Skip to content

Commit

Permalink
added code for storing particle ids in a seperate function
Browse files Browse the repository at this point in the history
  • Loading branch information
guj committed Nov 3, 2023
1 parent a1cae93 commit 941cfc5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ namespace amrex
openPMD::ParticleSpecies& currSpecies,
unsigned long long offset) const;

template<class PIt>
void
SaveSpecieId(PIt& pti,
openPMD::ParticleSpecies& currSpecies,
unsigned long long offset) const;

template<class PIt>
void
StoreAoS_Int(PIt& pti,
Expand Down
18 changes: 18 additions & 0 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD_PTLImpl.H
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,25 @@ namespace amrex
std::string const positionComponent = positionComponents[currDim];
currSpecies["position"][positionComponent].storeChunk(curr, {offset + GetGrandOffset()}, {numParticleOnTile64});
}
}
SaveSpecieId(pti, currSpecies, offset);
}

template<class PIt>
void
AMReX_openPMDWriter::SaveSpecieId(PIt& pti,
openPMD::ParticleSpecies& currSpecies,
unsigned long long offset) const
{
BL_PROFILE("amrex::openpmd_api::SaveSpecieId");
auto const numParticleOnTile = pti.numParticles();
uint64_t const numParticleOnTile64 = static_cast<uint64_t>( numParticleOnTile );

// get position and particle ID from aos
// note: this implementation iterates the AoS 4x...
// if we flush late as we do now, we can also copy out the data in one go
const auto& aos = pti.GetArrayOfStructs(); // size = numParticlesOnTile
{
// save particle ID after converting it to a globally unique ID
std::shared_ptr< uint64_t > ids(new uint64_t[numParticleOnTile],
[](uint64_t const *p){ delete[] p; }
Expand Down

0 comments on commit 941cfc5

Please sign in to comment.