Skip to content

Commit

Permalink
PunctureTracker: schedule Setup into post_recover_variables also
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Aug 9, 2024
1 parent f8dc76d commit a3f055a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
31 changes: 24 additions & 7 deletions PunctureTracker/schedule.ccl
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
# 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
{
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
Expand Down
42 changes: 24 additions & 18 deletions PunctureTracker/src/puncture_tracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

#include <mpi.h>

#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <array>
#include <ctype.h>

namespace PunctureTracker {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -77,11 +83,11 @@ extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) {
if (track_boxes) {
const std::array<std::vector<CCTK_REAL>, 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];
}
}
}
Expand Down

0 comments on commit a3f055a

Please sign in to comment.