aboutsummaryrefslogtreecommitdiff
path: root/src/get_offset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/get_offset.c')
-rw-r--r--src/get_offset.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/get_offset.c b/src/get_offset.c
index d1a35d9..a3b8b90 100644
--- a/src/get_offset.c
+++ b/src/get_offset.c
@@ -3,7 +3,13 @@
#include "cctk_Functions.h"
#include "cctk_Parameters.h"
-void CCTK_FCALL CCTK_FNAME(get_grid_offsets) (CCTK_INT *offset) {
+/***
+ * This is a utility function which reads values of shiftout parameters from
+ * thorn CoordBase into an integer array offset[]. It is declared at the thorn
+ * interface as GetFDGridOffsets and can be called from Fortran routines.
+ * This is necessary since CCTK_ParameterGet is not available in Fortran.
+ */
+void get_grid_offsets (CCTK_INT *offset) {
DECLARE_CCTK_PARAMETERS;
@@ -34,5 +40,46 @@ void CCTK_FCALL CCTK_FNAME(get_grid_offsets) (CCTK_INT *offset) {
offset[5] = *shiftout_z_upper;
}
-
}
+
+/***
+ * This function returns the effective values of local index ranges,
+ * taking into account ghost zones and boundary_shiftout_* values.
+ * If the use_shiftout=no, boundary offsets are set to zero.
+ * Index ranges are set in Fortran convention (starting from 1):
+ * - imin <= i <= imax
+ * - jmin <= j <= jmax
+ * - kmin <= k <= kmax
+ * This function is declared in interface.ccl as GetLSHIndexRanges
+ * to be used by other thorns, which need to know the actual index
+ * ranges for the region where SBP thorn will apply derivative /
+ * dissipation operators.
+ */
+void get_lsh_iranges ( const CCTK_POINTER_TO_CONST cctkGH_,
+ CCTK_INT *imin, CCTK_INT *imax,
+ CCTK_INT *jmin, CCTK_INT *jmax,
+ CCTK_INT *kmin, CCTK_INT *kmax)
+{
+ cGH const * restrict const cctkGH = cctkGH_;
+ DECLARE_CCTK_PARAMETERS
+ DECLARE_CCTK_ARGUMENTS
+
+ int i, offset[6];
+
+ for (i=0;i<6;i++) offset[i] = 0;
+ if (use_shiftout) get_grid_offsets (offset);
+
+ *imin = 1 + ((cctk_bbox[0]) ? offset[0] : cctk_nghostzones[0]);
+ *jmin = 1 + ((cctk_bbox[2]) ? offset[2] : cctk_nghostzones[1]);
+ *kmin = 1 + ((cctk_bbox[4]) ? offset[4] : cctk_nghostzones[2]);
+
+ *imax = cctk_lsh[0] - ((cctk_bbox[1]) ? offset[1] : cctk_nghostzones[0] );
+ *jmax = cctk_lsh[1] - ((cctk_bbox[3]) ? offset[3] : cctk_nghostzones[1] );
+ *kmax = cctk_lsh[2] - ((cctk_bbox[5]) ? offset[5] : cctk_nghostzones[2] );
+
+ /*** debug ***/
+ CCTK_VInfo (CCTK_THORNSTRING, "imn-kmx = {%d, %d, %d, %d, %d, %d}",
+ *imin, *imax, *jmin, *jmax, *kmin, *kmax);
+}
+
+