Skip to content

Commit 644b7ef

Browse files
committed
Allow flushes before defining position and positionOffset records
This will ensure openPMD specific requirements for those records at flush time as soon as those records are present -- rather than at creation time of the particle species object. Currently missing is any kind of check that those records are present before closing the series.
1 parent 6b31e79 commit 644b7ef

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

include/openPMD/ParticleSpecies.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ namespace traits
5555
template< typename T >
5656
void operator()(T & ret)
5757
{
58-
/* enforce these two RecordComponents as required by the standard */
59-
ret["position"].setUnitDimension({{UnitDimension::L, 1}});
60-
ret["positionOffset"].setUnitDimension({{UnitDimension::L, 1}});
6158
ret.particlePatches.linkHierarchy(ret.m_writable);
6259

6360
auto& np = ret.particlePatches["numParticles"];

src/ParticleSpecies.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ ParticleSpecies::flush(std::string const& path)
122122
for( auto& patch : particlePatches )
123123
patch.second.flush(patch.first);
124124
}
125+
126+
iterator it = find("position");
127+
if ( it != end() )
128+
{
129+
it->second.setUnitDimension({{UnitDimension::L, 1}});
130+
}
131+
it = find("positionOffset");
132+
if ( it != end() )
133+
{
134+
it->second.setUnitDimension({{UnitDimension::L, 1}});
135+
}
125136
}
126137
}
127138
} // openPMD

0 commit comments

Comments
 (0)