From 651ef1255c515adc71e21dda74e457baba2e7dbb Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 8 Apr 2020 12:54:18 -0500 Subject: [PATCH] Some cleanup of the bin_label functions. --- include/openmc/mesh.h | 17 +++++++---------- src/mesh.cpp | 22 +--------------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 5b25ae73b..e9d10b6c8 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -108,6 +108,9 @@ public: plot(Position plot_ll, Position plot_ur) const = 0; //! Get a label for the mesh bin + //! Return a string representation of the mesh bin + // + //! \param[in] bin Mesh bin to generate a label for virtual std::string bin_label(int bin) const = 0; // Data members @@ -219,8 +222,6 @@ public: double negative_grid_boundary(int* ijk, int i) const override; - std::string bin_label(int bin) const override; - int n_surface_bins() const override; std::pair, std::vector> @@ -274,6 +275,7 @@ public: }; class UnstructuredMeshBase : public Mesh { + public: // constructors UnstructuredMeshBase() {}; @@ -282,10 +284,10 @@ public: std::string bin_label(int bin) const override; - //! Add a variable to the libmesh mesh instance + //! Add a variable to the mesh instance virtual void add_score(const std::string& var_name) = 0; - //! Set the value of a bin for a variable on the libmesh mesh instance + //! Set the value of a bin for a variable on the mesh instance virtual void set_score_data(const std::string& var_name, std::vector values, std::vector std_dev) = 0; @@ -294,7 +296,7 @@ public: virtual Position centroid(int bin) const = 0; - + // Data members std::string filename_; }; @@ -343,11 +345,6 @@ public: // \return The centroid of the element Position centroid(int bin) const override; - //! Return a string represntation of the mesh bin - // - //! \param[in] bin Mesh bin to generate a label for - std::string bin_label(int bin) const override; - //! Add a score to the mesh instance void add_score(const std::string& score); diff --git a/src/mesh.cpp b/src/mesh.cpp index 2deeaa540..955c264ab 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -133,9 +133,7 @@ UnstructuredMeshBase::UnstructuredMeshBase(pugi::xml_node node) : Mesh(node) { std::string UnstructuredMeshBase::bin_label(int bin) const { - std::stringstream out; - out << "Mesh Index (" << bin << ")"; - return out.str(); + return fmt::format("Mesh Index ({})", bin); }; //============================================================================== @@ -1055,19 +1053,6 @@ RegularMesh::count_sites(const Particle::Bank* bank, return counts; } -std::string RegularMesh::bin_label(int bin) const { - int ijk[n_dimension_]; - get_indices_from_bin(bin, ijk); - - std::stringstream out; - out << "Mesh Index (" << ijk[0]; - if (n_dimension_ > 1) out << ", " << ijk[1]; - if (n_dimension_ > 2) out << ", " << ijk[2]; - out << ")"; - - return out.str(); -} - //============================================================================== // RectilinearMesh implementation //============================================================================== @@ -2033,11 +2018,6 @@ UnstructuredMesh::centroid(int bin) const { return {centroid[0], centroid[1], centroid[2]}; } -std::string -UnstructuredMesh::bin_label(int bin) const { - return fmt::format("Mesh Index ({})", bin); -}; - std::pair UnstructuredMesh::get_score_tags(std::string score) const { moab::ErrorCode rval;