Skip to content

Commit

Permalink
Extend example
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Nov 15, 2023
1 parent 770c67e commit 9d4a9f4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion examples/14_toml_template.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <openPMD/auxiliary/TemplateFile.hpp>
#include <openPMD/openPMD.hpp>

std::string backendEnding()
Expand Down Expand Up @@ -97,7 +98,23 @@ void read()
"../samples/tomlTemplate." + backendEnding(),
openPMD::Access::READ_LINEAR);
read.readIterations(); // @todo change to read.parseBase()
openPMD::helper::listSeries(read);

std::string jsonConfig = R"(
{
"iteration_encoding": "variable_based",
"json": {
"mode": "template"
}
}
)";
openPMD::Series cloned(
"../samples/jsonTemplate.json", openPMD::Access::CREATE, jsonConfig);
openPMD::auxiliary::initializeFromTemplate(cloned, read, 0);
// Have to define the dataset for E/z as it is not defined in the template
// @todo check that the dataset is defined only upon destruction, not at
// flushing already
cloned.writeIterations()[0].meshes["E"]["z"].resetDataset(
{openPMD::Datatype::INT});
}

int main()
Expand Down

0 comments on commit 9d4a9f4

Please sign in to comment.