aboutsummaryrefslogtreecommitdiff
path: root/src/stencil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stencil.c')
-rw-r--r--src/stencil.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/stencil.c b/src/stencil.c
new file mode 100644
index 0000000..007a7c6
--- /dev/null
+++ b/src/stencil.c
@@ -0,0 +1,66 @@
+#include "cctk.h"
+
+#include "util_ErrorCodes.h"
+#include "util_Table.h"
+
+#include "stencil.h"
+
+
+
+/* Determine whether a boundary with the symmetry handle symbnd is a
+ "regular" symmetry boundary (where the SBP stencils should not be
+ modified), or an outer boundary (or a multi-block boundary), where
+ the SBP stencils need to be modified. */
+
+void SBP_determine_onesided_stencil (const cGH * cctkGH, int * onesided)
+{
+ int symtable;
+ int pen_sym_handle;
+ CCTK_INT symbnd[6];
+ int ierr;
+ int d;
+
+ symtable = SymmetryTableHandleForGrid (cctkGH);
+ if (symtable<0) {
+ CCTK_WARN(0,"Cannot get symmetry table handle -- maybe thorn SymBase is not active?");
+ }
+
+ ierr = Util_TableGetIntArray (symtable, 6, symbnd, "symmetry_handle");
+ if (ierr!=6) {
+ CCTK_WARN(0,"Cannot get symmetry handles");
+ }
+
+ pen_sym_handle = SymmetryHandleOfName ( "multipatch" );
+
+ for (d=0; d<6; ++d) {
+ if (! cctkGH->cctk_bbox[d]) {
+ /* This is an inter-processor boundary */
+ onesided[d] = 0;
+ } else {
+ /* On an outer boundary (which is not a symmetry boundary),
+ symbnd < 0. */
+ if (symbnd[d] < 0) {
+ onesided[d] = 1;
+ } else {
+ if (pen_sym_handle >= 0) {
+ /* If the symmetry boundary is a multi-block boundary, then
+ symbnd = pen_sym_handle. However, we can only check that
+ thorn MultiPatch is active, i.e., whether pen_sym_handle
+ >= 0. */
+ if (symbnd[d] == pen_sym_handle) {
+ onesided[d] = 1;
+ } else {
+ onesided[d] = 0;
+ }
+ } else {
+ onesided[d] = 0;
+ }
+ }
+ }
+ }
+}
+
+CCTK_FCALL void CCTK_FNAME (SBP_determine_onesided_stencil) (CCTK_POINTER_TO_CONST cctkGH, int * onesided)
+{
+ SBP_determine_onesided_stencil (cctkGH, onesided);
+}