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.c122
1 files changed, 72 insertions, 50 deletions
diff --git a/src/get_offset.c b/src/get_offset.c
index da94d0e..c955681 100644
--- a/src/get_offset.c
+++ b/src/get_offset.c
@@ -4,78 +4,100 @@
#include "cctk_Parameters.h"
/***
- * 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.
+ * A function to switch between CoordBase::GetBoundarySpecification and
+ * MultiPatch::MultiPatch_GetBoundarySpecification, depending on whether
+ * MultiPatch is present in compilation
*/
-void get_grid_offsets (CCTK_INT *offset) {
-
- DECLARE_CCTK_PARAMETERS;
+void get_shiftout ( const CCTK_POINTER_TO_CONST cctkGH_,
+ CCTK_INT *shiftout )
+{
+ cGH const * restrict const cctkGH = cctkGH_;
- int i, type;
+ DECLARE_CCTK_PARAMETERS
+ DECLARE_CCTK_ARGUMENTS
- const CCTK_INT* shiftout_x_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_x_lower", "coordbase", &type );
- if (shiftout_x_lower != NULL ) {
- offset[0] = *shiftout_x_lower;
- }
- const CCTK_INT* shiftout_x_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_x_upper", "coordbase", &type );
- if (shiftout_x_upper != NULL ) {
- offset[1] = *shiftout_x_upper;
- }
- const CCTK_INT* shiftout_y_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_y_lower", "coordbase", &type );
- if (shiftout_y_lower != NULL ) {
- offset[2] = *shiftout_y_lower;
- }
- const CCTK_INT* shiftout_y_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_y_upper", "coordbase", &type );
- if (shiftout_y_upper != NULL ) {
- offset[3] = *shiftout_y_upper;
- }
- const CCTK_INT* shiftout_z_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_z_lower", "coordbase", &type );
- if (shiftout_z_lower != NULL ) {
- offset[4] = *shiftout_z_lower;
- }
- const CCTK_INT* shiftout_z_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_z_upper", "coordbase", &type );
- if (shiftout_z_upper != NULL ) {
- offset[5] = *shiftout_z_upper;
- }
+ int i;
+ CCTK_INT nboundaryzones[6];
+ CCTK_INT is_internal[6];
+ CCTK_INT is_staggered[6];
+ for (i=0;i<6;i++) shiftout[i] = 0;
+ if (use_shiftout) {
+ if (CCTK_IsFunctionAliased ("MultiPatch_GetBoundarySpecification")) {
+ MultiPatch_GetBoundarySpecification (
+ MultiPatch_GetMap(cctkGH_),
+ 6,
+ nboundaryzones,
+ is_internal,
+ is_staggered,
+ shiftout);
+ } else if (CCTK_IsFunctionAliased ("GetBoundarySpecification")) {
+ GetBoundarySpecification (6,
+ nboundaryzones,
+ is_internal,
+ is_staggered,
+ shiftout);
+ } else {
+ CCTK_WARN (CCTK_WARN_ABORT,
+ "Thorns providing GetBoundarySpecification function not found.");
+ }
+ }
}
/***
* 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
+ * Index ranges are set in C convention (starting from 0). I.e.,
+ * to iterate over the grid in C, one might use
+ * for(i=imin[0];i<imax[0];i++)
+ * for(j=imin[1];j<imax[1];j++)
+ * for(k=imin[2];k<imax[2];k++)
+ * {...}
+ * In Fortran, one would write the main loop like this:
+ * do i = imin(1)+1,imax(1)
+ * do j = imin(2)+1,imax(2)
+ * do k = imin(3)+1,imax(3)
+ * ...
+ * enddo
+ * enddo
+ * enddo
+ * 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)
+ CCTK_INT *imin,
+ CCTK_INT *imax)
{
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);
+ int i;
+ CCTK_INT shiftout[6];
+ /*
+ CCTK_INT nboundaryzones[6];
+ CCTK_INT is_internal[6];
+ CCTK_INT is_staggered[6];
- *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]);
+ for (i=0;i<6;i++) shiftout[i] = 0;
+ if (use_shiftout) {
+ GetBoundarySpecification (6,
+ nboundaryzones,
+ is_internal,
+ is_staggered,
+ shiftout);
+ }
+ */
+ get_shiftout (cctkGH_, shiftout);
- *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] );
+ for (i=0;i<3;i++) {
+ imin[i] = ((cctk_bbox[2*i]) ? shiftout[2*i] : cctk_nghostzones[i]);
+ imax[i] = cctk_lsh[i]
+ - ((cctk_bbox[2*i+1]) ? shiftout[2*i+1] : cctk_nghostzones[i] );
+ }
}