Skip to content

Commit 20eb1ab

Browse files
authored
PC Names: Same Type, Multiple Vars/Instances (#4302)
## Summary 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. ## Additional background First seen with ImpactX for its "lost" particle species (2nd instance of the same PC type in the code). Needed for BLAST-ImpactX/impactx#805 ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 92d35c2 commit 20eb1ab

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Src/Particle/AMReX_ParticleContainerI.H

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
4242

4343
SetParticleSize();
4444

45+
// add default names for SoA Real and Int compile-time arguments
46+
m_soa_rdata_names.clear();
47+
for (int i=0; i<NArrayReal; ++i)
48+
{
49+
m_soa_rdata_names.push_back(getDefaultCompNameReal<ParticleType>(i));
50+
}
51+
m_soa_idata_names.clear();
52+
for (int i=0; i<NArrayInt; ++i)
53+
{
54+
m_soa_idata_names.push_back(getDefaultCompNameInt<ParticleType>(i));
55+
}
56+
4557
static bool initialized = false;
4658
if ( ! initialized)
4759
{
@@ -65,16 +77,6 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
6577
pp.queryAdd("do_mem_efficient_sort", memEfficientSort);
6678
pp.queryAdd("use_comms_arena", use_comms_arena);
6779

68-
// add default names for SoA Real and Int compile-time arguments
69-
for (int i=0; i<NArrayReal; ++i)
70-
{
71-
m_soa_rdata_names.push_back(getDefaultCompNameReal<ParticleType>(i));
72-
}
73-
for (int i=0; i<NArrayInt; ++i)
74-
{
75-
m_soa_idata_names.push_back(getDefaultCompNameInt<ParticleType>(i));
76-
}
77-
7880
initialized = true;
7981
}
8082
}

0 commit comments

Comments
 (0)