diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 8bcc1ea067..1728392953 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -74,8 +74,13 @@ public: BoundingBox bounding_box() const; - GeometryType type_ = GeometryType::CSG; + const GeometryType& geom_type() const { return geom_type_; } + GeometryType& geom_type() { return geom_type_; } + unique_ptr partitioner_; + +private: + GeometryType geom_type_ = GeometryType::CSG; }; //============================================================================== diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 591ea64748..f2cc1ee2a3 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -5,6 +5,20 @@ namespace openmc { extern "C" const bool DAGMC_ENABLED; } +// always include the XML interface header +#include "openmc/xml_interface.h" + +//============================================================================== +// Functions that are always defined +//============================================================================== + +namespace openmc { + +void read_dagmc_universes(pugi::xml_node node); +void check_dagmc_root_univ(); + +} + #ifdef DAGMC #include "DagMC.hpp" @@ -13,7 +27,6 @@ extern "C" const bool DAGMC_ENABLED; #include "openmc/particle.h" #include "openmc/position.h" #include "openmc/surface.h" -#include "openmc/xml_interface.h" class UWUW; @@ -114,18 +127,21 @@ public: int32_t cell_idx_offset_; //!< An offset to the start of the cells in this universe in OpenMC's cell vector int32_t surf_idx_offset_; //!< An offset to the start of the surfaces in this universe in OpenMC's surface vector + // Accessors + bool has_graveyard() const { return has_graveyard_; } + private: std::string filename_; //!< Name of the DAGMC file used to create this universe std::shared_ptr uwuw_; //!< Pointer to the UWUW instance for this universe bool adjust_geometry_ids_; //!< Indicates whether or not to automatically generate new cell and surface IDs for the universe bool adjust_material_ids_; //!< Indicates whether or not to automatically generate new material IDs for the universe + bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard" volume }; //============================================================================== // Non-member functions //============================================================================== -void read_dagmc_universes(pugi::xml_node node); int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed); } // namespace openmc diff --git a/src/cell.cpp b/src/cell.cpp index c58fb17679..4de98aaddb 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -194,7 +194,7 @@ Universe::to_hdf5(hid_t universes_group) const auto group = create_group(universes_group, fmt::format("universe {}", id_)); // Write the geometry representation type. - switch(type_) { + switch(geom_type_) { case GeometryType::CSG : write_string(group, "geom_type", "csg", false); break; @@ -995,9 +995,7 @@ void read_cells(pugi::xml_node node) } } - #ifdef DAGMC read_dagmc_universes(node); - #endif // Populate the Universe vector and map. for (int i = 0; i < model::cells.size(); i++) { diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 775c130f75..bde33157f5 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -85,7 +85,7 @@ DAGUniverse::DAGUniverse(const std::string& filename, void DAGUniverse::initialize() { - type_ = GeometryType::DAG; + geom_type() = GeometryType::DAG; // determine the next cell id int32_t next_cell_id = 0; @@ -229,10 +229,7 @@ DAGUniverse::initialize() { model::overlap_check_count.resize(model::cells.size(), 0); } - if (!graveyard) { - warning("No graveyard volume found in the DagMC model. " - "This may result in lost particles and rapid simulation failure."); - } + has_graveyard_ = graveyard; // --- Surfaces --- @@ -631,6 +628,19 @@ void read_dagmc_universes(pugi::xml_node node) { } } +void check_dagmc_root_univ() { + const auto& ru = model::universes[model::root_universe]; + if (ru->geom_type() == GeometryType::DAG) { + // if the root universe contains DAGMC geometry, warn the user + // if it does not contain a graveyard volume + auto dag_univ = dynamic_cast(ru.get()); + if (dag_univ && !dag_univ->has_graveyard()) { + warning("No graveyard volume found in the DagMC model. " + "This may result in lost particles and rapid simulation failure."); + } + } +} + int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed) { moab::EntityHandle surf = @@ -645,5 +655,15 @@ int32_t next_cell(DAGUniverse* dag_univ, DAGCell* cur_cell, DAGSurface* surf_xed } -} -#endif +} // namespace openmc + +#else + +namespace openmc { + +void read_dagmc_universes(pugi::xml_node node) {}; +void check_dagmc_root_univ() {}; + +} // namespace openmc + +#endif // DAGMC diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index 80741b3e78..af6ebac9f8 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -80,9 +80,11 @@ void read_geometry_xml() fatal_error("No boundary conditions were applied to any surfaces!"); } - // Allocate universes, universe cell arrays, and assign base universe model::root_universe = find_root_universe(); + + // if the root universe is DAGMC geometry, make sure the model is well-formed + check_dagmc_root_univ(); } //==============================================================================