aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary/Cactus
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2011-05-27 11:20:55 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2011-05-27 16:23:40 +0200
commitc47a4e5376c935baa2a4ebf787911dbee90a59bc (patch)
tree03a9e818925f28b3a64e0d12a242ea2b74ad9cc6 /Auxiliary/Cactus
parent4ced9076a98db22e333f2c0c7acb81d48673f64f (diff)
GenericFD: Add GenericFD_EnsureStencilFits
This function checks that there are enough ghost and boundary points for the stencil widths (ni, nj, nk) passed to it.
Diffstat (limited to 'Auxiliary/Cactus')
-rw-r--r--Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c42
-rw-r--r--Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h1
2 files changed, 43 insertions, 0 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
index 3f34e54..8c06940 100644
--- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
+++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
@@ -556,3 +556,45 @@ void GenericFD_GroupDataPointers(cGH const * restrict const cctkGH, const char *
ptrs[v] = (CCTK_REAL const *) CCTK_VarDataPtrI(cctkGH, 0 /* timelevel */, v1+v);
}
}
+
+void GenericFD_EnsureStencilFits(cGH const * restrict const cctkGH, const char *calc, int ni, int nj, int nk)
+{
+ DECLARE_CCTK_ARGUMENTS
+
+ int bws[6];
+ GenericFD_GetBoundaryWidths(cctkGH, bws);
+
+ int ns[] = {ni, nj, nk};
+ const char *dirs[] = {"x", "y", "z"};
+ const char *faces[] = {"lower", "upper"};
+ int abort = 0;
+
+ for (int dir = 0; dir < 3; dir++)
+ {
+ for (int face = 0; face < 2; face++)
+ {
+ int bw = bws[2*dir+face];
+ if (bw < ns[dir])
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,
+ "The stencil for %s requires %d points, but the %s %s boundary has only %d points.",
+ calc, ns[dir], faces[face], dirs[dir], bw);
+ abort = 1;
+ }
+ }
+ int gz = cctk_nghostzones[dir];
+ if (gz < ns[dir])
+ {
+ CCTK_VInfo(CCTK_THORNSTRING,
+ "The stencil for %s requires %d points, but there are only %d ghost zones in the %s direction.",
+ calc, ns[dir], gz, dirs[dir]);
+ abort = 1;
+ }
+ }
+
+ if (abort)
+ {
+ CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Insufficient ghost or boundary points for %s", calc);
+ }
+}
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
index ee35b05..401b4e0 100644
--- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
+++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
@@ -154,6 +154,7 @@ void GenericFD_LoopOverInterior(cGH const * restrict cctkGH, Kranc_Calculation c
void GenericFD_GroupDataPointers(cGH const * restrict const cctkGH, const char *group_name,
int nvars, CCTK_REAL const *restrict *ptrs);
+void GenericFD_EnsureStencilFits(cGH const * restrict const cctkGH, const char *calc, int ni, int nj, int nk);
#ifdef __cplusplus