Skip to content

Commit 7d09a12

Browse files
pshriwiseclaudepaulromano
authored
DAGMC Cell Override Updates (#3888)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 66497e7 commit 7d09a12

9 files changed

Lines changed: 693 additions & 268 deletions

File tree

docs/source/io_formats/geometry.rst

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -406,24 +406,55 @@ Each ``<dagmc_universe>`` element can have the following attributes or sub-eleme
406406

407407
*Default*: None
408408

409-
:material_overrides:
410-
This element contains information on material overrides to be applied to the
411-
DAGMC universe. It has the following attributes and sub-elements:
412-
413-
:cell:
414-
Material override information for a single cell. It contains the following
415-
attributes and sub-elements:
416-
417-
:id:
418-
The cell ID in the DAGMC geometry for which the material override will
419-
apply.
420-
421-
:materials:
422-
A list of material IDs that will apply to instances of the cell. If the
423-
list contains only one ID, it will replace the original material
424-
assignment of all instances of the DAGMC cell. If the list contains more
425-
than one material, each material ID of the list will be assigned to the
426-
various instances of the DAGMC cell.
409+
:cell:
410+
Zero or more ``<cell>`` sub-elements may appear to override properties of
411+
individual DAGMC volumes. Each ``<cell>`` element supports the following
412+
attributes and sub-elements:
413+
414+
:id:
415+
The integer cell ID in the DAGMC geometry to override. Required.
416+
417+
:name:
418+
An optional string label for the cell.
419+
420+
*Default*: None
421+
422+
:material:
423+
The material ID to assign to this cell. Use ``void`` for vacuum. Multiple
424+
space-separated IDs may be given to specify a distribmat (distributed
425+
material) assignment. Required.
426+
427+
:temperature:
428+
Temperature(s) in [K] to assign to the cell. Must be ≥ 0. Multiple
429+
space-separated values may be given.
430+
431+
*Default*: None
432+
433+
:density:
434+
Density in [g/cm³] to assign to the cell. Must be > 0. Requires a non-void
435+
material fill. Multiple space-separated values may be given.
436+
437+
*Default*: None
438+
439+
:volume:
440+
Volume of the cell in [cm³].
441+
442+
.. note:: DAGMC can compute cell volumes exactly from the triangulated
443+
mesh surfaces. Specifying a manual volume risks inconsistency
444+
with that capability.
445+
446+
*Default*: None
447+
448+
The following standard ``<cell>`` attributes are **not** supported inside
449+
``<dagmc_universe>`` and will raise an error if present: ``region``,
450+
``fill``, ``universe``, ``translation``, ``rotation``.
451+
452+
.. deprecated::
453+
The ``<material_overrides>`` sub-element (containing ``<cell_override>``
454+
children with ``<material_ids>``) is deprecated. A deprecation warning is
455+
emitted and the overrides are converted to the ``<cell>`` format at parse
456+
time. It is an error to specify both ``<material_overrides>`` and
457+
``<cell>`` sub-elements on the same ``<dagmc_universe>``.
427458

428459
*Default*: None
429460

include/openmc/cell.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ class Region {
145145
bool simple_; //!< Does the region contain only intersections?
146146
};
147147

148+
//==============================================================================
149+
// XML parsing helpers for <cell> nodes
150+
//==============================================================================
151+
152+
//! Parse material IDs from a <cell> XML node.
153+
//! \param node XML node containing a "material" attribute or child element
154+
//! \param cell_id Cell ID used in error messages
155+
//! \return Vector of material IDs (MATERIAL_VOID for "void")
156+
vector<int32_t> parse_cell_material_xml(pugi::xml_node node, int32_t cell_id);
157+
158+
//! Parse temperatures in [K] from a <cell> XML node.
159+
//! Validates that all values are non-negative and the list is non-empty.
160+
//! \param node XML node containing a "temperature" attribute or child element
161+
//! \param cell_id Cell ID used in error messages
162+
//! \return Vector of temperatures in [K]
163+
vector<double> parse_cell_temperature_xml(pugi::xml_node node, int32_t cell_id);
164+
165+
//! Parse densities in [g/cm³] from a <cell> XML node.
166+
//! Validates that all values are positive and the list is non-empty.
167+
//! \param node XML node containing a "density" attribute or child element
168+
//! \param cell_id Cell ID used in error messages
169+
//! \return Vector of densities in [g/cm³]
170+
vector<double> parse_cell_density_xml(pugi::xml_node node, int32_t cell_id);
171+
148172
//==============================================================================
149173

150174
class Cell {

include/openmc/dagmc.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class DAGCell : public Cell {
9494
class DAGUniverse : public Universe {
9595

9696
public:
97+
using MaterialOverrides = std::unordered_map<int32_t, vector<int32_t>>;
98+
using TemperatureOverrides = std::unordered_map<int32_t, vector<double>>;
99+
using DensityOverrides = std::unordered_map<int32_t, vector<double>>;
100+
97101
explicit DAGUniverse(pugi::xml_node node);
98102

99103
//! Create a new DAGMC universe
@@ -112,6 +116,9 @@ class DAGUniverse : public Universe {
112116
//! Initialize the DAGMC accel. data structures, indices, material
113117
//! assignments, etc.
114118
void initialize();
119+
void initialize(const MaterialOverrides& material_overrides,
120+
const TemperatureOverrides& temperature_overrides,
121+
const DensityOverrides& density_overrides = {});
115122

116123
//! Reads UWUW materials and returns an ID map
117124
void read_uwuw_materials();
@@ -146,7 +153,8 @@ class DAGUniverse : public Universe {
146153

147154
//! Assign a material overriding normal assignement to a cell
148155
//! \param[in] c The OpenMC cell to which the material is assigned
149-
void override_assign_material(std::unique_ptr<DAGCell>& c) const;
156+
void override_assign_material(std::unique_ptr<DAGCell>& c,
157+
const MaterialOverrides& material_overrides) const;
150158

151159
//! Return the index into the model cells vector for a given DAGMC volume
152160
//! handle in the universe
@@ -187,7 +195,9 @@ class DAGUniverse : public Universe {
187195
void set_id(); //!< Deduce the universe id from model::universes
188196
void init_dagmc(); //!< Create and initialise DAGMC pointer
189197
void init_metadata(); //!< Create and initialise dagmcMetaData pointer
190-
void init_geometry(); //!< Create cells and surfaces from DAGMC entities
198+
void init_geometry(const MaterialOverrides& material_overrides,
199+
const TemperatureOverrides& temperature_overrides,
200+
const DensityOverrides& density_overrides);
191201

192202
std::string
193203
filename_; //!< Name of the DAGMC file used to create this universe
@@ -201,11 +211,6 @@ class DAGUniverse : public Universe {
201211
//!< generate new material IDs for the universe
202212
bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard"
203213
//!< volume
204-
std::unordered_map<int32_t, vector<int32_t>>
205-
material_overrides_; //!< Map of material overrides
206-
//!< keys correspond to the DAGMCCell id
207-
//!< values are a list of material ids used
208-
//!< for the override
209214
};
210215

211216
//==============================================================================

0 commit comments

Comments
 (0)