From 9ab4ae4755b8056759043cd9e28631e6ca10de3f Mon Sep 17 00:00:00 2001 From: helen-brooks Date: Fri, 4 Jun 2021 12:34:16 +0100 Subject: [PATCH] Small refactor of MOAB construction into its own method --- include/openmc/mesh.h | 3 +++ src/mesh.cpp | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 260ee2ad78..1bac011e63 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -412,6 +412,9 @@ private: // Methods + //! Create the MOAB interface pointer + void create_interface(); + //! Find all intersections with faces of the mesh. // //! \param[in] start Staring location diff --git a/src/mesh.cpp b/src/mesh.cpp index 09ae82c707..e81f2c82da 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1583,13 +1583,12 @@ MOABMesh::MOABMesh(const std::string& filename) { } void MOABMesh::initialize() { - // create MOAB instance - mbi_ = make_unique(); - // load unstructured mesh file - moab::ErrorCode rval = mbi_->load_file(filename_.c_str()); - if (rval != moab::MB_SUCCESS) { - fatal_error("Failed to load the unstructured mesh file: " + filename_); - } + + // Create the MOAB interface and load data from file + create_interface(); + + // Initialise MOAB error code + moab::ErrorCode rval = moab::MB_SUCCESS; // set member range of tetrahedral entities rval = mbi_->get_entities_by_dimension(0, n_dimension_, ehs_); @@ -1619,6 +1618,19 @@ void MOABMesh::initialize() { build_kdtree(ehs_); } +void +MOABMesh::create_interface() +{ + // create MOAB instance + mbi_ = make_unique(); + + // load unstructured mesh file + moab::ErrorCode rval = mbi_->load_file(filename_.c_str()); + if (rval != moab::MB_SUCCESS) { + fatal_error("Failed to load the unstructured mesh file: " + filename_); + } +} + void MOABMesh::build_kdtree(const moab::Range& all_tets) {