diff --git a/PunctureTracker/schedule.ccl b/PunctureTracker/schedule.ccl index 487ba7e8..4d4cb402 100644 --- a/PunctureTracker/schedule.ccl +++ b/PunctureTracker/schedule.ccl @@ -1,12 +1,29 @@ # Schedule definitions for thorn PunctureTracker -SCHEDULE PunctureTracker_Setup AT wragh +SCHEDULE PunctureTracker_Init AT initial { LANG: C OPTIONS: GLOBAL - WRITES: pt_loc - WRITES: pt_vel - WRITES: BoxInBox::positions + WRITES: pt_loc + WRITES: pt_vel +} "Read initial location of punctures from parameter file" + +SCHEDULE GROUP PunctureTracker_SetupGroup AT initial AFTER PunctureTracker_Init +{ +} "Setup puncture containter" + +# if recovery_mode is 'strict' +SCHEDULE GROUP PunctureTracker_SetupGroup AT post_recover_variables +{ +} "Setup puncture containter" + +SCHEDULE PunctureTracker_Setup IN PunctureTracker_SetupGroup +{ + LANG: C + OPTIONS: GLOBAL + READS: pt_loc + READS: pt_vel + WRITES: BoxInBox::positions } "Calculate initial location of punctures" SCHEDULE PunctureTracker_Track AT evol AFTER ODESolvers_Solve @@ -14,9 +31,9 @@ SCHEDULE PunctureTracker_Track AT evol AFTER ODESolvers_Solve LANG: C OPTIONS: GLOBAL READS: ADMBaseX::shift(everywhere) - WRITES: pt_loc - WRITES: pt_vel - WRITES: BoxInBox::positions + WRITES: pt_loc + WRITES: pt_vel + WRITES: BoxInBox::positions } "Calculate new location of punctures" SCHEDULE PunctureTracker_Finalize AT terminate BEFORE driver_terminate diff --git a/PunctureTracker/src/puncture_tracker.cxx b/PunctureTracker/src/puncture_tracker.cxx index accc9ff2..5a4f5c26 100644 --- a/PunctureTracker/src/puncture_tracker.cxx +++ b/PunctureTracker/src/puncture_tracker.cxx @@ -7,10 +7,10 @@ #include +#include #include #include #include -#include #include namespace PunctureTracker { @@ -19,8 +19,8 @@ static PunctureContainer *g_punctures = nullptr; const int max_num_tracked = 10; -extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) { - DECLARE_CCTK_ARGUMENTS_PunctureTracker_Setup; +extern "C" void PunctureTracker_Init(CCTK_ARGUMENTS) { + DECLARE_CCTK_ARGUMENTS_PunctureTracker_Init; DECLARE_CCTK_PARAMETERS; if (verbose) { @@ -48,23 +48,29 @@ extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) { pt_vel_z[n] = 0.0; } } +} + +extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) { + DECLARE_CCTK_ARGUMENTS_PunctureTracker_Setup; + DECLARE_CCTK_PARAMETERS; // Initialize PunctureContainer if (g_punctures == nullptr) { g_punctures = new PunctureContainer(); - } - for (int n = 0; n < max_num_tracked; ++n) { - if (track[n]) { - g_punctures->getTime().push_back(cctk_time); - g_punctures->getLocation()[0].push_back(initial_x[n]); - g_punctures->getLocation()[1].push_back(initial_y[n]); - g_punctures->getLocation()[2].push_back(initial_z[n]); - g_punctures->getVelocity()[0].push_back(0.0); - g_punctures->getVelocity()[1].push_back(0.0); - g_punctures->getVelocity()[2].push_back(0.0); + for (int n = 0; n < max_num_tracked; ++n) { + if (track[n]) { + g_punctures->getTime().push_back(pt_loc_t[n]); + g_punctures->getLocation()[0].push_back(pt_loc_x[n]); + g_punctures->getLocation()[1].push_back(pt_loc_y[n]); + g_punctures->getLocation()[2].push_back(pt_loc_z[n]); + g_punctures->getVelocity()[0].push_back(pt_vel_x[n]); + g_punctures->getVelocity()[1].push_back(pt_vel_y[n]); + g_punctures->getVelocity()[2].push_back(pt_vel_z[n]); + } } } + const int nPunctures = g_punctures->getTime().size(); g_punctures->getPreviousTime().resize(nPunctures); g_punctures->getBeta()[0].resize(nPunctures); @@ -77,11 +83,11 @@ extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) { if (track_boxes) { const std::array, Loop::dim> &location = g_punctures->getLocation(); - for (int i = 0; i < nPunctures; ++i) { - CCTK_VINFO("Writing punc coords to box %d.", i); - position_x[i] = location[0][i]; - position_y[i] = location[1][i]; - position_z[i] = location[2][i]; + for (int n = 0; n < nPunctures; ++n) { + CCTK_VINFO("Writing punc coords to box %d.", n); + position_x[n] = location[0][n]; + position_y[n] = location[1][n]; + position_z[n] = location[2][n]; } } }