Skip to content

Commit da493ba

Browse files
committed
PunctureTracker: write to inactive elements instead of modify schedule
1 parent 5150d54 commit da493ba

File tree

2 files changed

+41
-22
lines changed

2 files changed

+41
-22
lines changed

PunctureTracker/schedule.ccl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ SCHEDULE PunctureTracker_Setup IN PunctureTracker_SetupGroup
2323
OPTIONS: GLOBAL
2424
READS: pt_loc
2525
READS: pt_vel
26-
READS: BoxInBox::positions
2726
WRITES: BoxInBox::positions
2827
} "Calculate initial location of punctures"
2928

@@ -32,9 +31,6 @@ SCHEDULE PunctureTracker_Track AT evol AFTER ODESolvers_Solve
3231
LANG: C
3332
OPTIONS: GLOBAL
3433
READS: ADMBaseX::shift(everywhere)
35-
READS: pt_loc
36-
READS: pt_vel
37-
READS: BoxInBox::positions
3834
WRITES: pt_loc
3935
WRITES: pt_vel
4036
WRITES: BoxInBox::positions

PunctureTracker/src/puncture_tracker.cxx

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,17 @@ extern "C" void PunctureTracker_Setup(CCTK_ARGUMENTS) {
8383
if (track_boxes) {
8484
const std::array<std::vector<CCTK_REAL>, Loop::dim> &location =
8585
g_punctures->getLocation();
86-
for (int n = 0; n < nPunctures; ++n) {
87-
CCTK_VINFO("Writing punc coords to box %d.", n);
88-
position_x[n] = location[0][n];
89-
position_y[n] = location[1][n];
90-
position_z[n] = location[2][n];
86+
for (int n = 0; n < 3; ++n) { // since BoxInBox hard codes position[3]
87+
if (n < nPunctures) {
88+
CCTK_VINFO("Writing punc coords to box %d.", n);
89+
position_x[n] = location[0][n];
90+
position_y[n] = location[1][n];
91+
position_z[n] = location[2][n];
92+
} else {
93+
position_x[n] = 0.0;
94+
position_y[n] = 0.0;
95+
position_z[n] = 0.0;
96+
}
9197
}
9298
}
9399
}
@@ -164,22 +170,39 @@ extern "C" void PunctureTracker_Track(CCTK_ARGUMENTS) {
164170
g_punctures->broadcast(CCTK_PASS_CTOC);
165171

166172
// Write to pt_loc_foo and pt_vel_foo
167-
for (int i = 0; i < nPunctures; ++i) {
168-
pt_loc_t[i] = time[i];
169-
pt_loc_x[i] = location[0][i];
170-
pt_loc_y[i] = location[1][i];
171-
pt_loc_z[i] = location[2][i];
172-
pt_vel_t[i] = time[i];
173-
pt_vel_x[i] = velocity[0][i];
174-
pt_vel_y[i] = velocity[1][i];
175-
pt_vel_z[i] = velocity[2][i];
173+
for (int i = 0; i < max_num_tracked; ++i) {
174+
if (i < nPunctures) {
175+
pt_loc_t[i] = time[i];
176+
pt_loc_x[i] = location[0][i];
177+
pt_loc_y[i] = location[1][i];
178+
pt_loc_z[i] = location[2][i];
179+
pt_vel_t[i] = time[i];
180+
pt_vel_x[i] = velocity[0][i];
181+
pt_vel_y[i] = velocity[1][i];
182+
pt_vel_z[i] = velocity[2][i];
183+
} else {
184+
pt_loc_t[i] = 0.0;
185+
pt_loc_x[i] = 0.0;
186+
pt_loc_y[i] = 0.0;
187+
pt_loc_z[i] = 0.0;
188+
pt_vel_t[i] = 0.0;
189+
pt_vel_x[i] = 0.0;
190+
pt_vel_y[i] = 0.0;
191+
pt_vel_z[i] = 0.0;
192+
}
176193
}
177194

178195
if (track_boxes) {
179-
for (int i = 0; i < nPunctures; ++i) {
180-
position_x[i] = location[0][i];
181-
position_y[i] = location[1][i];
182-
position_z[i] = location[2][i];
196+
for (int i = 0; i < 3; ++i) { // since BoxInBox hard codes position[3]
197+
if (i < nPunctures) {
198+
position_x[i] = location[0][i];
199+
position_y[i] = location[1][i];
200+
position_z[i] = location[2][i];
201+
} else {
202+
position_x[i] = 0.0;
203+
position_y[i] = 0.0;
204+
position_z[i] = 0.0;
205+
}
183206
}
184207
}
185208
}

0 commit comments

Comments
 (0)