Skip to content

Commit 623c6fa

Browse files
committed
Merge branch 'develop' into point-detector
2 parents cd9aafd + 111eb77 commit 623c6fa

110 files changed

Lines changed: 4488 additions & 768 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,7 @@ add_custom_command(TARGET libopenmc POST_BUILD
614614
#===============================================================================
615615
# Install executable, scripts, manpage, license
616616
#===============================================================================
617-
618-
configure_file(cmake/OpenMCConfig.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake" @ONLY)
619-
configure_file(cmake/OpenMCConfigVersion.cmake.in "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake" @ONLY)
617+
include(CMakePackageConfigHelpers)
620618

621619
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/OpenMC)
622620
install(TARGETS openmc libopenmc
@@ -630,10 +628,24 @@ install(EXPORT openmc-targets
630628
NAMESPACE OpenMC::
631629
DESTINATION ${INSTALL_CONFIGDIR})
632630

631+
configure_package_config_file(
632+
"cmake/OpenMCConfig.cmake.in"
633+
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
634+
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
635+
)
636+
637+
write_basic_package_version_file(
638+
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
639+
VERSION ${OPENMC_VERSION}
640+
COMPATIBILITY AnyNewerVersion
641+
)
642+
633643
install(FILES
634-
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
635-
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
636-
DESTINATION ${INSTALL_CONFIGDIR})
644+
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfig.cmake"
645+
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/OpenMCConfigVersion.cmake"
646+
DESTINATION "${INSTALL_CONFIGDIR}"
647+
)
648+
637649
install(FILES man/man1/openmc.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
638650
install(FILES LICENSE DESTINATION "${CMAKE_INSTALL_DOCDIR}" RENAME copyright)
639651
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

cmake/OpenMCConfig.cmake.in

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
1+
@PACKAGE_INIT@
22

3-
# Compute the install prefix from this file's location
4-
get_filename_component(_OPENMC_PREFIX "${OpenMC_CMAKE_DIR}/../../.." ABSOLUTE)
3+
include("${CMAKE_CURRENT_LIST_DIR}/OpenMCConfigVersion.cmake")
4+
include(CMakeFindDependencyMacro)
5+
6+
# Explicitly calculate prefix if it was not generated above
7+
if(NOT DEFINED PACKAGE_PREFIX_DIR)
8+
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
9+
endif()
10+
11+
find_dependency(fmt CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR})
12+
find_dependency(pugixml CONFIG REQUIRED HINTS ${PACKAGE_PREFIX_DIR})
513

6-
find_package(fmt CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
7-
find_package(pugixml CONFIG REQUIRED HINTS ${_OPENMC_PREFIX})
814
if(@OPENMC_USE_DAGMC@)
9-
find_package(DAGMC REQUIRED HINTS @DAGMC_DIR@)
15+
find_dependency(DAGMC REQUIRED HINTS @DAGMC_DIR@)
1016
endif()
1117

1218
if(@OPENMC_USE_LIBMESH@)
@@ -16,20 +22,24 @@ if(@OPENMC_USE_LIBMESH@)
1622
pkg_check_modules(LIBMESH REQUIRED @LIBMESH_PC_FILE@>=1.7.0 IMPORTED_TARGET)
1723
endif()
1824

19-
find_package(PNG)
20-
21-
if(NOT TARGET OpenMC::libopenmc)
22-
include("${OpenMC_CMAKE_DIR}/OpenMCTargets.cmake")
25+
if("@PNG_FOUND@")
26+
find_dependency(PNG)
2327
endif()
2428

2529
if(@OPENMC_USE_MPI@)
26-
find_package(MPI REQUIRED)
30+
find_dependency(MPI REQUIRED)
2731
endif()
2832

2933
if(@OPENMC_USE_OPENMP@)
30-
find_package(OpenMP REQUIRED)
34+
find_dependency(OpenMP REQUIRED)
3135
endif()
3236

3337
if(@OPENMC_USE_UWUW@ AND NOT ${DAGMC_BUILD_UWUW})
3438
message(FATAL_ERROR "UWUW is enabled in OpenMC but the DAGMC installation discovered was not configured with UWUW.")
3539
endif()
40+
41+
include("${CMAKE_CURRENT_LIST_DIR}/OpenMCTargets.cmake")
42+
43+
if(NOT OpenMC_FIND_QUIETLY)
44+
message(STATUS "Found OpenMC: ${PACKAGE_VERSION} (found in ${PACKAGE_PREFIX_DIR})")
45+
endif()

cmake/OpenMCConfigVersion.cmake.in

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

docs/source/io_formats/settings.rst

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,16 @@ pseudo-random number generator.
741741

742742
*Default*: 1
743743

744-
--------------------
745-
``<stride>`` Element
746-
--------------------
747-
748-
The ``stride`` element is used to specify how many random numbers are allocated
749-
for each source particle history.
744+
-----------------------------------
745+
``<shared_secondary_bank>`` Element
746+
-----------------------------------
750747

751-
*Default*: 152,917
748+
The ``shared_secondary_bank`` element indicates whether to use a shared
749+
secondary particle bank. When enabled, secondary particles are collected into
750+
a global bank, sorted for reproducibility, and load-balanced across MPI ranks
751+
between generations. If not specified, the shared secondary bank is enabled
752+
automatically for fixed-source simulations with weight windows active, and
753+
disabled otherwise.
752754

753755
.. _source_element:
754756

@@ -1156,23 +1158,6 @@ based on constraints.
11561158

11571159
*Default*: 0.05
11581160

1159-
-------------------------
1160-
``<state_point>`` Element
1161-
-------------------------
1162-
1163-
The ``<state_point>`` element indicates at what batches a state point file
1164-
should be written. A state point file can be used to restart a run or to get
1165-
tally results at any batch. The default behavior when using this tag is to
1166-
write out the source bank in the state_point file. This behavior can be
1167-
customized by using the ``<source_point>`` element. This element has the
1168-
following attributes/sub-elements:
1169-
1170-
:batches:
1171-
A list of integers separated by spaces indicating at what batches a state
1172-
point file should be written.
1173-
1174-
*Default*: Last batch only
1175-
11761161
--------------------------
11771162
``<source_point>`` Element
11781163
--------------------------
@@ -1222,6 +1207,32 @@ attributes/sub-elements:
12221207

12231208
*Default*: false
12241209

1210+
-------------------------
1211+
``<state_point>`` Element
1212+
-------------------------
1213+
1214+
The ``<state_point>`` element indicates at what batches a state point file
1215+
should be written. A state point file can be used to restart a run or to get
1216+
tally results at any batch. The default behavior when using this tag is to
1217+
write out the source bank in the state_point file. This behavior can be
1218+
customized by using the ``<source_point>`` element. This element has the
1219+
following attributes/sub-elements:
1220+
1221+
:batches:
1222+
A list of integers separated by spaces indicating at what batches a state
1223+
point file should be written.
1224+
1225+
*Default*: Last batch only
1226+
1227+
--------------------
1228+
``<stride>`` Element
1229+
--------------------
1230+
1231+
The ``stride`` element is used to specify how many random numbers are allocated
1232+
for each source particle history.
1233+
1234+
*Default*: 152,917
1235+
12251236
------------------------------
12261237
``<surf_source_read>`` Element
12271238
------------------------------

docs/source/usersguide/processing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ VTK Mesh File Generation
9797
------------------------
9898

9999
VTK files of OpenMC meshes can be created using the
100-
:meth:`openmc.Mesh.write_data_to_vtk` method. Data can be applied to the
100+
:meth:`openmc.Mesh.write_data_to_vtk` method. This method supports several VTK
101+
formats depending on the mesh type. Structured meshes
102+
(:class:`~openmc.RegularMesh`, :class:`~openmc.RectilinearMesh`,
103+
:class:`~openmc.CylindricalMesh`, and :class:`~openmc.SphericalMesh`) can be
104+
exported to legacy VTK format (``.vtk``). The :class:`~openmc.UnstructuredMesh`
105+
class supports VTK unstructured grid formats (``.vtu``) as well as an HDF5-based
106+
format (``.vtkhdf``) that does not require the ``vtk`` module to write.
107+
108+
Data can be applied to the
101109
elements of the resulting mesh from mesh filter objects. This data can be
102110
provided either as a flat array or, in the case of structured meshes
103111
(:class:`~openmc.RegularMesh`, :class:`~openmc.RectilinearMesh`,

include/openmc/bank.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,24 @@ extern vector<vector<double>> ifp_fission_lifetime_bank;
3434

3535
extern vector<int64_t> progeny_per_particle;
3636

37+
extern SharedArray<SourceSite> shared_secondary_bank_read;
38+
extern SharedArray<SourceSite> shared_secondary_bank_write;
39+
3740
} // namespace simulation
3841

3942
//==============================================================================
4043
// Non-member functions
4144
//==============================================================================
4245

43-
void sort_fission_bank();
46+
void sort_bank(SharedArray<SourceSite>& bank, bool is_fission_bank);
4447

4548
void free_memory_bank();
4649

4750
void init_fission_bank(int64_t max);
4851

52+
int64_t synchronize_global_secondary_bank(
53+
SharedArray<SourceSite>& shared_secondary_bank);
54+
4955
} // namespace openmc
5056

5157
#endif // OPENMC_BANK_H

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)