From 5dd6da91c5ce40894877fc216d664838f77d5c33 Mon Sep 17 00:00:00 2001 From: helen-brooks Date: Tue, 19 Apr 2022 15:50:34 +0100 Subject: [PATCH] Only expose methods that are needed externally --- include/openmc/dagmc.h | 10 ++-------- src/dagmc.cpp | 33 ++++++++++++--------------------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 4c4e7f8c4..2fa0919e5 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -98,13 +98,6 @@ public: //! assignments, etc. void initialize(); - //! When providing an external DAGMC instance, the user will need to call - //! these methods manually - void init_metadata(); //!< Create and initialise dagmcMetaData pointer - void init_uwuw(); //!< Create UWUW pointer - void init_cells(); //!< Create cells from DAGMC volumes - void init_surfaces(); //!< Create surfaces from DAGMC surfaces - //! Reads UWUW materials and returns an ID map void read_uwuw_materials(); //! Indicates whether or not UWUW materials are present @@ -155,6 +148,8 @@ public: private: void set_id(); //!< Deduce the universe id from model::universes void init_dagmc(); //!< Create and initialise DAGMC pointer + void init_metadata(); //!< Create and initialise dagmcMetaData pointer + void init_geometry(); //!< Create cells and surfaces from DAGMC entities std::string filename_; //!< Name of the DAGMC file used to create this universe @@ -169,7 +164,6 @@ private: //!< generate new material IDs for the universe bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard" //!< volume - moab::EntityHandle graveyard; //!< MOAB index for graveyard }; //============================================================================== diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 061c04f87..2d0bab86e 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -83,7 +83,9 @@ DAGUniverse::DAGUniverse(std::shared_ptr external_dagmc_ptr, adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids) { set_id(); - uwuw_disabled = (filename==""); + init_metadata(); + read_uwuw_materials(); + init_geometry(); } void DAGUniverse::set_id() @@ -103,19 +105,14 @@ void DAGUniverse::set_id() void DAGUniverse::initialize() { geom_type() = GeometryType::DAG; - uwuw_disabled = false; init_dagmc(); init_metadata(); - init_uwuw(); - read_uwuw_materials(); - init_cells(); - - init_surfaces(); + init_geometry(); } void DAGUniverse::init_dagmc() @@ -151,7 +148,7 @@ void DAGUniverse::init_metadata() MB_CHK_ERR_CONT(rval); } -void DAGUniverse::init_cells() +void DAGUniverse::init_geometry() { moab::ErrorCode rval; @@ -166,7 +163,7 @@ void DAGUniverse::init_cells() // initialize cell objects int n_cells = dagmc_instance_->num_entities(3); - graveyard = 0; + moab::EntityHandle graveyard = 0; for (int i = 0; i < n_cells; i++) { moab::EntityHandle vol_handle = dagmc_instance_->entity_by_index(3, i + 1); @@ -259,12 +256,6 @@ void DAGUniverse::init_cells() has_graveyard_ = graveyard; -} - -void DAGUniverse::init_surfaces() -{ - moab::ErrorCode rval; - // determine the next surface id int32_t next_surf_id = 0; for (const auto& s : model::surfaces) { @@ -514,14 +505,14 @@ void DAGUniverse::legacy_assign_material( } } -void DAGUniverse::init_uwuw() -{ - if (uwuw_disabled) return; - uwuw_ = std::make_shared(filename_.c_str()); -} - void DAGUniverse::read_uwuw_materials() { + // If no filename was provided, disable read UWUW materials + uwuw_disabled = (filename_==""); + + if (uwuw_disabled) return; + uwuw_ = std::make_shared(filename_.c_str()); + if (!uses_uwuw()) return;