aboutsummaryrefslogtreecommitdiff
path: root/src/CartGrid3D.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/CartGrid3D.c')
-rw-r--r--src/CartGrid3D.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/CartGrid3D.c b/src/CartGrid3D.c
index d23d73c..df5539c 100644
--- a/src/CartGrid3D.c
+++ b/src/CartGrid3D.c
@@ -71,24 +71,41 @@ void DecodeSymParameters3D(int sym[6]);
@@*/
void CartGrid3D_SetRanges(CCTK_ARGUMENTS)
{
- int i, j, k, idx;
- int is_coarsest_refinement_level, coord_handle, ierr;
+ int i;
+ int coord_handle, ierr;
CCTK_REAL this_delta[3], origin[3], min1[3], max1[3];
CCTK_REAL *coarse_delta[3];
double lower[3], upper[3];
int domainsym[6], cntstag[3], loweri[3], upperi[3], do_periodic[3];
char coord_name[16];
- DECLARE_CCTK_ARGUMENTS
- DECLARE_CCTK_PARAMETERS
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- /* ranges need to be set up only once, on the coarsest refinement level */
- is_coarsest_refinement_level = cctk_levfac[0] == 1 &&
- cctk_levfac[1] == 1 &&
- cctk_levfac[2] == 1;
- if (! is_coarsest_refinement_level)
+ if (CCTK_EQUALS (set_coordinate_ranges_on, "first level"))
{
- return;
+ /* Ranges must be set up only once, and this must happen on the
+ coarse grid. However, the coarse grid itself may not actually
+ exist; in this case, use the coarsest existing grid. We assume
+ that this is the first grid for which this routine is
+ called. */
+ static int is_coarsest_refinement_level = 1;
+ if (! is_coarsest_refinement_level)
+ {
+ return;
+ }
+ is_coarsest_refinement_level = 0;
+ }
+ else
+ {
+ /* Ranges need to be set up only once (or once per map), on the
+ coarsest refinement level */
+ int const is_coarsest_refinement_level =
+ cctk_levfac[0] == 1 && cctk_levfac[1] == 1 && cctk_levfac[2] == 1;
+ if (! is_coarsest_refinement_level)
+ {
+ return;
+ }
}
coarse_delta[0] = coarse_dx;