Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions include/openmc/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,15 @@ class LibMesh : public UnstructuredMesh {
LibMesh(const std::string& filename, double length_multiplier = 1.0);
LibMesh(libMesh::MeshBase& input_mesh, double length_multiplier = 1.0);

//! Create a mesh from an externally constructed libMesh mesh, transferring
//! ownership of the mesh to OpenMC
//
//! \param[in] input_mesh Externally built mesh (must be replicated)
//! \param[in] length_multiplier Multiplier applied to mesh coordinates
//! \param[in] filename Name of the file the mesh was read from, if any
LibMesh(unique_ptr<libMesh::MeshBase> input_mesh,
double length_multiplier = 1.0, const std::string& filename = "");

static const std::string mesh_lib_type;

// Overridden Methods
Expand Down
5 changes: 5 additions & 0 deletions include/openmc/weight_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ void apply_weight_window(Particle& p, WeightWindow weight_window);
//! Free memory associated with weight windows
void free_memory_weight_windows();

//! Build a WeightWindows object from multigroup adjoint flux stored as
//! elemental data in an Exodus II file (requires libMesh support)
//! \param[in] node XML node for <weight_windows_exodus> in settings.xml
void read_weight_windows_exodus(pugi::xml_node node);

//! Search weight window that apply to a particle
//! \param[in] p Particle to search weight window for
std::pair<bool, WeightWindow> search_weight_window(const Particle& p);
Expand Down
31 changes: 30 additions & 1 deletion openmc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from .source import SourceBase, MeshSource, IndependentSource
from .utility_funcs import input_path
from .volume import VolumeCalculation
from .weight_windows import WeightWindows, WeightWindowGenerator, WeightWindowsList
from .weight_windows import (WeightWindows, WeightWindowGenerator,
WeightWindowsList, WeightWindowsExodus)


class RunMode(Enum):
Expand Down Expand Up @@ -395,6 +396,12 @@ class Settings:
Path to a weight window file to load during simulation initialization

.. versionadded::0.14.0
weight_windows_exodus : openmc.WeightWindowsExodus
Specification for building weight windows from multigroup adjoint flux
stored as elemental data in an Exodus file. Requires OpenMC to be
built with libMesh support.

.. versionadded:: 0.15.4
write_initial_source : bool
Indicate whether to write the initial source distribution to file
"""
Expand Down Expand Up @@ -493,6 +500,7 @@ def __init__(self, **kwargs):
self._weight_windows_on = None
self._shared_secondary_bank = None
self._weight_windows_file = None
self._weight_windows_exodus = None
self._weight_window_checkpoints = {}
self._max_history_splits = None
self._max_tracks = None
Expand Down Expand Up @@ -1383,6 +1391,16 @@ def weight_windows_file(self, value: PathLike | None):
cv.check_type('weight windows file', value, PathLike)
self._weight_windows_file = input_path(value)

@property
def weight_windows_exodus(self) -> WeightWindowsExodus | None:
return self._weight_windows_exodus

@weight_windows_exodus.setter
def weight_windows_exodus(self, value: WeightWindowsExodus | None):
if value is not None:
cv.check_type('weight windows exodus', value, WeightWindowsExodus)
self._weight_windows_exodus = value

@property
def weight_window_generators(self) -> list[WeightWindowGenerator]:
return self._weight_window_generators
Expand Down Expand Up @@ -1973,6 +1991,10 @@ def _create_weight_windows_file_element(self, root):
element.text = str(self.weight_windows_file)
root.append(element)

def _create_weight_windows_exodus_subelement(self, root):
if self._weight_windows_exodus is not None:
root.append(self._weight_windows_exodus.to_xml_element())

def _create_weight_window_checkpoints_subelement(self, root):
if not self._weight_window_checkpoints:
return
Expand Down Expand Up @@ -2464,6 +2486,11 @@ def _weight_windows_file_from_xml_element(self, root):
if text is not None:
self.weight_windows_file = text

def _weight_windows_exodus_from_xml_element(self, root):
elem = root.find('weight_windows_exodus')
if elem is not None:
self.weight_windows_exodus = WeightWindowsExodus.from_xml_element(elem)

def _weight_window_checkpoints_from_xml_element(self, root):
elem = root.find('weight_window_checkpoints')
if elem is None:
Expand Down Expand Up @@ -2629,6 +2656,7 @@ def to_xml_element(self, mesh_memo=None):
self._create_shared_secondary_bank_subelement(element)
self._create_weight_window_generators_subelement(element, mesh_memo)
self._create_weight_windows_file_element(element)
self._create_weight_windows_exodus_subelement(element)
self._create_weight_window_checkpoints_subelement(element)
self._create_max_history_splits_subelement(element)
self._create_max_tracks_subelement(element)
Expand Down Expand Up @@ -2746,6 +2774,7 @@ def from_xml_element(cls, elem, meshes=None):
settings._weight_windows_on_from_xml_element(elem)
settings._shared_secondary_bank_from_xml_element(elem)
settings._weight_windows_file_from_xml_element(elem)
settings._weight_windows_exodus_from_xml_element(elem)
settings._weight_window_generators_from_xml_element(elem, meshes)
settings._weight_window_checkpoints_from_xml_element(elem)
settings._max_history_splits_from_xml_element(elem)
Expand Down
Loading
Loading