Skip to content

Commit

Permalink
Use openPMD 2.0 standard setting
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 26, 2024
1 parent f225ff6 commit cc4e335
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ std::vector<double> Mesh::gridUnitSIPerDimension() const
Mesh &Mesh::setGridUnitSIPerDimension(std::vector<double> gridUnitSI)
{
setAttribute("gridUnitSI", std::move(gridUnitSI));
if (auto series_opt = retrieveSeries_optional(); series_opt.has_value())
{
if (auto version = series_opt->openPMD(); version < "2.")
{
throw error::IllegalInOpenPMDStandard(
"[Mesh::setGridUnitSI] Setting `gridUnitSI` as a vector in a "
"file with openPMD version '" +
version +
"', but per-axis specification is only supported as of "
"openPMD 2.0. Either upgrade the file to openPMD >= 2.0 "
"or specify a scalar that applies to all axes.");
}
}
return *this;
}

Expand Down Expand Up @@ -515,10 +528,7 @@ void Mesh::read()
IOHandler()->enqueue(IOTask(this, aRead));
IOHandler()->flush(internal::defaultFlushParams);
auto series = retrieveSeries();
/* @todo remove second if condition (currently enabled since it allows a
* sneak peek into openPMD 2.0 features)
*/
if (series.openPMD() >= "2." || isVector(*aRead.dtype))
if (series.openPMD() >= "2.")
{
if (auto val =
Attribute(*aRead.resource).getOptional<std::vector<double>>();
Expand Down

0 comments on commit cc4e335

Please sign in to comment.