Skip to content

Commit

Permalink
Define class function defineAllParticleTiles for `NamedComponentPar…
Browse files Browse the repository at this point in the history
…ticleContainer` (ECP-WarpX#4780)

* Define function to define tiles, for a NamedComponentParticleContainer

* Call parent class in WarpXParticleContainer
  • Loading branch information
RemiLehe authored Mar 16, 2024
1 parent a8f48ea commit 4e568ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Source/Particles/NamedComponentParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ public:
}
}

void defineAllParticleTiles () noexcept
{
for (int lev = 0; lev <= amrex::ParticleContainerPureSoA<PIdx::nattribs,0,T_Allocator>::finestLevel(); ++lev)
{
for (auto mfi = amrex::ParticleContainerPureSoA<PIdx::nattribs,0,T_Allocator>::MakeMFIter(lev); mfi.isValid(); ++mfi)
{
const int grid_id = mfi.index();
const int tile_id = mfi.LocalTileIndex();
amrex::ParticleContainerPureSoA<PIdx::nattribs,0,T_Allocator>::DefineAndReturnParticleTile(lev, grid_id, tile_id);
}
}
}

/** Return the name-to-index map for the compile-time and runtime-time real components */
[[nodiscard]] std::map<std::string, int> getParticleComps () const noexcept { return particle_comps;}
/** Return the name-to-index map for the compile-time and runtime-time integer components */
Expand Down
5 changes: 4 additions & 1 deletion Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,10 @@ WarpXParticleContainer::PushX (int lev, amrex::Real dt)
// without runtime component).
void WarpXParticleContainer::defineAllParticleTiles () noexcept
{
// Call the parent class's method
NamedComponentParticleContainer<amrex::DefaultAllocator>::defineAllParticleTiles();

// Resize the tmp_particle_data (no present in parent class)
tmp_particle_data.resize(finestLevel()+1);
for (int lev = 0; lev <= finestLevel(); ++lev)
{
Expand All @@ -1525,7 +1529,6 @@ void WarpXParticleContainer::defineAllParticleTiles () noexcept
const int grid_id = mfi.index();
const int tile_id = mfi.LocalTileIndex();
tmp_particle_data[lev][std::make_pair(grid_id,tile_id)];
DefineAndReturnParticleTile(lev, grid_id, tile_id);
}
}
}
Expand Down

0 comments on commit 4e568ad

Please sign in to comment.