Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 52 additions & 18 deletions docs/source/io_formats/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,24 +406,58 @@ Each ``<dagmc_universe>`` element can have the following attributes or sub-eleme

*Default*: None

:material_overrides:
This element contains information on material overrides to be applied to the
DAGMC universe. It has the following attributes and sub-elements:

:cell:
Material override information for a single cell. It contains the following
attributes and sub-elements:

:id:
The cell ID in the DAGMC geometry for which the material override will
apply.

:materials:
A list of material IDs that will apply to instances of the cell. If the
list contains only one ID, it will replace the original material
assignment of all instances of the DAGMC cell. If the list contains more
than one material, each material ID of the list will be assigned to the
various instances of the DAGMC cell.
:cell:
Zero or more ``<cell>`` sub-elements may appear to override properties of
individual DAGMC volumes. Each ``<cell>`` element supports the following
attributes and sub-elements:

:id:
The integer cell ID in the DAGMC geometry to override. Required.

:name:
An optional string label for the cell.

*Default*: None

:material:
The material ID to assign to this cell. Use ``void`` for vacuum. Multiple
space-separated IDs may be given to specify a distribmat (distributed
material) assignment. May also be specified as a ``<material>``
sub-element. Required.

:temperature:
Temperature(s) in Kelvin to assign to the cell. Must be ≥ 0. Multiple
space-separated values may be given. May also be specified as a
``<temperature>`` sub-element.

*Default*: None

:density:
Density in g/cm³ to assign to the cell. Must be > 0. Requires a non-void
material fill. Multiple space-separated values may be given. May also be
specified as a ``<density>`` sub-element.

*Default*: None

:volume:
Volume of the cell in cm³.

.. note:: DAGMC can compute cell volumes exactly from the triangulated
mesh surfaces. Specifying a manual volume risks inconsistency
with that capability.

*Default*: None

The following standard ``<cell>`` attributes are **not** supported inside
``<dagmc_universe>`` and will raise an error if present: ``region``,
``fill``, ``universe``, ``translation``, ``rotation``.

.. deprecated::
The ``<material_overrides>`` sub-element (containing ``<cell_override>``
children with ``<material_ids>``) is deprecated. A deprecation warning is
emitted and the overrides are converted to the ``<cell>`` format at parse
time. It is an error to specify both ``<material_overrides>`` and
``<cell>`` sub-elements on the same ``<dagmc_universe>``.

*Default*: None

Expand Down
24 changes: 24 additions & 0 deletions include/openmc/cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@ class Region {
bool simple_; //!< Does the region contain only intersections?
};

//==============================================================================
// XML parsing helpers for <cell> nodes
//==============================================================================

//! Parse material IDs from a <cell> XML node.
//! \param node XML node containing a "material" attribute or child element
//! \param cell_id Cell ID used in error messages
//! \return Vector of material IDs (MATERIAL_VOID for "void")
vector<int32_t> parse_cell_material_xml(pugi::xml_node node, int32_t cell_id);

//! Parse temperatures (in Kelvin) from a <cell> XML node.
//! Validates that all values are non-negative and the list is non-empty.
//! \param node XML node containing a "temperature" attribute or child element
//! \param cell_id Cell ID used in error messages
//! \return Vector of temperatures in Kelvin
vector<double> parse_cell_temperature_xml(pugi::xml_node node, int32_t cell_id);

//! Parse densities (in g/cm³) from a <cell> XML node.
//! Validates that all values are positive and the list is non-empty.
//! \param node XML node containing a "density" attribute or child element
//! \param cell_id Cell ID used in error messages
//! \return Vector of densities in g/cm³
vector<double> parse_cell_density_xml(pugi::xml_node node, int32_t cell_id);

//==============================================================================

class Cell {
Expand Down
19 changes: 12 additions & 7 deletions include/openmc/dagmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class DAGCell : public Cell {
class DAGUniverse : public Universe {

public:
using MaterialOverrides = std::unordered_map<int32_t, vector<int32_t>>;
using TemperatureOverrides = std::unordered_map<int32_t, vector<double>>;
using DensityOverrides = std::unordered_map<int32_t, vector<double>>;

explicit DAGUniverse(pugi::xml_node node);

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

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

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

//! Return the index into the model cells vector for a given DAGMC volume
//! handle in the universe
Expand Down Expand Up @@ -187,7 +195,9 @@ class DAGUniverse : public Universe {
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
void init_geometry(const MaterialOverrides& material_overrides,
const TemperatureOverrides& temperature_overrides,
const DensityOverrides& density_overrides);

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

//==============================================================================
Expand Down
Loading
Loading