aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkorobkin <korobkin@f69c4107-0314-4c4f-9ad4-17e986b73f4a>2008-05-06 21:22:45 +0000
committerkorobkin <korobkin@f69c4107-0314-4c4f-9ad4-17e986b73f4a>2008-05-06 21:22:45 +0000
commita1e00fbca790be568d7efd1d5032555f4806e2e2 (patch)
tree525c8904914e332ce50457037e0ad2e92702ef82
parentac1d410652ea832f67e8fd20a0c1345a973ef392 (diff)
(*) Small modifications to use GetBoundarySpecification or
MultiPatch_GetBoundarySpecification instead of reading shiftout parameters directly from the CoordBase thorn. git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/SummationByParts/trunk@113 f69c4107-0314-4c4f-9ad4-17e986b73f4a
-rw-r--r--interface.ccl31
-rw-r--r--src/call_derivs.c16
-rw-r--r--src/dissipation.c13
-rw-r--r--src/get_offset.c122
4 files changed, 113 insertions, 69 deletions
diff --git a/interface.ccl b/interface.ccl
index 381ac63..bc6c63b 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -71,15 +71,11 @@ PROVIDES FUNCTION GetScalProdDiag WITH SBP_GetScalProdDiag LANGUAGE Fortran
CCTK_REAL FUNCTION GetScalProdCoeff ()
PROVIDES FUNCTION GetScalProdCoeff WITH GetCoeff LANGUAGE Fortran
-SUBROUTINE GetFDGridOffsets ( CCTK_INT OUT ARRAY offset )
-PROVIDES FUNCTION GetFDGridOffsets WITH get_grid_offsets LANGUAGE C
-
-SUBROUTINE GetLSHIndexRanges ( \
+SUBROUTINE GetLshIndexRanges ( \
CCTK_POINTER_TO_CONST IN cctkGH, \
- CCTK_INT OUT imn, CCTK_INT OUT imx, \
- CCTK_INT OUT jmn, CCTK_INT OUT jmx, \
- CCTK_INT OUT kmn, CCTK_INT OUT kmx )
-PROVIDES FUNCTION GetLSHIndexRanges WITH get_lsh_iranges LANGUAGE C
+ CCTK_INT OUT ARRAY imin, \
+ CCTK_INT OUT ARRAY imax )
+PROVIDES FUNCTION GetLshIndexRanges WITH get_lsh_iranges LANGUAGE C
CCTK_INT FUNCTION GetDomainSpecification \
(CCTK_INT IN size, \
@@ -92,6 +88,25 @@ CCTK_INT FUNCTION GetDomainSpecification \
CCTK_REAL OUT ARRAY spacing)
USES FUNCTION GetDomainSpecification
+CCTK_INT FUNCTION \
+ GetBoundarySpecification \
+ (CCTK_INT IN size, \
+ CCTK_INT OUT ARRAY nboundaryzones, \
+ CCTK_INT OUT ARRAY is_internal, \
+ CCTK_INT OUT ARRAY is_staggered, \
+ CCTK_INT OUT ARRAY shiftout)
+USES FUNCTION GetBoundarySpecification
+
+CCTK_INT FUNCTION \
+ MultiPatch_GetBoundarySpecification \
+ (CCTK_INT IN map, \
+ CCTK_INT IN size, \
+ CCTK_INT OUT ARRAY nboundaryzones, \
+ CCTK_INT OUT ARRAY is_internal, \
+ CCTK_INT OUT ARRAY is_staggered, \
+ CCTK_INT OUT ARRAY shiftout)
+USES FUNCTION MultiPatch_GetBoundarySpecification
+
CCTK_INT FUNCTION \
SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST IN cctkGH)
REQUIRES FUNCTION SymmetryTableHandleForGrid
diff --git a/src/call_derivs.c b/src/call_derivs.c
index 56b41e4..8358895 100644
--- a/src/call_derivs.c
+++ b/src/call_derivs.c
@@ -25,6 +25,12 @@ void DiffGv ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir,
CCTK_INT dummy[6];
int nelements;
+ /*
+ CCTK_INT nboundaryzones[6];
+ CCTK_INT is_internal[6];
+ CCTK_INT is_staggered[6];
+ */
+
void CCTK_FCALL CCTK_FNAME(deriv_gf_2_1)(const CCTK_REAL *var,
const CCTK_INT *ni,
const CCTK_INT *nj,
@@ -126,7 +132,7 @@ void DiffGv ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir,
const CCTK_REAL *delta,
CCTK_REAL *dvar);
- void get_grid_offsets (CCTK_INT *offset);
+ void get_shiftout ( const CCTK_POINTER_TO_CONST cctkGH_, CCTK_INT *offset);
void CCTK_FCALL CCTK_FNAME(SBP_Poisoning) (
const CCTK_INT *ni,
@@ -165,14 +171,12 @@ void DiffGv ( const CCTK_POINTER_TO_CONST cctkGH_, const CCTK_INT dir,
}
}
+ /* get values of boundary_shiftout_* from CoordBase */
for (i=0; i<6; i++) {
offset[i] = 0;
}
- if ( use_shiftout ) {
- /* get values of boundary_shiftout_* from CoordBase */
- get_grid_offsets (offset);
- }
-
+ get_shiftout (cctkGH_, offset);
+ /*GetBoundarySpecification (6, nboundaryzones, is_internal, is_staggered, offset);*/
SBP_determine_onesided_stencil (cctkGH, onesided);
diff --git a/src/dissipation.c b/src/dissipation.c
index 4dbacbf..548f522 100644
--- a/src/dissipation.c
+++ b/src/dissipation.c
@@ -145,7 +145,7 @@ void CCTK_FCALL CCTK_FNAME(dissipation_8_4_alt) (const CCTK_REAL *var,
const CCTK_REAL *dx,
const CCTK_REAL *epsdis,
CCTK_REAL *rhs);
-void get_grid_offsets (CCTK_INT *offset);
+void get_shiftout ( const CCTK_POINTER_TO_CONST cctkGH_, CCTK_INT *offset);
void CCTK_FCALL CCTK_FNAME(SBP_Poisoning) ( const CCTK_INT *ni,
const CCTK_INT *nj,
@@ -188,6 +188,10 @@ apply (int const varindex, char const * const optstring, void * const arg)
CCTK_INT offset[6];
int type;
int i;
+
+ CCTK_INT nboundaryzones[6];
+ CCTK_INT is_internal[6];
+ CCTK_INT is_staggered[6];
assert (varindex >= 0);
@@ -196,13 +200,12 @@ apply (int const varindex, char const * const optstring, void * const arg)
gsize[d] = cctk_nghostzones[d];
}
+ /* get values of boundary_shiftout_* from CoordBase */
for (i=0; i<6; i++) {
offset[i] = 0;
}
- if ( use_shiftout ) {
- /* get values of boundary_shiftout_* from CoordBase */
- get_grid_offsets (offset);
- }
+ get_shiftout (cctkGH, offset);
+ /*GetBoundarySpecification (6, nboundaryzones, is_internal, is_staggered, offset);*/
SBP_determine_onesided_stencil (cctkGH, onesided);
for (d=0; d<6; ++d) {
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] );
+ }
}