Skip to content

Commit

Permalink
backward compatibility for buffergathereachdir
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Aug 12, 2024
1 parent 0418eb1 commit eea5eb8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/Parallelization/WarpXRegrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ WarpX::RemakeLevel (int lev, Real /*time*/, const BoxArray& ba, const Distributi
#endif
}

if (lev > 0 && (n_field_gather_buffer > 0 || n_current_deposition_buffer > 0)) {
if (lev > 0 && (n_field_gather_buffer_each_dir.max() > 0 || n_current_deposition_buffer_each_dir.max() > 0)) {
for (int idim=0; idim < 3; ++idim)
{
RemakeMultiFab(Bfield_cax[lev][idim], false);
Expand Down
8 changes: 4 additions & 4 deletions Source/Particles/Sorting/Partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PhysicalParticleContainer::PartitionParticlesInBuffers(

// - Select the larger buffer
iMultiFab const* bmasks =
(WarpX::n_field_gather_buffer >= WarpX::n_current_deposition_buffer) ?
(WarpX::n_field_gather_buffer_each_dir.max() >= WarpX::n_current_deposition_buffer_each_dir.max()) ?
gather_masks : current_masks;
// - For each particle, find whether it is in the larger buffer,
// by looking up the mask. Store the answer in `inexflag`.
Expand All @@ -86,7 +86,7 @@ PhysicalParticleContainer::PartitionParticlesInBuffers(
// Second, among particles that are in the larger buffer, partition
// particles into the smaller buffer

if (WarpX::n_current_deposition_buffer == WarpX::n_field_gather_buffer) {
if (WarpX::n_current_deposition_buffer_each_dir.max() == WarpX::n_field_gather_buffer_each_dir.max()) {
// No need to do anything if the buffers have the same size
nfine_current = nfine_gather = iteratorDistance(pid.begin(), sep);
} else if (sep == pid.end()) {
Expand All @@ -97,11 +97,11 @@ PhysicalParticleContainer::PartitionParticlesInBuffers(
if (bmasks == gather_masks) {
nfine_gather = n_fine;
bmasks = current_masks;
n_buf = WarpX::n_current_deposition_buffer;
n_buf = WarpX::n_current_deposition_buffer_each_dir.max();
} else {
nfine_current = n_fine;
bmasks = gather_masks;
n_buf = WarpX::n_field_gather_buffer;
n_buf = WarpX::n_field_gather_buffer_each_dir.max();
}
if (n_buf > 0)
{
Expand Down
11 changes: 10 additions & 1 deletion Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,16 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
// Field gather buffer should be larger than current deposition buffers
n_field_gather_buffer = n_current_deposition_buffer + 1;
}

for (int i = 0; i < AMREX_SPACEDIM; ++i) {
if (n_current_deposition_buffer_each_dir[i] < 0) {
n_current_deposition_buffer_each_dir[i] = guard_cells.ng_alloc_J.max();
}
}
for (int i = 0; i < AMREX_SPACEDIM; ++i) {
if (n_field_gather_buffer_each_dir[i] < 0) {
n_field_gather_buffer_each_dir[i] = n_current_deposition_buffer + 1;
}
}
AllocLevelMFs(lev, ba, dm, guard_cells.ng_alloc_EB, guard_cells.ng_alloc_J,
guard_cells.ng_alloc_Rho, guard_cells.ng_alloc_F, guard_cells.ng_alloc_G, aux_is_nodal);

Expand Down

0 comments on commit eea5eb8

Please sign in to comment.