diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2010-03-18 15:10:52 -0700 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 16:45:33 +0000 |
commit | 0707cfeb82f565afec604f39202dafcbef889db0 (patch) | |
tree | 820f1ac0bc04d5f9827e4e00bf1efccb6d76727e /Carpet/Carpet/src/Evolve.cc | |
parent | 6b2d5314e79a5547f2fdd1dc4898bdeef74da9f2 (diff) |
Re-organise time level handling
Store the current Cactus time (and not a fake Carpet time) in the th
"time hiearchy". This removes the now redundant "leveltimes" data
structure in Carpet.
Add past time levels to th, so that it can store the time for past
time levels instead of assuming the time step size is constant. This
allows changing the time step size during evolution.
Share the time hierarchy between all maps, instead of having one time
hierarchy per map.
Simplify the time level cycling and time stepping code used during
evolution.
Improve structure of the code that loops over time levels for certain
schedule bins. Introduce a new Carpet variable "timelevel", similar
to "reflevel".
This also makes it possible to avoid time interpolation for the past
time levels during regridding. The past time levels of the fine grid
then remain aligned (in time) with the past time levels of the coarse
grid. This is controlled by a new parameter
"time_interpolation_during_regridding", which defaults to "yes" for
backwards compatibility.
Simplify the three time level initialisation. Instead of initialising
all three time levels by taking altogether three time steps (forwards
and backwards), initialise only one past time level by taking one time
step backwards. The remaining time level is initialised during the
first time step of the evolution, which begins by cycling time levels,
which drops the non-initialised last time level anyway.
Update Carpet and the mode handling correspondingly.
Update the CarpetIOHDF5 checkpoint format correspondingly.
Update CarpetInterp, CarpetReduce, and CarpetRegrid2 correspondingly.
Update CarpetJacobi and CarpetMG correspondingly.
Diffstat (limited to 'Carpet/Carpet/src/Evolve.cc')
-rw-r--r-- | Carpet/Carpet/src/Evolve.cc | 103 |
1 files changed, 19 insertions, 84 deletions
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc index baadd19bd..3ed5ae848 100644 --- a/Carpet/Carpet/src/Evolve.cc +++ b/Carpet/Carpet/src/Evolve.cc @@ -95,7 +95,9 @@ namespace Carpet { int const do_every = ipow (mgfact, ml) * (maxtimereflevelfact / timereffacts.AT(rl)); if (cctkGH->cctk_iteration % do_every == 0) { - assert (abs (leveltimes.AT(ml).AT(rl) - global_time) <= + // assert (abs (leveltimes.AT(ml).AT(rl) - global_time) <= + // eps * global_time); + assert (abs (tt->get_time(ml,rl,0) - global_time) <= eps * global_time); } } @@ -296,57 +298,19 @@ namespace Carpet { do_global_mode = do_late_global_mode; do_meta_mode = do_late_meta_mode; - Waypoint ("Postregrid at iteration %d time %g%s%s", - cctkGH->cctk_iteration, (double)cctkGH->cctk_time, - (do_global_mode ? " (global)" : ""), - (do_meta_mode ? " (meta)" : "")); - - int const num_tl = prolongation_order_time+1; - - bool const old_do_allow_past_timelevels = - do_allow_past_timelevels; - do_allow_past_timelevels = false; - - // Rewind times - for (int m=0; m<maps; ++m) { - CCTK_REAL const old_delta = - vtt.AT(m)->get_delta (reflevel, mglevel); - vtt.AT(m)->set_delta (reflevel, mglevel, - old_delta); - } - FlipTimeLevels (cctkGH); - for (int tl=0; tl<num_tl; ++tl) { - for (int m=0; m<maps; ++m) { - vtt.AT(m)->advance_time (reflevel, mglevel); - } - CycleTimeLevels (cctkGH); - } - for (int m=0; m<maps; ++m) { - CCTK_REAL const old_delta = - vtt.AT(m)->get_delta (reflevel, mglevel); - vtt.AT(m)->set_delta (reflevel, mglevel, - old_delta); - } - FlipTimeLevels (cctkGH); - CCTK_REAL const old_cctk_time = cctkGH->cctk_time; - cctkGH->cctk_time -= - num_tl * (cctkGH->cctk_delta_time / cctkGH->cctk_timefac); - - for (int tl=0; tl<num_tl; ++tl) { + BEGIN_TIMELEVEL_LOOP (cctkGH) { - // Advance times - for (int m=0; m<maps; ++m) { - vtt.AT(m)->advance_time (reflevel, mglevel); - } - CycleTimeLevels (cctkGH); - cctkGH->cctk_time += - cctkGH->cctk_delta_time / cctkGH->cctk_timefac; + Waypoint ("Postregrid at iteration %d time %g timelevel %d%s%s", + cctkGH->cctk_iteration, + (double)cctkGH->cctk_time, + timelevel, + (do_global_mode ? " (global)" : ""), + (do_meta_mode ? " (meta)" : "")); // Postregrid ScheduleTraverse (where, "CCTK_POSTREGRID", cctkGH); - } // for tl - cctkGH->cctk_time = old_cctk_time; - - do_allow_past_timelevels = old_do_allow_past_timelevels; + } END_TIMELEVEL_LOOP; EndTimingLevel (cctkGH); } LEAVE_LEVEL_MODE; @@ -413,43 +377,14 @@ namespace Carpet { } // Advance times - cctkGH->cctk_time - = (global_time - - delta_time / maxtimereflevelfact - + delta_time * mglevelfact / timereflevelfact); - CCTK_REAL const carpet_time = cctkGH->cctk_time / delta_time; - for (int m=0; m<maps; ++m) { - vtt.AT(m)->advance_time (reflevel, mglevel); - if (not adaptive_stepsize) { -#if 0 - // We must not perform this check, since the - // relative accuracy of incrementally adding to the - // current time cannot be good enough. Just setting - // the time (see below) is fine. - CCTK_REAL const eps = 1.0e-12; - static_assert (abs(0.1) > 0, - "Function CarpetLib::abs has wrong signature"); - CCTK_REAL const level_time = - vtt.AT(m)->get_time (reflevel, mglevel); - if (not (abs (level_time - carpet_time) <= - eps * max (carpet_time, 1.0))) { - int const oldprecision = cerr.precision(); - cerr.precision (17); - cerr << "ml: " << ml << endl - << "rl: " << rl << endl - << "m: " << m << endl - << "level_time: " << level_time << endl - << "carpet_time: " << carpet_time << endl - << "(level_time - carpet_time): " << (level_time - carpet_time) << endl; - cerr.precision (oldprecision); - } - assert (abs (level_time - carpet_time) <= - eps * max (carpet_time, 1.0)); -#endif - vtt.AT(m)->set_time (reflevel, mglevel, carpet_time); - } - } CycleTimeLevels (cctkGH); + if (not adaptive_stepsize) { + cctkGH->cctk_time + = (global_time + - delta_time / maxtimereflevelfact + + delta_time * mglevelfact / timereflevelfact); + tt->set_time (mglevel, reflevel, timelevel, cctkGH->cctk_time); + } Waypoint ("Evolution I at iteration %d time %g%s%s%s", cctkGH->cctk_iteration, (double)cctkGH->cctk_time, @@ -633,7 +568,7 @@ namespace Carpet { streamsize const oldprecision = cout.precision(); cout.precision (17); cout << " global_time: " << global_time << endl - << " leveltimes: " << leveltimes << endl + // << " leveltimes: " << leveltimes << endl << " delta_time: " << delta_time << endl; cout.precision (oldprecision); } |