diff options
author | cott <schnetter@cct.lsu.edu> | 2006-04-17 14:17:00 +0000 |
---|---|---|
committer | cott <schnetter@cct.lsu.edu> | 2006-04-17 14:17:00 +0000 |
commit | 731fa9add174636763abcd71e9ef5aade690adee (patch) | |
tree | e816309ee131ee4928598fdf26d512197ba4e9f5 /Carpet/Carpet/src/Evolve.cc | |
parent | d9d028a2700ff0082c32a471dc4e450de711dd56 (diff) |
Introducing group/bin PreRegrid.
Changes to:
Carpet/Carpet/schedule.ccl
Carpet/Carpet/src/Evolve.cc
Carpet/Carpet/src/Initialise.cc
It is now possible to schedule routines
in the schedule group PreRegrid (defined in
Carpet's schedule.ccl). Routines scheduled
in PreRegrid are called by Carpet before
regridding. This is necessary for consistency
when doing AMR and, e.g., checkpointing.
- Christian
darcs-hash:20060417141735-34d71-d96a74cdd306dace1ffe69d66d5e7aac385c6b19.gz
Diffstat (limited to 'Carpet/Carpet/src/Evolve.cc')
-rw-r--r-- | Carpet/Carpet/src/Evolve.cc | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc index 85c35c37b..af292ea38 100644 --- a/Carpet/Carpet/src/Evolve.cc +++ b/Carpet/Carpet/src/Evolve.cc @@ -120,6 +120,7 @@ namespace Carpet { static void AdvanceTime( cGH* cgh, CCTK_REAL initial_time ); static bool Regrid( cGH* cgh ); + static void PreRegrid( cGH* cgh ); static void PostRegrid( cGH* cgh ); static void EvolutionI( cGH* cgh ); static void Evolution_Restrict( cGH* cgh ); @@ -145,6 +146,8 @@ namespace Carpet { cgh->cctk_iteration, (double)cgh->cctk_time); } + PreRegrid( cgh ); + if( Regrid( cgh ) ) PostRegrid( cgh ); @@ -186,6 +189,33 @@ namespace Carpet { } } + void PreRegrid( cGH* cgh ) + { + for (int rl=0; rl<reflevels; ++rl) { + for (int ml=mglevels-1; ml>=0; --ml) { + const int do_every = maxtimereflevelfact / timereffacts.at(rl); + if ((cgh->cctk_iteration-1) % do_every == 0) { + enter_global_mode (cgh, ml); + enter_level_mode (cgh, rl); + + do_global_mode = reflevel==0; + do_meta_mode = do_global_mode and mglevel==mglevels-1; + + Waypoint ("Preregrid at iteration %d time %g%s%s", + cgh->cctk_iteration, (double)cgh->cctk_time, + (do_global_mode ? " (global)" : ""), + (do_meta_mode ? " (meta)" : "")); + + Checkpoint ("Scheduling PREREGRID"); + CCTK_ScheduleTraverse ("PreRegrid", cgh, CallFunction); + + leave_level_mode (cgh); + leave_global_mode (cgh); + } + } + } + } + bool Regrid( cGH* cgh ) { bool did_regrid = false; @@ -211,22 +241,25 @@ namespace Carpet { { for (int rl=0; rl<reflevels; ++rl) { for (int ml=mglevels-1; ml>=0; --ml) { - enter_global_mode (cgh, ml); - enter_level_mode (cgh, rl); + const int do_every = maxtimereflevelfact / timereffacts.at(rl); + if ((cgh->cctk_iteration-1) % do_every == 0) { + enter_global_mode (cgh, ml); + enter_level_mode (cgh, rl); - do_global_mode = reflevel==0; - do_meta_mode = do_global_mode and mglevel==mglevels-1; + do_global_mode = reflevel==0; + do_meta_mode = do_global_mode and mglevel==mglevels-1; - Waypoint ("Postregrid at iteration %d time %g%s%s", - cgh->cctk_iteration, (double)cgh->cctk_time, - (do_global_mode ? " (global)" : ""), - (do_meta_mode ? " (meta)" : "")); + Waypoint ("Postregrid at iteration %d time %g%s%s", + cgh->cctk_iteration, (double)cgh->cctk_time, + (do_global_mode ? " (global)" : ""), + (do_meta_mode ? " (meta)" : "")); - Checkpoint ("Scheduling POSTREGRID"); - CCTK_ScheduleTraverse ("CCTK_POSTREGRID", cgh, CallFunction); + Checkpoint ("Scheduling POSTREGRID"); + CCTK_ScheduleTraverse ("CCTK_POSTREGRID", cgh, CallFunction); - leave_level_mode (cgh); - leave_global_mode (cgh); + leave_level_mode (cgh); + leave_global_mode (cgh); + } } } } |