From 44ddb460c77695935de4d408d089946b26cdba94 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 28 Sep 2006 03:33:00 +0000 Subject: CarpetRegrid2: Regrid at most once per iteration Remember the iteration at which the last regridding happened, and regrid only once per iteration. darcs-hash:20060928033352-dae7b-5f92904364803097578bc43c9c394800cbf1cf4a.gz --- Carpet/CarpetRegrid2/src/regrid.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Carpet') diff --git a/Carpet/CarpetRegrid2/src/regrid.cc b/Carpet/CarpetRegrid2/src/regrid.cc index 765b1f758..78da21904 100644 --- a/Carpet/CarpetRegrid2/src/regrid.cc +++ b/Carpet/CarpetRegrid2/src/regrid.cc @@ -487,7 +487,12 @@ namespace CarpetRegrid2 { assert (Carpet::is_singlemap_mode()); // Decide whether to change the grid hierarchy - // (We always do) + static bool last_iteration_initialised = false; + static vector last_iteration; + if (not last_iteration_initialised) { + last_iteration_initialised = true; + last_iteration.resize (maps, -1); + } bool do_recompose; if (force) { do_recompose = true; @@ -498,11 +503,15 @@ namespace CarpetRegrid2 { do_recompose = cctkGH->cctk_iteration == 0; } else { do_recompose = - cctkGH->cctk_iteration == 0 or - (cctkGH->cctk_iteration > 0 and - (cctkGH->cctk_iteration - 1) % regrid_every == 0); + (cctkGH->cctk_iteration == 0 or + (cctkGH->cctk_iteration > 0 and + (cctkGH->cctk_iteration - 1) % regrid_every == 0 and + cctkGH->cctk_iteration > last_iteration.at(Carpet::map))); } } + if (do_recompose) { + last_iteration.at(Carpet::map) = cctkGH->cctk_iteration; + } if (do_recompose) { @@ -562,7 +571,9 @@ namespace CarpetRegrid2 { cctkGH->cctk_iteration > last_iteration)); } } - last_iteration = cctkGH->cctk_iteration; + if (do_recompose) { + last_iteration = cctkGH->cctk_iteration; + } if (do_recompose) { -- cgit v1.2.3