From 7aa68b7680dc203f91fb5b89a55a60d576dd0e2b Mon Sep 17 00:00:00 2001 From: Jonas Lippuner Date: Thu, 29 Apr 2021 13:46:28 -0500 Subject: [PATCH] address review comments need to update gold because metadata names changed: NumVariables => NumComponents VariableNames => ComponentNames --- src/interface/params.hpp | 28 ++++++++++++++++------------ src/outputs/parthenon_hdf5.cpp | 20 ++++++++++---------- src/parthenon_manager.cpp | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/interface/params.hpp b/src/interface/params.hpp index cdda8c2cb476..1f141ba5d3d7 100644 --- a/src/interface/params.hpp +++ b/src/interface/params.hpp @@ -114,9 +114,11 @@ class Params { #ifdef HDF5OUTPUT + private: // will write all params with type T to the given HDF5 group as an attribute template - void WriteToHDF5(const std::string &prefix, const HDF5::H5G &group) const { + void WriteToHDF5AllParamsOfTypeT(const std::string &prefix, + const HDF5::H5G &group) const { for (const auto &p : myParams_) { const auto &key = p.first; const auto type = myTypes_.at(key); @@ -128,20 +130,22 @@ class Params { } template - void WriteTVecToHDF5(const std::string &prefix, const HDF5::H5G &group) const { - WriteToHDF5(prefix, group); - WriteToHDF5>(prefix, group); + void WriteToHDF5AllParamsOfTypeTOrVecT(const std::string &prefix, + const HDF5::H5G &group) const { + WriteToHDF5AllParamsOfTypeT(prefix, group); + WriteToHDF5AllParamsOfTypeT>(prefix, group); } + public: void WriteAllToHDF5(const std::string &prefix, const HDF5::H5G &group) const { - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); - WriteTVecToHDF5(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); + WriteToHDF5AllParamsOfTypeTOrVecT(prefix, group); } #endif // ifdef HDF5OUTPUT diff --git a/src/outputs/parthenon_hdf5.cpp b/src/outputs/parthenon_hdf5.cpp index 4a7becd2d797..d4a025e27ea2 100644 --- a/src/outputs/parthenon_hdf5.cpp +++ b/src/outputs/parthenon_hdf5.cpp @@ -955,27 +955,27 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm } } - // NumVariables - number of variables within each dataset - std::vector numVariables; - // VariablesNames - Names of variables within each dataset - std::vector variableNames; + // number of components within each dataset + std::vector num_components; + // names of components within each dataset + std::vector component_names; for (const auto &vi : all_unique_vars) { const auto &component_labels = vi.component_labels; if (component_labels.size() > 0) { - numVariables.push_back(component_labels.size()); + num_components.push_back(component_labels.size()); for (const auto &label : component_labels) { - variableNames.push_back(label); + component_names.push_back(label); } } else { - numVariables.push_back(1); - variableNames.push_back(vi.label); + num_components.push_back(1); + component_names.push_back(vi.label); } } - HDF5WriteAttribute("NumVariables", numVariables, info_group); - HDF5WriteAttribute("VariableNames", variableNames, info_group); + HDF5WriteAttribute("NumComponents", num_components, info_group); + HDF5WriteAttribute("ComponentNames", component_names, info_group); // write SparseInfo and SparseFields (we can't write a zero-size dataset, so only write // this if we have sparse fields) diff --git a/src/parthenon_manager.cpp b/src/parthenon_manager.cpp index 61e9fa5bd6df..aec2f660f170 100644 --- a/src/parthenon_manager.cpp +++ b/src/parthenon_manager.cpp @@ -223,7 +223,7 @@ void ParthenonManager::RestartPackages(Mesh &rm, RestartReader &resfile) { // Get list of variables, assumed same for all blocks - // TODO(JL) this doesn't work anymore, will update this in sparse update + // TODO(JL) this won't work when reading true sparse variables, will be updated in PR #383 auto ciX = MeshBlockDataIterator( mb.meshblock_data.Get(),