From ba0fae0a796d2dd0d23772b254827afaab15c191 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sun, 17 Apr 2011 22:55:57 -0400 Subject: CarpetRegrid2: New debugging parameter add_levels_automatically --- Carpet/CarpetRegrid2/param.ccl | 8 +++++++ Carpet/CarpetRegrid2/src/initialise.cc | 38 +++++++++++++++++----------------- Carpet/CarpetRegrid2/src/regrid.cc | 21 +++++++++++++++---- 3 files changed, 44 insertions(+), 23 deletions(-) (limited to 'Carpet/CarpetRegrid2') diff --git a/Carpet/CarpetRegrid2/param.ccl b/Carpet/CarpetRegrid2/param.ccl index 5f87e9a9a..c45241de9 100644 --- a/Carpet/CarpetRegrid2/param.ccl +++ b/Carpet/CarpetRegrid2/param.ccl @@ -71,6 +71,14 @@ CCTK_INT num_centres "Number of refinement centres" +################################################################################ + +BOOLEAN add_levels_automatically "Automatically add a new refinement level at each regrid" STEERABLE=always +{ +} "no" + + + ################################################################################ CCTK_INT num_levels_1 "Number of refinement levels for this centre" diff --git a/Carpet/CarpetRegrid2/src/initialise.cc b/Carpet/CarpetRegrid2/src/initialise.cc index 789f168e5..12c69410e 100644 --- a/Carpet/CarpetRegrid2/src/initialise.cc +++ b/Carpet/CarpetRegrid2/src/initialise.cc @@ -35,25 +35,25 @@ namespace CarpetRegrid2 { int lsh[2]; getvectorindex2 (cctkGH, "CarpetRegrid2::radii", lsh); -#define INIT_CENTRE(N) \ - do { \ - if (num_centres >= N) { \ - num_levels[N-1] = num_levels_##N; \ - active [N-1] = active_##N; \ - position_x[N-1] = position_x_##N; \ - position_y[N-1] = position_y_##N; \ - position_z[N-1] = position_z_##N; \ - for (int rl = 0; rl < 30; ++ rl) { \ - int const ind = index2 (lsh, rl, N-1); \ - radius[ind] = radius_##N[rl]; \ - radius_x[ind] = radius_x_##N[rl]; \ - radius_y[ind] = radius_y_##N[rl]; \ - radius_z[ind] = radius_z_##N[rl]; \ - } \ - old_position_x[N-1] = position_x[N-1]; \ - old_position_y[N-1] = position_y[N-1]; \ - old_position_z[N-1] = position_z[N-1]; \ - } \ +#define INIT_CENTRE(N) \ + do { \ + if (num_centres >= N) { \ + num_levels[N-1] = num_levels_##N; \ + active [N-1] = active_##N; \ + position_x[N-1] = position_x_##N; \ + position_y[N-1] = position_y_##N; \ + position_z[N-1] = position_z_##N; \ + for (int rl = 0; rl < 30; ++ rl) { \ + int const ind = index2 (lsh, rl, N-1); \ + radius[ind] = radius_##N[rl]; \ + radius_x[ind] = radius_x_##N[rl]; \ + radius_y[ind] = radius_y_##N[rl]; \ + radius_z[ind] = radius_z_##N[rl]; \ + } \ + old_position_x[N-1] = position_x[N-1]; \ + old_position_y[N-1] = position_y[N-1]; \ + old_position_z[N-1] = position_z[N-1]; \ + } \ } while (0) INIT_CENTRE( 1); diff --git a/Carpet/CarpetRegrid2/src/regrid.cc b/Carpet/CarpetRegrid2/src/regrid.cc index c4c9fa91d..a1989d22b 100644 --- a/Carpet/CarpetRegrid2/src/regrid.cc +++ b/Carpet/CarpetRegrid2/src/regrid.cc @@ -1140,11 +1140,12 @@ namespace CarpetRegrid2 { for (int n = 0; n < num_centres; ++ n) { if (active[n]) { CCTK_VInfo (CCTK_THORNSTRING, - "Centre %d is at position [%g,%g,%g]", + "Centre %d is at position [%g,%g,%g] with %d levels", n + 1, static_cast (position_x[n]), static_cast (position_y[n]), - static_cast (position_z[n])); + static_cast (position_z[n]), + static_cast (num_levels[n])); } else { CCTK_VInfo (CCTK_THORNSTRING, "Centre %d is not active", n + 1); @@ -1321,11 +1322,12 @@ namespace CarpetRegrid2 { for (int n = 0; n < num_centres; ++ n) { if (active[n]) { CCTK_VInfo (CCTK_THORNSTRING, - "Centre %d is at position [%g,%g,%g]", + "Centre %d is at position [%g,%g,%g] with %d levels", n + 1, static_cast (position_x[n]), static_cast (position_y[n]), - static_cast (position_z[n])); + static_cast (position_z[n]), + static_cast (num_levels[n])); } else { CCTK_VInfo (CCTK_THORNSTRING, "Centre %d is not active", n + 1); @@ -1343,6 +1345,17 @@ namespace CarpetRegrid2 { do_recompose = false; for (int n = 0; n < num_centres; ++ n) { + // When debugging, sneakily add a new level, but skip the + // initial regrid, and the regrid before the first time step + if (add_levels_automatically and cctk_iteration > 1) { + num_levels[n] = min (num_levels[n] + 1, maxreflevels); + CCTK_VInfo (CCTK_THORNSTRING, + "Increasing number of levels of centre %d to %d (it=%d)", + n + 1, + static_cast (num_levels[n]), + cctk_iteration); + } + // Regrid if a region became active or inactive do_recompose = active[n] != old_active[n]; if (do_recompose) break; -- cgit v1.2.3