Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PunctureTracker: schedule Setup into post_recover_variables also #42

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
45 changes: 27 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 Expand Up @@ -110,6 +116,7 @@ extern "C" void PunctureTracker_Track(CCTK_ARGUMENTS) {
g_punctures->getLocation();
const std::array<std::vector<CCTK_REAL>, Loop::dim> &velocity =
g_punctures->getVelocity();
const std::vector<CCTK_REAL> &time = g_punctures->getTime();

if (verbose) {
for (int n = 0; n < nPunctures; ++n) {
Expand Down Expand Up @@ -158,9 +165,11 @@ extern "C" void PunctureTracker_Track(CCTK_ARGUMENTS) {

// Write to pt_loc_foo and pt_vel_foo
for (int i = 0; i < nPunctures; ++i) {
pt_loc_t[i] = time[i];
pt_loc_x[i] = location[0][i];
pt_loc_y[i] = location[1][i];
pt_loc_z[i] = location[2][i];
pt_vel_t[i] = time[i];
pt_vel_x[i] = velocity[0][i];
pt_vel_y[i] = velocity[1][i];
pt_vel_z[i] = velocity[2][i];
Expand Down