Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions include/openPMD/ParticleSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ namespace traits
template< typename T >
void operator()(T & ret)
{
/* enforce these two RecordComponents as required by the standard */
ret["position"].setUnitDimension({{UnitDimension::L, 1}});
ret["positionOffset"].setUnitDimension({{UnitDimension::L, 1}});
ret.particlePatches.linkHierarchy(ret.m_writable);

auto& np = ret.particlePatches["numParticles"];
Expand Down
11 changes: 11 additions & 0 deletions src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ ParticleSpecies::flush(std::string const& path)
for( auto& patch : particlePatches )
patch.second.flush(patch.first);
}

iterator it = find("position");
if ( it != end() )
{
it->second.setUnitDimension({{UnitDimension::L, 1}});
}
it = find("positionOffset");
if ( it != end() )
{
it->second.setUnitDimension({{UnitDimension::L, 1}});
}
}
}
} // openPMD
4 changes: 0 additions & 4 deletions test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ TEST_CASE( "particleSpecies_modification_test", "[core]" )
REQUIRE(1 == particles.size());
REQUIRE(1 == particles.count("species"));
REQUIRE(0 == species.numAttributes());
REQUIRE(2 == species.size()); //position, positionOffset
REQUIRE(1 == species.count("position"));
auto dset = Dataset(Datatype::DOUBLE, {1});
species["position"][RecordComponent::SCALAR].resetDataset(dset);
species["positionOffset"][RecordComponent::SCALAR].resetDataset(dset);
Expand Down Expand Up @@ -451,8 +449,6 @@ TEST_CASE( "structure_test", "[core]" )
REQUIRE(o.iterations[1].particles["P"].particlePatches.IOHandler);
REQUIRE(o.iterations[1].particles["P"].particlePatches.parent == getWritable(&o.iterations[1].particles["P"]));

REQUIRE(1 == o.iterations[1].particles["P"].count("position"));
REQUIRE(1 == o.iterations[1].particles["P"].count("positionOffset"));
auto dset = Dataset(Datatype::DOUBLE, {1});
o.iterations[1].particles["P"]["position"][RecordComponent::SCALAR].resetDataset(dset);
o.iterations[1].particles["P"]["positionOffset"][RecordComponent::SCALAR].resetDataset(dset);
Expand Down
35 changes: 35 additions & 0 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,41 @@ TEST_CASE( "constant_scalar", "[serial]" )
}
}

TEST_CASE( "flush_without_position_positionOffset", "[serial]" )
{
for( auto const & t : backends )
{
const std::string & file_ending = std::get< 0 >( t );
Series s = Series(
"../samples/flush_without_position_positionOffset." + file_ending,
AccessType::CREATE );
ParticleSpecies e = s.iterations[ 0 ].particles[ "e" ];
RecordComponent weighting = e[ "weighting" ][ RecordComponent::SCALAR ];
weighting.resetDataset( Dataset( Datatype::FLOAT, Extent{ 2, 2 } ) );
weighting.storeChunk( std::shared_ptr< float >(
new float[ 4 ]{},
[]( float * ptr ) { delete[] ptr; } ),
{ 0, 0 },
{ 2, 2 } );

s.flush();

for( auto const & key : { "position", "positionOffset" } )
{
for( auto const & dim : { "x", "y", "z" } )
{
RecordComponent rc = e[ key ][ dim ];
rc.resetDataset( Dataset( Datatype::FLOAT , Extent{ 2, 2 } ) );
rc.storeChunk( std::shared_ptr< float >(
new float[ 4 ]{},
[]( float * ptr ) { delete[] ptr; } ),
{ 0, 0 },
{ 2, 2 } );
}
}
}
}


inline
void particle_patches( std::string file_ending )
Expand Down