From 723317dad1becf1faba4e168374ffd7dd7bff871 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 6 Jul 2007 12:25:00 +0000 Subject: Carpet: Use thorn InitBase to manage initial data setup Thorn InitBase specifies how initial data should be calculated. There can be three possibilities: init_some_levels: Set up at least one time level; other time levels are scratch space init_single_level: Set up exactly one time level; other time levels are not acessed init_all_levels: Set up all active time levels Carpet checks this parameter and ensures that this setting is consistent with Carpet's parameters init_each_timelevel init_fill_timelevels init_3_timelevels The new parameter init_fill_timelevels copies the current time level into all past time levels, very similar to what MoL::initial_data_is_crap does. darcs-hash:20070706122545-dae7b-57ccca2954b1bd7ad98771e689c6c5b569c238cc.gz --- Carpet/Carpet/param.ccl | 9 ++++ Carpet/Carpet/schedule.ccl | 5 +++ Carpet/Carpet/src/CarpetParamCheck.cc | 79 +++++++++++++++++++++++++++++++++++ Carpet/Carpet/src/Comm.cc | 5 ++- Carpet/Carpet/src/Cycle.cc | 40 ++++++++++++++++++ Carpet/Carpet/src/Initialise.cc | 8 +++- Carpet/Carpet/src/carpet.hh | 1 + 7 files changed, 144 insertions(+), 3 deletions(-) diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl index c773686c4..a16b9bfe8 100644 --- a/Carpet/Carpet/param.ccl +++ b/Carpet/Carpet/param.ccl @@ -10,6 +10,11 @@ USES CCTK_REAL cctk_final_time USES CCTK_REAL max_runtime +shares: InitBase + +USES KEYWORD initial_data_setup_method + + shares: IO USES STRING out_dir @@ -438,6 +443,10 @@ BOOLEAN init_each_timelevel "Call initial data routines once for each timelevel" { } "no" +BOOLEAN init_fill_timelevels "Fill past time levels from current time level after calling initial data routines" STEERABLE=always +{ +} "no" + BOOLEAN prolongate_initial_data "Prolongate the refined regions during initial data generation" STEERABLE=always { } "no" diff --git a/Carpet/Carpet/schedule.ccl b/Carpet/Carpet/schedule.ccl index 5d8b6e1d3..b202a4a82 100644 --- a/Carpet/Carpet/schedule.ccl +++ b/Carpet/Carpet/schedule.ccl @@ -11,3 +11,8 @@ schedule CarpetStartup at STARTUP as Driver_Startup { LANG: C } "Startup routine" + +schedule CarpetParamCheck at PARAMCHECK +{ + LANG: C +} "Parameter checking routine" diff --git a/Carpet/Carpet/src/CarpetParamCheck.cc b/Carpet/Carpet/src/CarpetParamCheck.cc index 085f91e1f..ab71c74b2 100644 --- a/Carpet/Carpet/src/CarpetParamCheck.cc +++ b/Carpet/Carpet/src/CarpetParamCheck.cc @@ -33,6 +33,85 @@ namespace Carpet { if (adaptive_stepsize and max_refinement_levels > 1) { CCTK_PARAMWARN ("Adaptive time step sizes do not work with mesh refinement yet. Please use only a single level, and set max_refinement_levels=1."); } + + + + // InitBase + + enum setup_method_t { + init_some_levels, + init_single_level, + init_all_levels, + }; + setup_method_t setup_method; + + if (CCTK_EQUALS (initial_data_setup_method, "init_some_levels")) { + setup_method = init_some_levels; + } + else if (CCTK_EQUALS (initial_data_setup_method, "init_single_level")) { + setup_method = init_single_level; + } + else if (CCTK_EQUALS (initial_data_setup_method, "init_all_levels")) { + setup_method = init_some_levels; + } + else + { + CCTK_PARAMWARN ("Unknown value of parameter InitBase::initial_data_setup_method"); + } + + // Carpet + + enum init_method_t { + each_timelevel, // Initialise each time level + fill_timelevels, // Copy the current to all past timelevels + three_timelevels, // Carpet's 3 timelevel scheme + all_timelevels, // Initial data thorn initialises all timelevels + }; + init_method_t init_method; + + if (init_each_timelevel) { + if (init_fill_timelevels) { + CCTK_PARAMWARN ("Cannot set parameters init_each_timelevel and init_fill_timelevels at the same time"); + } + if (init_3_timelevels) { + CCTK_PARAMWARN ("Cannot set parameters init_each_timelevel and init_3_timelevels at the same time"); + } + init_method = each_timelevel; + } + else if (init_fill_timelevels) { + if (init_3_timelevels) { + CCTK_PARAMWARN ("Cannot set parameters init_fill_timelevels and init_3_timelevels at the same time"); + } + init_method = fill_timelevels; + } + else if (init_3_timelevels) { + init_method = three_timelevels; + } + else { + init_method = all_timelevels; + } + + switch (init_method) { + case each_timelevel: + if (setup_method != init_single_level) { + CCTK_PARAMWARN ("When you set Carpet::init_each_timelevel=yes, then you must also use InitBase::initial_data_setup_method=\"single_level\""); + } + break; + case fill_timelevels: + // Everything is allowed + break; + case three_timelevels: + // Everything is allowed + break; + case all_timelevels: + if (setup_method != init_all_levels) { + CCTK_PARAMWARN ("When you set neither Carpet::init_each_timelevel=yes nor Carpet::init_fill_timelevels=yes nor Carpet::init_3_timelevel=yes, then you must also use InitBase::initial_data_setup_method=\"all_levels\""); + } + break; + default: + assert (0); + } + } } // namespace Carpet diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc index 80cea30c5..b09869ef9 100644 --- a/Carpet/Carpet/src/Comm.cc +++ b/Carpet/Carpet/src/Comm.cc @@ -166,7 +166,8 @@ namespace Carpet { if (sync_during_time_integration or local_do_prolongate) { SyncGroups (cctkGH, goodgroups); } - } + + } // for g return retval; } @@ -178,7 +179,7 @@ namespace Carpet { { DECLARE_CCTK_PARAMETERS; const int tl = 0; - + // use the current time here (which may be modified by the user) const CCTK_REAL time = (cctkGH->cctk_time - initial_time) / delta_time; diff --git a/Carpet/Carpet/src/Cycle.cc b/Carpet/Carpet/src/Cycle.cc index 45425905d..3901b7753 100644 --- a/Carpet/Carpet/src/Cycle.cc +++ b/Carpet/Carpet/src/Cycle.cc @@ -113,4 +113,44 @@ namespace Carpet { } // for group } + + + void FillTimeLevels (const cGH* cgh) + { + Checkpoint ("CopyTimeLevels"); + assert (is_level_mode()); + + for (int group=0; group=0 and reflevelcomponents(reflevel); ++c) { + arrdata.at(group).at(m).data.at(var)->fill (reflevel, c, mglevel); + } + } + } + break; + + case CCTK_SCALAR: + case CCTK_ARRAY: + if (do_global_mode) { + for (int var=0; varcomponents(0); ++c) { + arrdata.at(group).at(0).data.at(var)->fill (0, c, mglevel); + } + } + } + break; + + default: + assert (0); + } // switch grouptype + } // if storage + } // for group + } + } // namespace Carpet diff --git a/Carpet/Carpet/src/Initialise.cc b/Carpet/Carpet/src/Initialise.cc index 4fabe1446..5c3512603 100644 --- a/Carpet/Carpet/src/Initialise.cc +++ b/Carpet/Carpet/src/Initialise.cc @@ -294,7 +294,9 @@ namespace Carpet { int const num_tl = init_each_timelevel ? prolongation_order_time+1 : 1; bool const old_do_allow_past_timelevels = do_allow_past_timelevels; - do_allow_past_timelevels = not init_each_timelevel; + // do_allow_past_timelevels = not init_each_timelevel; + do_allow_past_timelevels = + not CCTK_EQUALS (initial_data_setup_method, "single_level"); for (int m=0; mset_delta @@ -323,6 +325,10 @@ namespace Carpet { // Set up the initial data ScheduleTraverse (where, "CCTK_INITIAL", cctkGH); + if (init_fill_timelevels) { + FillTimeLevels (cctkGH); + } + // Checking PoisonCheck (cctkGH, currenttime); diff --git a/Carpet/Carpet/src/carpet.hh b/Carpet/Carpet/src/carpet.hh index bd16cd525..f61f60264 100644 --- a/Carpet/Carpet/src/carpet.hh +++ b/Carpet/Carpet/src/carpet.hh @@ -37,6 +37,7 @@ namespace Carpet { void CycleTimeLevels (const cGH* cgh); void FlipTimeLevels (const cGH* cgh); + void FillTimeLevels (const cGH* cgh); void SyncGroups (const cGH* cgh, const vector& groups); int SyncProlongateGroups (const cGH* cgh, const vector& groups); -- cgit v1.2.3