Skip to content

Commit

Permalink
PC Names: Same Type, Multiple Vars/Instances
Browse files Browse the repository at this point in the history
If the same particle container type is used to create
multiple particle species, then the compile-time defined
names were only added for the first particle species (instance)
of the type and then skipped for any later species (another
instance of the same type).

This is due to the global variable (so many globals...) used in
the type init. This fixes the problem by moving the instance
related name logic out of the once-per-type logic `if` branch.
  • Loading branch information
ax3l committed Jan 18, 2025
1 parent 1803a94 commit 50e5b42
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig

SetParticleSize();

// add default names for SoA Real and Int compile-time arguments
m_soa_rdata_names.clear();
for (int i=0; i<NArrayReal; ++i)
{
m_soa_rdata_names.push_back(getDefaultCompNameReal<ParticleType>(i));
}
m_soa_idata_names.clear();
for (int i=0; i<NArrayInt; ++i)
{
m_soa_idata_names.push_back(getDefaultCompNameInt<ParticleType>(i));
}

static bool initialized = false;
if ( ! initialized)
{
Expand All @@ -65,16 +77,6 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
pp.queryAdd("do_mem_efficient_sort", memEfficientSort);
pp.queryAdd("use_comms_arena", use_comms_arena);

// add default names for SoA Real and Int compile-time arguments
for (int i=0; i<NArrayReal; ++i)
{
m_soa_rdata_names.push_back(getDefaultCompNameReal<ParticleType>(i));
}
for (int i=0; i<NArrayInt; ++i)
{
m_soa_idata_names.push_back(getDefaultCompNameInt<ParticleType>(i));
}

initialized = true;
}
}
Expand Down

0 comments on commit 50e5b42

Please sign in to comment.