Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddRealComp/AddIntComp: Resize SoA #3615

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,18 @@ public:
m_num_runtime_real++;
h_redistribute_real_comp.push_back(communicate);
SetParticleSize();

// resize runtime SoA
for (int lev = 0; lev < numLevels(); ++lev) {
for (ParIterType pti(*this,lev); pti.isValid(); ++pti) {
auto& tile = DefineAndReturnParticleTile(lev, pti);
auto np = tile.numParticles();
if (np > 0) {
auto& soa = tile.GetStructOfArrays();
soa.resize(np);
}
}
}
}

template <typename T,
Expand All @@ -1259,6 +1271,18 @@ public:
m_num_runtime_int++;
h_redistribute_int_comp.push_back(communicate);
SetParticleSize();

// resize runtime SoA
for (int lev = 0; lev < numLevels(); ++lev) {
for (ParIterType pti(*this,lev); pti.isValid(); ++pti) {
auto& tile = DefineAndReturnParticleTile(lev, pti);
auto np = tile.numParticles();
if (np > 0) {
auto& soa = tile.GetStructOfArrays();
soa.resize(np);
}
}
}
}

int NumRuntimeRealComps () const { return m_num_runtime_real; }
Expand All @@ -1267,7 +1291,18 @@ public:
int NumRealComps () const { return NArrayReal + NumRuntimeRealComps(); }
int NumIntComps () const { return NArrayInt + NumRuntimeIntComps() ; }

/** Resize the Real runtime components (SoA)
*
* @param new_size new number of Real runtime components
* @param communicate participate this component in redistribute
*/
void ResizeRuntimeRealComp (int new_size, bool communicate);

/** Resize the Int runtime components (SoA)
*
* @param new_size new number of integer runtime components
* @param communicate participate this component in redistribute
*/
void ResizeRuntimeIntComp (int new_size, bool communicate);

/** type trait to translate one particle container to another, with changed allocator */
Expand Down