aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschnetter <schnetter@1bf05452-ddb3-4880-bfa1-00436340132b>2003-05-06 11:45:52 +0000
committerschnetter <schnetter@1bf05452-ddb3-4880-bfa1-00436340132b>2003-05-06 11:45:52 +0000
commit24ab84c1b08adfad5c1fa8d6a65bb923a6474709 (patch)
tree7dcfe980747c004592fa0e94f9a98171bcf9209b /src
parent7d957cbc6da68f0b6bc24065ee7ada778f688a70 (diff)
Works.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Periodic/trunk@3 1bf05452-ddb3-4880-bfa1-00436340132b
Diffstat (limited to 'src')
-rw-r--r--src/make.code.defn2
-rw-r--r--src/periodic.c91
-rw-r--r--src/periodic.h5
3 files changed, 89 insertions, 9 deletions
diff --git a/src/make.code.defn b/src/make.code.defn
index a62de81..8c52d6b 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -2,7 +2,7 @@
# $Header$
# Source files in this directory
-SRCS =
+SRCS = periodic.c
# Subdirectories containing source files
SUBDIRS =
diff --git a/src/periodic.c b/src/periodic.c
index feb6aec..7339d9e 100644
--- a/src/periodic.c
+++ b/src/periodic.c
@@ -2,10 +2,11 @@
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "Slab.h"
-#include "Periodic.h"
+#include "periodic.h"
static const char * restrict const rcsid = "$Header$";
CCTK_FILEVERSION(TAT_Periodic_periodic_c);
@@ -17,6 +18,8 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
int const * restrict const stencil,
int const vi)
{
+ DECLARE_CCTK_PARAMETERS;
+
cGroup group;
cGroupDynamicData data;
void * restrict varptr;
@@ -53,6 +56,11 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
do_periodic[1] = periodic || periodic_y;
do_periodic[2] = periodic || periodic_z;
+ printf ("BndPeriodicVI var=%s\n", CCTK_FullName(vi));
+ for (d=0; d<3; ++d) {
+ printf (" d=%d per=%d ste=%d\n", d, do_periodic[d], stencil[d]);
+ }
+
/* Allocate slab transfer description */
xferinfo = malloc(group.dim * sizeof *xferinfo);
assert (xferinfo);
@@ -91,19 +99,20 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
if (f==0) {
/* Fill in lower face */
- xferinfo[dir].src.off = data.lsh[d] - data.nghostzones[d];
- xferinfo[dir].src.len = data.nghostzones[d];
- xferinfo[dir].dst.len = data.nghostzones[d];
+ xferinfo[dir].src.off = data.gsh[dir] - 2 * stencil[dir];
+ xferinfo[dir].src.len = stencil[dir];
+ xferinfo[dir].dst.len = stencil[dir];
} else {
/* Fill in upper face */
- xferinfo[dir].src.len = data.nghostzones[d];
- xferinfo[dir].dst.off = data.lsh[d] - data.nghostzones[d];
- xferinfo[dir].dst.len = data.nghostzones[d];
+ xferinfo[dir].src.off = stencil[dir];
+ xferinfo[dir].src.len = stencil[dir];
+ xferinfo[dir].dst.off = data.gsh[dir] - stencil[dir];
+ xferinfo[dir].dst.len = stencil[dir];
}
ierr = Slab_Transfer (cctkGH, group.dim, xferinfo, -1,
group.vartype, varptr, group.vartype, varptr);
- assert (ierr);
+ assert (!ierr);
} /* for f */
@@ -161,3 +170,69 @@ BndPeriodicGN (cGH const * restrict const cctkGH,
assert (gi>=0 && gi<CCTK_NumGroups());
return BndPeriodicGI (cctkGH, stencil, gi);
}
+
+
+
+void
+Periodic_ApplyBC (cGH const * restrict const cctkGH)
+{
+ int nvars;
+ CCTK_INT * restrict indices;
+ CCTK_INT * restrict faces;
+ CCTK_INT * restrict widths;
+ CCTK_INT * restrict tables;
+ int vi;
+ int dim;
+ int * restrict stencil;
+ int i;
+ int d;
+ int ierr;
+
+ assert (cctkGH);
+
+ nvars = Boundary_SelectedGVs (cctkGH, 0, 0, 0, 0, 0, 0);
+ assert (nvars>=0);
+
+ indices = malloc (nvars * sizeof *indices);
+ assert (indices);
+ faces = malloc (nvars * sizeof *faces);
+ assert (faces);
+ widths = malloc (nvars * sizeof *widths);
+ assert (widths);
+ tables = malloc (nvars * sizeof *tables);
+ assert (tables);
+
+ ierr = Boundary_SelectedGVs
+ (cctkGH, nvars, indices, faces, widths, tables, 0);
+ assert (ierr == nvars);
+
+ for (i=0; i<nvars; ++i) {
+ vi = indices[i];
+ assert (vi>=0 && vi<CCTK_NumVars());
+
+ assert (widths[i] >= 0);
+
+ dim = CCTK_GroupDimFromVarI (vi);
+ assert (dim>=0);
+
+ stencil = malloc (dim * sizeof *stencil);
+ assert (stencil);
+#if 0
+ for (d=0; d<dim; ++d) {
+ stencil[d] = widths[i];
+ }
+#endif
+ ierr = CCTK_GroupnghostzonesVI (cctkGH, dim, stencil, vi);
+ assert (!ierr);
+
+ ierr = BndPeriodicVI (cctkGH, stencil, vi);
+ assert (!ierr);
+
+ free (stencil);
+ }
+
+ free (indices);
+ free (faces);
+ free (widths);
+ free (tables);
+}
diff --git a/src/periodic.h b/src/periodic.h
index 2f381f3..c423c73 100644
--- a/src/periodic.h
+++ b/src/periodic.h
@@ -25,5 +25,10 @@ BndPeriodicGN (cGH const * restrict const cctkGH,
int const * restrict const stencil,
char const * restrict const gn);
+
+
+void
+Periodic_ApplyBC (cGH const * restrict const cctkGH);
+
#endif /* defined PERIODIC_H */