From fd8a8207082522a7a454931c49453ee5f0c833e9 Mon Sep 17 00:00:00 2001 From: lewisgross1296 Date: Tue, 26 Jul 2022 12:40:13 -0500 Subject: [PATCH] added public mesh_ptr() accessor. moved m->prepare_for_use() to filename constructor since it only happens there. for consistency, added theh length_multiplier scale modification to constructors --- include/openmc/mesh.h | 2 ++ src/mesh.cpp | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index ce512c7674..cd2e56bb0c 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -704,6 +704,8 @@ public: double volume(int bin) const override; + libMesh::MeshBase * mesh_ptr() const; + private: void initialize() override; void set_mesh_pointer_from_filename(const std::string& filename); diff --git a/src/mesh.cpp b/src/mesh.cpp index 44580d81be..5c2c8ea252 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -2332,6 +2332,9 @@ LibMesh::LibMesh(libMesh::MeshBase & input_mesh, double length_multiplier) { m_ = &input_mesh; set_length_multiplier(length_multiplier); + if (specified_length_multiplier_) { + libMesh::MeshTools::Modification::scale(*m_, length_multiplier_); + } initialize(); } @@ -2340,6 +2343,10 @@ LibMesh::LibMesh(const std::string& filename, double length_multiplier) { set_mesh_pointer_from_filename(filename); set_length_multiplier(length_multiplier); + if (specified_length_multiplier_) { + libMesh::MeshTools::Modification::scale(*m_, length_multiplier_); + } + m_->prepare_for_use(); initialize(); } @@ -2362,12 +2369,6 @@ void LibMesh::initialize() // assuming that unstructured meshes used in OpenMC are 3D n_dimension_ = 3; - if (specified_length_multiplier_) { - libMesh::MeshTools::Modification::scale(*m_, length_multiplier_); - } - - m_->prepare_for_use(); - // ensure that the loaded mesh is 3 dimensional if (m_->mesh_dimension() != n_dimension_) { fatal_error(fmt::format("Mesh file {} specified for use in an unstructured " @@ -2565,6 +2566,11 @@ double LibMesh::volume(int bin) const return m_->elem_ref(bin).volume(); } +libMesh::MeshBase * mesh_ptr() const +{ + return m_; +} + #endif // LIBMESH //==============================================================================