From db8acd75b9304ed558ce78a8ef6263ecec7ca24e Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 8 Aug 2013 13:10:20 -0400 Subject: LoopControl: Make explore_eagerly_before_iteration and settle_after_iteration work Check cctk_iteration in a scheduled function since cctkGH is otherwise not available. --- Carpet/LoopControl/schedule.ccl | 6 ++++++ Carpet/LoopControl/src/loopcontrol.cc | 40 ++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Carpet/LoopControl/schedule.ccl b/Carpet/LoopControl/schedule.ccl index e73f72c7b..760991e75 100644 --- a/Carpet/LoopControl/schedule.ccl +++ b/Carpet/LoopControl/schedule.ccl @@ -5,6 +5,12 @@ SCHEDULE lc_setup AT startup BEFORE Driver_Startup LANG: C } "Set up LoopControl" +SCHEDULE lc_steer AT prestep +{ + LANG: C + OPTIONS: meta +} "Update LoopControl algorithm preferences" + SCHEDULE lc_statistics_analysis AT analysis { LANG: C diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc index 6f3ad7fe5..68df03b27 100644 --- a/Carpet/LoopControl/src/loopcontrol.cc +++ b/Carpet/LoopControl/src/loopcontrol.cc @@ -69,8 +69,8 @@ using namespace std; -bool lc_do_explore_eagerly = false; -bool lc_do_settle = false; +static bool lc_do_explore_eagerly = false; +static bool lc_do_settle = false; @@ -676,21 +676,11 @@ void lc_control_init(lc_control_t *restrict const control, } if (choice == choice_use_best) { // Make a random jump every so often -#if 0 - const bool do_settle = - settle_after_iteration >= 0 and - cctkGH->cctk_iteration >= settle_after_iteration; -#endif - if (not lc_do_settle) { -#if 0 - const bool do_explore_eagerly = - cctkGH->cctk_iteration < explore_eagerly_before_iteration; -#endif - if (lc_do_explore_eagerly or - random() / (RAND_MAX + 1.0) < random_jump_probability) - { - choice = choice_random_jump; - } + if (not lc_do_settle and + (lc_do_explore_eagerly or + random() / (RAND_MAX + 1.0) < random_jump_probability)) + { + choice = choice_random_jump; } } @@ -1139,6 +1129,22 @@ int lc_setup(void) +void lc_steer(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + lc_do_settle = + settle_after_iteration >= 0 and + cctkGH->cctk_iteration >= settle_after_iteration; + + lc_do_explore_eagerly = + not lc_do_settle and + cctkGH->cctk_iteration < explore_eagerly_before_iteration; +} + + + void lc_statistics(CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS; -- cgit v1.2.3