mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
More refactoring of DAGMC universe metadata; allow external setting of material temperature and population of universes' cells
This commit is contained in:
parent
05577e6a2e
commit
cc6c3ac9e6
5 changed files with 52 additions and 31 deletions
|
|
@ -300,5 +300,8 @@ struct CellInstanceHash {
|
|||
|
||||
void read_cells(pugi::xml_node node);
|
||||
|
||||
//! Add cells to universes
|
||||
void populate_universes();
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_CELL_H
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ public:
|
|||
|
||||
//! Alternative DAGMC universe constructor for external DAGMC
|
||||
explicit DAGUniverse(std::shared_ptr<moab::DagMC> external_dagmc_ptr,
|
||||
const std::string& filename,
|
||||
bool auto_geom_ids = false,
|
||||
bool auto_mat_ids = false);
|
||||
|
||||
|
|
@ -97,6 +98,13 @@ 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
|
||||
|
|
@ -147,8 +155,6 @@ public:
|
|||
private:
|
||||
void set_id(); //!< Deduce the universe id from model::universes
|
||||
void init_dagmc(); //!< Create and initialise DAGMC pointer
|
||||
void init_cells(); //!< Create cells from DAGMC volumes
|
||||
void init_surfaces(); //!< Create surfaces from DAGMC surfaces
|
||||
|
||||
std::string
|
||||
filename_; //!< Name of the DAGMC file used to create this universe
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ public:
|
|||
//! \param[in] units Units of density
|
||||
void set_density(double density, gsl::cstring_span units);
|
||||
|
||||
//! Set temperature of the material
|
||||
void set_temperature(double temperature) { temperature_ = temperature; };
|
||||
|
||||
//! Get nuclides in material
|
||||
//! \return Indices into the global nuclides vector
|
||||
gsl::span<const int> nuclides() const
|
||||
|
|
|
|||
23
src/cell.cpp
23
src/cell.cpp
|
|
@ -846,6 +846,20 @@ void read_cells(pugi::xml_node node)
|
|||
|
||||
read_dagmc_universes(node);
|
||||
|
||||
populate_universes();
|
||||
|
||||
// Allocate the cell overlap count if necessary.
|
||||
if (settings::check_overlaps) {
|
||||
model::overlap_check_count.resize(model::cells.size(), 0);
|
||||
}
|
||||
|
||||
if (model::cells.size() == 0) {
|
||||
fatal_error("No cells were found in the geometry.xml file");
|
||||
}
|
||||
}
|
||||
|
||||
void populate_universes()
|
||||
{
|
||||
// Populate the Universe vector and map.
|
||||
for (int i = 0; i < model::cells.size(); i++) {
|
||||
int32_t uid = model::cells[i]->universe_;
|
||||
|
|
@ -860,15 +874,6 @@ void read_cells(pugi::xml_node node)
|
|||
}
|
||||
}
|
||||
model::universes.shrink_to_fit();
|
||||
|
||||
// Allocate the cell overlap count if necessary.
|
||||
if (settings::check_overlaps) {
|
||||
model::overlap_check_count.resize(model::cells.size(), 0);
|
||||
}
|
||||
|
||||
if (model::cells.size() == 0) {
|
||||
fatal_error("No cells were found in the geometry.xml file");
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -77,8 +77,9 @@ DAGUniverse::DAGUniverse(
|
|||
}
|
||||
|
||||
DAGUniverse::DAGUniverse(std::shared_ptr<moab::DagMC> external_dagmc_ptr,
|
||||
const std::string& filename,
|
||||
bool auto_geom_ids, bool auto_mat_ids)
|
||||
: dagmc_instance_(external_dagmc_ptr), filename_(""),
|
||||
: dagmc_instance_(external_dagmc_ptr), filename_(filename),
|
||||
adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids)
|
||||
{
|
||||
set_id();
|
||||
|
|
@ -104,6 +105,10 @@ void DAGUniverse::initialize()
|
|||
|
||||
init_dagmc();
|
||||
|
||||
init_metadata();
|
||||
|
||||
init_uwuw();
|
||||
|
||||
read_uwuw_materials();
|
||||
|
||||
init_cells();
|
||||
|
|
@ -128,7 +133,10 @@ void DAGUniverse::init_dagmc()
|
|||
// initialize acceleration data structures
|
||||
rval = dagmc_instance_->init_OBBTree();
|
||||
MB_CHK_ERR_CONT(rval);
|
||||
}
|
||||
|
||||
void DAGUniverse::init_metadata()
|
||||
{
|
||||
// parse model metadata
|
||||
dmd_ptr = std::make_unique<dagmcMetaData>(dagmc_instance_.get(), false, false);
|
||||
dmd_ptr->load_property_data();
|
||||
|
|
@ -136,6 +144,7 @@ void DAGUniverse::init_dagmc()
|
|||
std::vector<std::string> keywords {"temp"};
|
||||
std::map<std::string, std::string> dum;
|
||||
std::string delimiters = ":/";
|
||||
moab::ErrorCode rval;
|
||||
rval = dagmc_instance_->parse_properties(keywords, dum, delimiters.c_str());
|
||||
MB_CHK_ERR_CONT(rval);
|
||||
}
|
||||
|
|
@ -502,38 +511,33 @@ void DAGUniverse::legacy_assign_material(
|
|||
}
|
||||
}
|
||||
|
||||
void DAGUniverse::init_uwuw()
|
||||
{
|
||||
uwuw_ = std::make_shared<UWUW>(filename_.c_str());
|
||||
}
|
||||
|
||||
void DAGUniverse::read_uwuw_materials()
|
||||
{
|
||||
|
||||
int32_t next_material_id = 0;
|
||||
for (const auto& m : model::materials) {
|
||||
next_material_id = std::max(m->id_, next_material_id);
|
||||
}
|
||||
next_material_id++;
|
||||
|
||||
uwuw_ = std::make_shared<UWUW>(filename_.c_str());
|
||||
const auto& mat_lib = uwuw_->material_library;
|
||||
if (mat_lib.size() == 0)
|
||||
if (!uses_uwuw())
|
||||
return;
|
||||
|
||||
// notify user if UWUW materials are going to be used
|
||||
// Notify user if UWUW materials are going to be used
|
||||
write_message("Found UWUW Materials in the DAGMC geometry file.", 6);
|
||||
|
||||
// if we're using automatic IDs, update the UWUW material metadata
|
||||
if (adjust_material_ids_) {
|
||||
int32_t next_material_id = 0;
|
||||
for (const auto& m : model::materials) {
|
||||
next_material_id = std::max(m->id_, next_material_id);
|
||||
}
|
||||
next_material_id++;
|
||||
|
||||
for (auto& mat : uwuw_->material_library) {
|
||||
mat.second->metadata["mat_number"] = next_material_id++;
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "<?xml version=\"1.0\"?>\n";
|
||||
ss << "<materials>\n";
|
||||
for (auto mat : mat_lib) {
|
||||
ss << mat.second->openmc("atom");
|
||||
}
|
||||
ss << "</materials>";
|
||||
std::string mat_xml_string = ss.str();
|
||||
std::string mat_xml_string = get_uwuw_materials_xml();
|
||||
|
||||
// create a pugi XML document from this string
|
||||
pugi::xml_document doc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue