Adding a fucntion for printing a warning if a root DAGMC universe does not contain a graveyard volume.

This commit is contained in:
Patrick Shriwise 2021-06-28 14:39:35 -05:00
parent 019316e18d
commit 648054fbc7
5 changed files with 55 additions and 14 deletions

View file

@ -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<UniversePartitioner> partitioner_;
private:
GeometryType geom_type_ = GeometryType::CSG;
};
//==============================================================================

View file

@ -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> 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

View file

@ -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++) {

View file

@ -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<DAGUniverse*>(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

View file

@ -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();
}
//==============================================================================