aboutsummaryrefslogtreecommitdiff
path: root/src/periodic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/periodic.c')
-rw-r--r--src/periodic.c105
1 files changed, 71 insertions, 34 deletions
diff --git a/src/periodic.c b/src/periodic.c
index 1cfb274..b04f45a 100644
--- a/src/periodic.c
+++ b/src/periodic.c
@@ -6,7 +6,6 @@
#include "cctk.h"
#include "cctk_Parameters.h"
#include "Slab.h"
-#include "periodic.h"
static const char * restrict const rcsid = "$Header$";
CCTK_FILEVERSION(TAT_Periodic_periodic_c);
@@ -14,18 +13,18 @@ CCTK_FILEVERSION(TAT_Periodic_periodic_c);
int
-BndPeriodicVI (cGH const * restrict const cctkGH,
+BndPeriodicVI (CCTK_POINTER_TO_CONST _GH,
+ int size,
int const * restrict const stencil,
+ int const do_periodic[3],
int const vi)
{
- DECLARE_CCTK_PARAMETERS;
-
+ cGH const * restrict const cctkGH = _GH;
+
cGroup group;
cGroupDynamicData data;
- char * restrict fullname;
void * restrict varptr;
struct xferinfo * restrict xferinfo;
- int do_periodic[3];
int global_bbox[6];
int global_lbnd[3], global_ubnd[3];
int fake_bbox[6];
@@ -39,15 +38,6 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
assert (stencil);
assert (vi>=0 && vi<CCTK_NumVars());
- if (verbose) {
- fullname = CCTK_FullName(vi);
- assert (fullname);
- CCTK_VInfo (CCTK_THORNSTRING,
- "Applying periodicity boundary conditions to \"%s\"",
- fullname);
- free (fullname);
- }
-
/* Get and check group info */
gi = CCTK_GroupIndexFromVarI (vi);
assert (gi>=0 && gi<CCTK_NumGroups());
@@ -57,6 +47,12 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
assert (group.grouptype == CCTK_GF);
assert (group.disttype == CCTK_DISTRIB_DEFAULT);
assert (group.stagtype == 0);
+
+ if(group.dim != size) {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The group \"%s\" has dimension %d, but the given stencil has "
+ "size %d.", CCTK_GroupNameFromVarI(vi), group.dim, size);
+ }
ierr = CCTK_GroupDynamicData (cctkGH, gi, &data);
assert (!ierr);
@@ -64,11 +60,6 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
varptr = CCTK_VarDataPtrI (cctkGH, 0, vi);
assert (varptr);
- /* Condition periodicity information */
- do_periodic[0] = periodic || periodic_x;
- do_periodic[1] = periodic || periodic_y;
- do_periodic[2] = periodic || periodic_z;
-
{
int min_handle, max_handle;
CCTK_REAL local[6], global[6];
@@ -108,13 +99,7 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
assert (stencil[dir] >= 0);
if (data.gsh[dir] < 2*stencil[dir]+1) {
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "The group \"%s\" has in the %c-direction only %d grid points. "
- "This is not large enough for a periodic boundary that is %d grid points wide. "
- "The group needs to have at least %d grid points in that direction.",
- CCTK_GroupNameFromVarI(vi), "xyz"[dir], data.gsh[dir],
- stencil[dir],
- 2*stencil[dir]+1);
+ return dir+1;
}
/* Loop over faces */
@@ -214,22 +199,30 @@ BndPeriodicVI (cGH const * restrict const cctkGH,
int
-BndPeriodicVN (cGH const * restrict const cctkGH,
+BndPeriodicVN (CCTK_POINTER_TO_CONST _GH,
+ int size,
int const * restrict const stencil,
+ int const do_periodic[3],
char const * restrict const vn)
{
+ cGH const * restrict const cctkGH = _GH;
+
int const vi = CCTK_VarIndex (vn);
assert (vi>=0 && vi<CCTK_NumVars());
- return BndPeriodicVI (cctkGH, stencil, vi);
+ return BndPeriodicVI (_GH, size, stencil, do_periodic, vi);
}
int
-BndPeriodicGI (cGH const * restrict const cctkGH,
+BndPeriodicGI (CCTK_POINTER_TO_CONST _GH,
+ int size,
int const * restrict const stencil,
+ int const do_periodic[3],
int const gi)
{
+ cGH const * restrict const cctkGH = _GH;
+
int v1, nv;
int vi;
int ierr;
@@ -240,7 +233,7 @@ BndPeriodicGI (cGH const * restrict const cctkGH,
v1 = CCTK_FirstVarIndexI(gi);
assert (v1>=0 && v1<CCTK_NumVars());
for (vi=v1; vi<v1+nv; ++vi) {
- ierr = BndPeriodicVI (cctkGH, stencil, vi);
+ ierr = BndPeriodicVI (_GH, size, stencil, do_periodic, vi);
if (ierr) return ierr;
}
}
@@ -250,13 +243,15 @@ BndPeriodicGI (cGH const * restrict const cctkGH,
int
-BndPeriodicGN (cGH const * restrict const cctkGH,
+BndPeriodicGN (CCTK_POINTER_TO_CONST _GH,
+ int size,
int const * restrict const stencil,
+ int const do_periodic[3],
char const * restrict const gn)
{
int const gi = CCTK_GroupIndex (gn);
assert (gi>=0 && gi<CCTK_NumGroups());
- return BndPeriodicGI (cctkGH, stencil, gi);
+ return BndPeriodicGI (_GH, size, stencil, do_periodic, gi);
}
@@ -303,6 +298,15 @@ Periodic_RegisterBC (cGH * restrict const cctkGH)
void
Periodic_ApplyBC (cGH const * restrict const cctkGH)
{
+ DECLARE_CCTK_PARAMETERS;
+
+ int do_periodic[3];
+ do_periodic[0] = periodic || periodic_x;
+ do_periodic[1] = periodic || periodic_y;
+ do_periodic[2] = periodic || periodic_z;
+
+ char * fullname;
+
int nvars;
CCTK_INT * restrict indices;
CCTK_INT * restrict faces;
@@ -346,7 +350,40 @@ Periodic_ApplyBC (cGH const * restrict const cctkGH)
ierr = CCTK_GroupnghostzonesVI (cctkGH, dim, stencil, vi);
assert (!ierr);
- ierr = BndPeriodicVI (cctkGH, stencil, vi);
+ if (verbose) {
+ fullname = CCTK_FullName(vi);
+ assert (fullname);
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Applying periodicity boundary conditions to \"%s\"",
+ fullname);
+ free (fullname);
+ }
+
+ ierr = BndPeriodicVI (cctkGH, dim, stencil, do_periodic, vi);
+
+ if(ierr > 0 && ierr < 4) {
+ int dir = ierr-1;
+
+ int gi;
+ cGroup group;
+ cGroupDynamicData data;
+
+ gi = CCTK_GroupIndexFromVarI (vi);
+ ierr = CCTK_GroupData (gi, &group);
+ assert (!ierr);
+
+ ierr = CCTK_GroupDynamicData (cctkGH, gi, &data);
+ assert (!ierr);
+
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "The group \"%s\" has in the %c-direction only %d grid points. "
+ "This is not large enough for a periodic boundary that is %d grid points wide. "
+ "The group needs to have at least %d grid points in that direction.",
+ CCTK_GroupNameFromVarI(vi), "xyz"[dir], data.gsh[dir],
+ stencil[dir],
+ 2*stencil[dir]+1);
+ }
+
assert (!ierr);
free (stencil);