Skip to content

Commit b415648

Browse files
authored
Fix moving-window subvolume field output (#5985)
At initialization of moving-window simulations, the diagnostic subvolume is displaced along the direction of the moving window. This is done to account for restarted simulations. However, the displacement is calculated based on the trailing edge of the diagnostic subvolume rather than the simulation volume. This causes a displacement error when the trailing edges of the simulation volume and the diagnostic subvolume do not coincide. This PR corrects the displacement calculation.
1 parent cb36a3d commit b415648

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Source/Diagnostics/Diagnostics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,10 @@ Diagnostics::InitBaseData ()
524524
// current moving_window location
525525
if (WarpX::do_moving_window) {
526526
const int moving_dir = WarpX::moving_window_dir;
527-
const int shift_num_base = static_cast<int>((warpx.getmoving_window_x() - m_lo[moving_dir]) / warpx.Geom(0).CellSize(moving_dir) );
527+
const amrex::Real displacement =
528+
warpx.getmoving_window_x() - warpx.Geom(0).ProbLo(moving_dir);
529+
const int shift_num_base = static_cast<int>
530+
(displacement / warpx.Geom(0).CellSize(moving_dir));
528531
m_lo[moving_dir] += shift_num_base * warpx.Geom(0).CellSize(moving_dir);
529532
m_hi[moving_dir] += shift_num_base * warpx.Geom(0).CellSize(moving_dir);
530533
}

0 commit comments

Comments
 (0)