diff --git a/src/interface/data_collection.cpp b/src/interface/data_collection.cpp index 53dd6d8cc968..e1173b68bee9 100644 --- a/src/interface/data_collection.cpp +++ b/src/interface/data_collection.cpp @@ -60,10 +60,55 @@ std::shared_ptr &DataCollection::AddShallow(const std::string &label, const std::vector &flags) { return Add(label, src, flags, true); } +template +std::shared_ptr & +DataCollection::Add(const std::string &name, const std::string src_name, + const std::vector &field_names, const bool shallow) { + return Add(name, containers_[src_name], field_names, false); +} +template +std::shared_ptr &DataCollection::Add(const std::string &name, + const std::string src_name, + const std::vector &field_names) { + return Add(name, containers_[src_name], field_names, false); +} +template +std::shared_ptr & +DataCollection::AddShallow(const std::string &name, const std::string src_name, + const std::vector &field_names) { + return Add(name, containers_[src_name], field_names, true); +} +template +std::shared_ptr &DataCollection::Add(const std::string &name, + const std::string src_name) { + return Add(name, containers_[src_name], {}, false); +} +template +std::shared_ptr &DataCollection::AddShallow(const std::string &name, + const std::string src_name) { + return Add(name, containers_[src_name], {}, true); +} +template +std::shared_ptr & +DataCollection::Add(const std::string &name, + const std::vector &field_names, const bool shallow) { + return Add(name, containers_["base"], field_names, false); +} +template +std::shared_ptr &DataCollection::Add(const std::string &name, + const std::vector &field_names) { + return Add(name, containers_["base"], field_names, false); +} +template +std::shared_ptr & +DataCollection::AddShallow(const std::string &name, + const std::vector &field_names) { + return Add(name, containers_["base"], field_names, true); +} template <> std::shared_ptr> & -DataCollection>::GetOrAdd(const std::string &mbd_label, +DataCollection>::GetOrAddByPartition(const std::string &mbd_label, const int &partition_id) { const std::string label = mbd_label + "_part-" + std::to_string(partition_id); auto it = containers_.find(label); diff --git a/src/interface/state_descriptor.cpp b/src/interface/state_descriptor.cpp index 3ab618a722d1..74d922b6ecbc 100644 --- a/src/interface/state_descriptor.cpp +++ b/src/interface/state_descriptor.cpp @@ -530,4 +530,37 @@ StateDescriptor::GetVariableNames(const Metadata::FlagCollection &flags) { return GetVariableNames({}, flags, {}); } +// Get the total length of this StateDescriptor's variables when packed +int StateDescriptor::GetPackDimension(const std::vector &req_names, + const Metadata::FlagCollection &flags, + const std::vector &sparse_ids) { + std::vector names = GetVariableNames(req_names, flags, sparse_ids); + int nvar = 0; + for (auto name : names) { + const auto &meta = metadataMap_[VarID(name)]; + int var_len = 0; + if (meta.Shape().size() < 1) { + var_len = 1; + } else { + var_len = meta.Shape()[0]; + } + nvar += var_len; + } + return nvar; +} +int StateDescriptor::GetPackDimension(const std::vector &req_names, + const std::vector &sparse_ids) { + return GetPackDimension(req_names, Metadata::FlagCollection(), sparse_ids); +} +int StateDescriptor::GetPackDimension(const Metadata::FlagCollection &flags, + const std::vector &sparse_ids) { + return GetPackDimension({}, flags, sparse_ids); +} +int StateDescriptor::GetPackDimension(const std::vector &req_names) { + return GetPackDimension(req_names, Metadata::FlagCollection(), {}); +} +int StateDescriptor::GetPackDimension(const Metadata::FlagCollection &flags) { + return GetPackDimension({}, flags, {}); +} + } // namespace parthenon diff --git a/src/interface/state_descriptor.hpp b/src/interface/state_descriptor.hpp index 06537a87d88a..a53a69245e6e 100644 --- a/src/interface/state_descriptor.hpp +++ b/src/interface/state_descriptor.hpp @@ -272,6 +272,16 @@ class StateDescriptor { std::vector GetVariableNames(const std::vector &req_names); std::vector GetVariableNames(const Metadata::FlagCollection &flags); + int GetPackDimension(const std::vector &req_names, + const Metadata::FlagCollection &flags, + const std::vector &sparse_ids); + int GetPackDimension(const std::vector &req_names, + const std::vector &sparse_ids); + int GetPackDimension(const Metadata::FlagCollection &flags, + const std::vector &sparse_ids); + int GetPackDimension(const std::vector &req_names); + int GetPackDimension(const Metadata::FlagCollection &flags); + std::size_t RefinementFuncID(const refinement::RefinementFunctions_t &funcs) const noexcept { return refinementFuncMaps_.funcs_to_ids.at(funcs); diff --git a/src/mesh/mesh.cpp b/src/mesh/mesh.cpp index 8eb59faf8a60..f87223546c2f 100644 --- a/src/mesh/mesh.cpp +++ b/src/mesh/mesh.cpp @@ -96,9 +96,9 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, Packages_t &packages, // private members: num_mesh_threads_(pin->GetOrAddInteger("parthenon/mesh", "num_threads", 1)), tree(this), use_uniform_meshgen_fn_{true, true, true, true}, lb_flag_(true), - lb_automatic_(), - lb_manual_(), MeshGenerator_{nullptr, UniformMeshGeneratorX1, - UniformMeshGeneratorX2, UniformMeshGeneratorX3}, + lb_automatic_(), lb_manual_(), + MeshGenerator_{nullptr, UniformMeshGeneratorX1, UniformMeshGeneratorX2, + UniformMeshGeneratorX3}, MeshBndryFnctn{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr} { std::stringstream msg; RegionSize block_size; @@ -541,9 +541,9 @@ Mesh::Mesh(ParameterInput *pin, ApplicationInput *app_in, RestartReader &rr, // private members: num_mesh_threads_(pin->GetOrAddInteger("parthenon/mesh", "num_threads", 1)), tree(this), use_uniform_meshgen_fn_{true, true, true, true}, lb_flag_(true), - lb_automatic_(), - lb_manual_(), MeshGenerator_{nullptr, UniformMeshGeneratorX1, - UniformMeshGeneratorX2, UniformMeshGeneratorX3}, + lb_automatic_(), lb_manual_(), + MeshGenerator_{nullptr, UniformMeshGeneratorX1, UniformMeshGeneratorX2, + UniformMeshGeneratorX3}, MeshBndryFnctn{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr} { std::stringstream msg; RegionSize block_size;