From b2d75253575774ace1eefe480eb46d8fa5b61210 Mon Sep 17 00:00:00 2001 From: Philipp Grete Date: Wed, 4 Sep 2024 11:12:10 +0200 Subject: [PATCH] Bump OPMD version and add delim --- CMakeLists.txt | 2 +- src/outputs/parthenon_opmd.cpp | 3 ++- src/outputs/parthenon_opmd.hpp | 7 +++++++ src/outputs/restart_opmd.cpp | 11 ++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eda4bee63126..5c4435b04c5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,7 @@ if (PARTHENON_ENABLE_OPENPMD) FetchContent_Declare(openPMD GIT_REPOSITORY "https://github.com/openPMD/openPMD-api.git" # we need newer than the latest 0.15.2 release to support writing attriutes from a subset of ranks - GIT_TAG "bda3544") # develop as of 2024-07-12 + GIT_TAG "1c7d7ff") # develop as of 2024-09-02 FetchContent_MakeAvailable(openPMD) install(TARGETS openPMD EXPORT parthenonTargets) endif() diff --git a/src/outputs/parthenon_opmd.cpp b/src/outputs/parthenon_opmd.cpp index 8e1268ef4413..2526728b9c8d 100644 --- a/src/outputs/parthenon_opmd.cpp +++ b/src/outputs/parthenon_opmd.cpp @@ -65,7 +65,8 @@ using namespace OutputUtils; template void WriteAllParamsOfType(std::shared_ptr pkg, openPMD::Iteration *it) { - const std::string prefix = "Params/" + pkg->label() + "/"; + using OpenPMDUtils::delim; + const std::string prefix = "Params" + delim + pkg->label() + delim; const auto ¶ms = pkg->AllParams(); for (const auto &key : params.GetKeys()) { const auto type = params.GetType(key); diff --git a/src/outputs/parthenon_opmd.hpp b/src/outputs/parthenon_opmd.hpp index 94a9161ec424..2c7035dd13e9 100644 --- a/src/outputs/parthenon_opmd.hpp +++ b/src/outputs/parthenon_opmd.hpp @@ -20,6 +20,13 @@ namespace parthenon { namespace OpenPMDUtils { +// Deliminter to separate packages and parameters in attributes. +// More or less a workaround as the OpenPMD API does currently not expose +// access to non-standard groups (such as "Params" versus the standard "meshes"). +// TODO(pgrete & reviewer) (agree on delim and add check for package name and keys) OR +// better use of opmd-api +inline static const std::string delim = "+"; + // Construct OpenPMD Mesh "record" name and comonnent identifier. // - comp_idx is a flattended index over all components of the vectors and tensors, i.e., // the typical v,u,t indices. diff --git a/src/outputs/restart_opmd.cpp b/src/outputs/restart_opmd.cpp index b6767eaa3714..8fd939f2ae84 100644 --- a/src/outputs/restart_opmd.cpp +++ b/src/outputs/restart_opmd.cpp @@ -116,11 +116,20 @@ std::size_t RestartReaderOPMD::GetSwarmCounts(const std::string &swarm, template void RestartReaderOPMD::ReadAllParamsOfType(const std::string &pkg_name, Params ¶ms) { + using OpenPMDUtils::delim; for (const auto &key : params.GetKeys()) { const auto type = params.GetType(key); auto mutability = params.GetMutability(key); if (type == std::type_index(typeid(T)) && mutability == Params::Mutability::Restart) { - auto val = it->getAttribute("Params/" + pkg_name + "/" + key).get(); + auto attrs = it->attributes(); + for (const auto & attr : attrs) { + std::cout << "Contains attribute: " << attr << std::endl; + } + std::cout << "Reading '" + << "Params" + delim + pkg_name + delim + key << "' with type: " << typeid(T).name() + << std::endl; + + auto val = it->getAttribute("Params" + delim + pkg_name + delim + key).get(); params.Update(key, val); } }