diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index a7160b0c89..d17f820237 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -298,6 +298,9 @@ public: //! Add a score to the mesh instance void add_score(std::string score) const; + //! Remove a score from the mesh instance + void remove_score(std::string score) const; + //! Set data for a score void set_score_data(const std::string& score, std::vector values, diff --git a/src/mesh.cpp b/src/mesh.cpp index b76be1ee8e..5acfee44e7 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -2015,6 +2015,30 @@ UnstructuredMesh::add_score(std::string score) const { auto score_tags = this->get_score_tags(score); } +void UnstructuredMesh::remove_score(std::string score) const { + moab::ErrorCode rval; + moab::Tag tag; + auto value_name = score + "_mean"; + rval = mbi_->tag_get_handle(value_name.c_str(), tag); + if (rval != moab::MB_SUCCESS) return; + + rval = mbi_->tag_delete(tag); + if (rval != moab::MB_SUCCESS) { + auto msg = fmt::format("Failed to delete mesh tag for the score {}" + " on unstructured mesh {}", score, id_); + fatal_error(msg); + } + + auto std_dev_name = score + "_std_dev"; + rval = mbi_->tag_get_handle(std_dev_name.c_str(), tag); + if (rval != moab::MB_SUCCESS) { + auto msg = fmt::format("Std. Dev. mesh tag does not exist for the score {}" + " on unstructured mesh {}", score, id_); + } + + +} + void UnstructuredMesh::set_score_data(const std::string& score, std::vector values, diff --git a/src/state_point.cpp b/src/state_point.cpp index bf249aa983..faf8071e77 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -687,6 +687,8 @@ void read_source_bank(hid_t group_id) void write_unstructured_mesh_results() { for (auto& tally : model::tallies) { + + std::vector tally_scores; for (auto filter_idx : tally->filters()) { auto& filter = model::tally_filters[filter_idx]; if (filter->type() != "mesh") continue; @@ -754,6 +756,8 @@ void write_unstructured_mesh_results() { w); // Write the unstructured mesh and data to file umesh->write(filename); + + for (const auto& score : tally_scores) { umesh->remove_score(score); } } } }