Skip to content

Commit

Permalink
Particle Patches: Do not emplace patch records if they don't exist in…
Browse files Browse the repository at this point in the history
… the file being read (openPMD#945)

* Removed from PR during backport:
  Test openpmd-pipe on git-sample/data%T.h5

* Only emplace particle patches in container if they exist
  • Loading branch information
franzpoeschel authored and ax3l committed Apr 9, 2021
1 parent a545921 commit 7cf12c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ ParticleSpecies::read()

Parameter< Operation::OPEN_PATH > pOpen;
Parameter< Operation::LIST_ATTS > aList;
bool hasParticlePatches = false;
for( auto const& record_name : *pList.paths )
{
if( record_name == "particlePatches" )
{
hasParticlePatches = true;
pOpen.path = "particlePatches";
IOHandler->enqueue(IOTask(&particlePatches, pOpen));
particlePatches.read();
Expand Down Expand Up @@ -69,6 +71,13 @@ ParticleSpecies::read()
}
}

if( !hasParticlePatches )
{
auto & container = *particlePatches.m_container;
container.erase( "numParticles" );
container.erase( "numParticlesOffset" );
}

/* obtain all scalar records */
Parameter< Operation::LIST_DATASETS > dList;
IOHandler->enqueue(IOTask(this, dList));
Expand Down

0 comments on commit 7cf12c0

Please sign in to comment.