Skip to content

Commit

Permalink
Fix optional component communication for pure SoA particles
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Feb 13, 2025
1 parent 240e2a8 commit 63c3ec5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
20 changes: 5 additions & 15 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ public:
//! of a level hierarchy. Must be properly initialized later.
ParticleContainer_impl ()
:
ParticleContainerBase(),
h_redistribute_real_comp(AMREX_SPACEDIM + NStructReal + NArrayReal, true),
h_redistribute_int_comp(2 + NStructInt + NArrayInt, true)
ParticleContainerBase()
{
Initialize ();
}
Expand All @@ -215,9 +213,7 @@ public:
//!
ParticleContainer_impl (ParGDBBase* gdb)
:
ParticleContainerBase(gdb),
h_redistribute_real_comp(AMREX_SPACEDIM + NStructReal + NArrayReal, true),
h_redistribute_int_comp(2 + NStructInt + NArrayInt, true)
ParticleContainerBase(gdb)
{
Initialize ();
ParticleContainer_impl::reserveData();
Expand All @@ -235,9 +231,7 @@ public:
const DistributionMapping & dmap,
const BoxArray & ba)
:
ParticleContainerBase(geom, dmap, ba),
h_redistribute_real_comp(AMREX_SPACEDIM + NStructReal + NArrayReal, true),
h_redistribute_int_comp(2 + NStructInt + NArrayInt, true)
ParticleContainerBase(geom, dmap, ba)
{
Initialize ();
ParticleContainer_impl::reserveData();
Expand All @@ -258,9 +252,7 @@ public:
const Vector<BoxArray> & ba,
const Vector<int> & rr)
:
ParticleContainerBase(geom, dmap, ba, rr),
h_redistribute_real_comp(AMREX_SPACEDIM + NStructReal + NArrayReal, true),
h_redistribute_int_comp(2 + NStructInt + NArrayInt, true)
ParticleContainerBase(geom, dmap, ba, rr)
{
Initialize ();
ParticleContainer_impl::reserveData();
Expand All @@ -280,9 +272,7 @@ public:
const Vector<BoxArray> & ba,
const Vector<IntVect> & rr)
:
ParticleContainerBase(geom, dmap, ba, rr),
h_redistribute_real_comp(AMREX_SPACEDIM + NStructReal + NArrayReal, true),
h_redistribute_int_comp(2 + NStructInt + NArrayInt, true)
ParticleContainerBase(geom, dmap, ba, rr)
{
Initialize ();
ParticleContainer_impl::reserveData();
Expand Down
14 changes: 13 additions & 1 deletion Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ void
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::SetParticleSize ()
{
num_real_comm_comps = 0;
int comm_comps_start = AMREX_SPACEDIM + NStructReal;
int comm_comps_start = 0;
if constexpr (!ParticleType::is_soa_particle) {
comm_comps_start += AMREX_SPACEDIM + NStructReal;
}
for (int i = comm_comps_start; i < comm_comps_start + NumRealComps(); ++i) {
if (h_redistribute_real_comp[i]) {++num_real_comm_comps;}
}
Expand Down Expand Up @@ -45,6 +48,15 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
usePrePost = false;
doUnlink = true;

// by default communicate all components
if constexpr (ParticleType::is_soa_particle)
{
h_redistribute_real_comp.resize(NArrayReal, true);
} else {
h_redistribute_real_comp.resize(AMREX_SPACEDIM + NStructReal + NArrayReal, true);
}
h_redistribute_int_comp.resize(2 + NStructInt + NArrayInt, true);

SetParticleSize();

// add default names for SoA Real and Int compile-time arguments
Expand Down

0 comments on commit 63c3ec5

Please sign in to comment.