From a1e00fbca790be568d7efd1d5032555f4806e2e2 Mon Sep 17 00:00:00 2001 From: korobkin Date: Tue, 6 May 2008 21:22:45 +0000 Subject: (*) 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 --- interface.ccl | 31 ++++++++++---- src/call_derivs.c | 16 ++++--- src/dissipation.c | 13 +++--- src/get_offset.c | 122 ++++++++++++++++++++++++++++++++---------------------- 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