Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
bb7f530
Initial implementation of the XDG mesh
pshriwise Feb 3, 2026
e722e0d
Accounting for XDGMesh when creating MeshFilters
pshriwise Feb 4, 2026
04b9573
Updating call to XDG for element connectivity
pshriwise Feb 6, 2026
b7b5924
Adding XDG unstructured mesh tallies mirroring those of the current u…
pshriwise Feb 9, 2026
752fae5
Use explicit name for kwarg for clarity
pshriwise Feb 10, 2026
0fb73d0
Report XDG availability in build info
pshriwise Mar 13, 2026
1ceba8d
Only set libmesh comms in XDG if it has libMesh enabled
pshriwise Mar 13, 2026
834701c
Adding XDG to CI builds. MOAB and libMesh should be built if XDG is e…
pshriwise Mar 13, 2026
4679ffb
Adding init files for proper test discovery with pytest
pshriwise Mar 13, 2026
c8313d6
Update submodules when cloning XDG in CI
pshriwise Mar 13, 2026
1180069
Add XDG to the OpenMC CMake config file
pshriwise Mar 15, 2026
106ea52
Adding more test scenarios for XDG meshes
pshriwise Mar 15, 2026
49f9c65
More descriptive test labels
pshriwise Mar 15, 2026
14b9890
Returning const string ref for mesh filename
pshriwise Mar 18, 2026
0638957
C++ style
pshriwise Mar 18, 2026
d15dba6
Apply suggestions from @nuclearkevin
pshriwise Mar 21, 2026
ab183b2
Fix includes in xdg.h/cpp
paulromano May 21, 2026
aceaf56
Add some Doxygen comments in xdg.h
paulromano May 21, 2026
72578de
Reorder methods
paulromano May 21, 2026
657fe94
Python imports
paulromano May 21, 2026
5ab893b
Remove extra line
paulromano May 21, 2026
a1fc3b6
Combined two #ifdefs
paulromano May 21, 2026
1797bf5
Rename local variable to center to avoid same name as method
paulromano May 22, 2026
e29b315
Test updates
paulromano May 22, 2026
4932c75
Use pathlib in test
paulromano May 22, 2026
9913cff
Fix circular import
paulromano May 22, 2026
8fcddd7
Lump unstructured mesh capabilities into one CI matrix parameter
pshriwise Jun 9, 2026
41e96ca
A start on @paulromano's PR comments
pshriwise Jun 9, 2026
5fccdd4
Adressing more comments from @paulromano
pshriwise Jun 10, 2026
74e07f5
Update XDG and unstructured mesh tests to use a distributed spherical…
pshriwise Jun 10, 2026
b4ddd48
Report error for invalid mesh library type in XDG mesh
pshriwise Jun 10, 2026
021381f
Classify XDG as its own mesh type on the C++ side
pshriwise Jun 11, 2026
da1b67f
Include Embree apt package in CI for XDG
pshriwise Jul 3, 2026
3cec4e2
C++ format
pshriwise Jul 3, 2026
d570e85
Correct test matrix attribute. Build XDG with tools enabled in CI.
pshriwise Jul 3, 2026
9910364
Update CI matrix to remove additional DAGMC/LibMesh jobs
pshriwise Jul 8, 2026
34c66dd
Additions so that XDG meshes can be postprocessed correctly
pshriwise Jul 8, 2026
2bea0b3
Run XDG tests if XDG is enabled, do not filter based on other umesn l…
pshriwise Jul 15, 2026
2d8a708
Add support for length multiplier in the XDGMesh class
pshriwise Jul 16, 2026
ba5908d
XDGMesh Python class now inheriting from UnstructuredMesh
pshriwise Jul 16, 2026
cc88d08
Fix C++ formatting
pshriwise Jul 16, 2026
b45bfdd
Using marker UnstructuredMesh.interface to enable direction to XDG me…
pshriwise Jul 17, 2026
cb4b90f
Remove xdg.py file. It is now unused
pshriwise Jul 17, 2026
644f86a
C++ formatting
pshriwise Jul 17, 2026
665b095
Remove other references to the XDGMesh Python class
pshriwise Jul 17, 2026
b057de3
Correct attr name for unstructured mesh interface
pshriwise Jul 17, 2026
d898d86
Other instances of consolidating xdg mesh support into the Unstructur…
pshriwise Aug 11, 2026
5a65353
Update regression tests to include XDG mesh type
pshriwise Aug 11, 2026
07e85e7
Including XDG hex mesh tests
pshriwise Aug 19, 2026
5cb30d8
Link XDG to libopenmc_objects target
pshriwise Aug 21, 2026
937685c
Add XDG option to the CAPI feature_enabled function
pshriwise Aug 21, 2026
07064a4
Adjust incoming position for bins_crossed if length multiplier is set
pshriwise Aug 21, 2026
29a0499
Differentiate between interface and library for XDG mesh
pshriwise Sep 1, 2026
5d534e8
Update test file script and inputs.
pshriwise Sep 1, 2026
25be037
C++ style updates
pshriwise Sep 1, 2026
a76f77a
Expanding unit tests to include xdg where appropriate
pshriwise Sep 1, 2026
2711ba3
Check mesh library support before getting to XDG constructor
pshriwise Sep 1, 2026
83055b6
C++ style updates
pshriwise Sep 1, 2026
9da79ac
Update CMake option description for XDG
pshriwise Sep 8, 2026
99002a3
Fix unstructured mesh interface round trips
paulromano Sep 22, 2026
9eae268
Preserve unstructured mesh interface in statepoints
paulromano Sep 22, 2026
b40d46a
Reject unavailable unstructured mesh interfaces
paulromano Sep 22, 2026
78b7444
Fix default XDG mesh bounding box scaling
paulromano Sep 22, 2026
04fdb60
Test XDG libMesh tracklength tallies
paulromano Sep 22, 2026
51478f9
Clear libMesh pointers during finalization
paulromano Sep 22, 2026
4e50801
Use public feature query for XDG tests
paulromano Sep 22, 2026
42771fe
Guard XDG element sampling against non-tets
paulromano Sep 22, 2026
b04d5b5
Document XDG mesh configuration
paulromano Sep 22, 2026
bbd95d0
Revert "Test XDG libMesh tracklength tallies"
paulromano Sep 22, 2026
6d8032a
Exercise XDG mesh source bounds without native backends
paulromano Sep 22, 2026
16324c3
Remove unsupported legacy XDG mesh type
paulromano Sep 22, 2026
6bd18b0
Enable XDG libMesh tracklength regression cases
paulromano Sep 23, 2026
a22fa89
Consolidate XDG and unstructured mesh tally regressions
paulromano Sep 23, 2026
e822bc4
Small updates in unstructured mesh test
paulromano Sep 23, 2026
cf5823a
Align mesh tally reshape with develop
paulromano Sep 23, 2026
7b396d6
Compute number of surface bins accounting for element type
pshriwise Sep 25, 2026
f1ccb15
Correct element type names
pshriwise Sep 25, 2026
add47ff
Correct method name
pshriwise Sep 25, 2026
acbd59e
Initialize XDG surface bins after loading the mesh
paulromano Sep 25, 2026
554aaed
Infer unstructured mesh libraries from filename extensions
paulromano Sep 25, 2026
a97a945
Remove leftover compatibility code
paulromano Sep 26, 2026
2836bf1
Replace unstructured mesh snapshots with direct comparisons
paulromano Sep 26, 2026
4f59370
Merge develop into pr-3889
paulromano Sep 27, 2026
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
31 changes: 14 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ jobs:
python-version: ["3.12"]
mpi: [n, y]
omp: [n, y]
dagmc: [n]
libmesh: [n]
event: [n]

include:
Expand All @@ -110,33 +108,26 @@ jobs:
- python-version: "3.14t"
omp: n
mpi: n
- dagmc: y
python-version: "3.12"
mpi: y
omp: y
- libmesh: y
python-version: "3.12"
mpi: y
omp: y
- libmesh: y
python-version: "3.12"
- python-version: "3.12"
omp: n
mpi: n
omp: y
umesh_libs: y
- event: y
python-version: "3.12"
omp: y
mpi: n
name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }},
mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }},
libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }}"
mpi=${{ matrix.mpi }}, umesh_libs=${{ matrix.umesh_libs }},
event=${{ matrix.event }}"

env:
MPI: ${{ matrix.mpi }}
PHDF5: ${{ matrix.mpi }}
OMP: ${{ matrix.omp }}
DAGMC: ${{ matrix.dagmc }}
DAGMC: ${{ matrix.umesh_libs }}
XDG: ${{ matrix.umesh_libs }}
EVENT: ${{ matrix.event }}
LIBMESH: ${{ matrix.libmesh }}
LIBMESH: ${{ matrix.umesh_libs }}
NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX"
OPENBLAS_NUM_THREADS: 1
PYTEST_ADDOPTS: --cov=openmc --cov-report=lcov:coverage-python.lcov
Expand Down Expand Up @@ -196,6 +187,12 @@ jobs:
sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich

- name: Optional apt dependencies for XDG
shell: bash
if: ${{ matrix.umesh_libs == 'y' }}
run: |
sudo apt install -y libembree-dev

- name: install
shell: bash
run: |
Expand Down
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ option(OPENMC_BUILD_TESTS "Build tests"
option(OPENMC_ENABLE_PROFILE "Compile with profiling flags" OFF)
option(OPENMC_ENABLE_COVERAGE "Compile with coverage analysis flags" OFF)
option(OPENMC_USE_DAGMC "Enable support for DAGMC (CAD) geometry" OFF)
option(OPENMC_USE_XDG "Enable support for XDG mesh interfaces" OFF)
option(OPENMC_USE_LIBMESH "Enable support for libMesh unstructured mesh tallies" OFF)
option(OPENMC_USE_MPI "Enable MPI" OFF)
option(OPENMC_USE_UWUW "Enable UWUW" OFF)
Expand Down Expand Up @@ -173,6 +174,15 @@ if(OPENMC_USE_DAGMC)
endif()
endif()

#===============================================================================
# XDG Mesh and Geometry Support
#===============================================================================

if(OPENMC_USE_XDG)
find_package(XDG REQUIRED PATH_SUFFIXES lib/cmake)
message(STATUS "Found XDG: ${XDG_DIR} (version ${XDG_VERSION})")
endif()

#===============================================================================
# libMesh Unstructured Mesh Support
#===============================================================================
Expand Down Expand Up @@ -392,6 +402,7 @@ list(APPEND libopenmc_SOURCES
src/string_utils.cpp
src/summary.cpp
src/surface.cpp
src/xdg.cpp
src/tallies/derivative.cpp
src/tallies/filter.cpp
src/tallies/filter_azimuthal.cpp
Expand Down Expand Up @@ -523,6 +534,11 @@ elseif(OPENMC_USE_UWUW)
message(FATAL_ERROR "DAGMC must be enabled when UWUW is enabled.")
endif()

if(OPENMC_USE_XDG)
target_compile_definitions(libopenmc_objects PRIVATE OPENMC_XDG_ENABLED)
target_link_libraries(libopenmc_objects PUBLIC xdg::xdg)
endif()

if(OPENMC_USE_LIBMESH)
target_compile_definitions(libopenmc_objects PRIVATE OPENMC_LIBMESH_ENABLED)
target_link_libraries(libopenmc_objects PUBLIC PkgConfig::LIBMESH)
Expand Down
4 changes: 4 additions & 0 deletions cmake/OpenMCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if("@PNG_FOUND@")
find_dependency(PNG)
endif()

if(@OPENMC_USE_XDG@)
find_dependency(XDG REQUIRED HINTS @XDG_DIR@)
endif()

if(@OPENMC_USE_MPI@)
find_dependency(MPI REQUIRED)
endif()
Expand Down
6 changes: 5 additions & 1 deletion docs/source/io_formats/statepoint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ The current version of the statepoint file format is 18.2.
- **filename** (*char[]*) -- Name of the mesh file.
- **library** (*char[]*) -- Mesh library used to represent the
mesh ("moab" or "libmesh").
- **length_multiplier** (*double*) Scaling factor applied to the mesh.
- **interface** (*char[]*) -- Interface used to operate on the
mesh ("native" or "xdg"). This
dataset is omitted for the native
interface.
- **length_multiplier** (*double*) -- Scaling factor applied to the mesh.
- **options** (*char[]*) -- Special options that control spatial
search data structures used.
- **volumes** (*double[]*) -- Volume of each mesh cell.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/io_formats/tallies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ attributes/sub-elements:
The mesh library used to represent an unstructured mesh. This can be either
"moab" or "libmesh". (For unstructured mesh only.)

:interface:
The interface used to operate on an unstructured mesh. This can be either
"native" or "xdg". The default is "native". (For unstructured mesh only.)

:options:
Special options that control spatial search data structures used. (For
unstructured mesh using MOAB only)
Expand Down
13 changes: 13 additions & 0 deletions docs/source/usersguide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ Prerequisites
Note that libMesh is most commonly compiled with MPI support. If that
is the case, then OpenMC should be compiled with MPI support as well.

* XDG_ interface for unstructured mesh operations

XDG provides a common interface for unstructured mesh operations backed
by MOAB or libMesh. The desired mesh libraries must be enabled when XDG
is built. To enable the XDG interface in OpenMC, specify the XDG
installation in ``CMAKE_PREFIX_PATH``::

cmake -DOPENMC_USE_XDG=on -DCMAKE_PREFIX_PATH=/path/to/xdg/installation ..

.. _gcc: https://gcc.gnu.org/
.. _CMake: https://cmake.org
.. _OpenMPI: https://www.open-mpi.org
Expand All @@ -372,6 +381,7 @@ Prerequisites
.. _DAGMC: https://svalinn.github.io/DAGMC/index.html
.. _MOAB: https://bitbucket.org/fathomteam/moab
.. _libMesh: https://libmesh.github.io/
.. _XDG: https://github.com/xdg-org/xdg
.. _libpng: http://www.libpng.org/pub/png/libpng.html
.. _MCPL: https://github.com/mctools/mcpl
.. _NCrystal: https://github.com/mctools/ncrystal
Expand Down Expand Up @@ -450,6 +460,9 @@ OPENMC_USE_DAGMC
OPENMC_USE_LIBMESH
Enables the use of unstructured mesh tallies with libMesh_. (Default: off)

OPENMC_USE_XDG
Enables the XDG_ interface for unstructured mesh tallies. (Default: off)

OPENMC_USE_MPI
Turns on compiling with MPI (Default: off). For further information on MPI
options, please see the `FindMPI.cmake documentation
Expand Down
46 changes: 42 additions & 4 deletions include/openmc/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ class Mesh {

// Factory method for creating meshes from either an XML node or HDF5 group
template<typename T>
static const std::unique_ptr<Mesh>& create(
T dataset, const std::string& mesh_type, const std::string& mesh_library);
static const std::unique_ptr<Mesh>& create(T dataset);

// Methods
//! Perform any preparation needed to support point location within the mesh
Expand Down Expand Up @@ -739,15 +738,18 @@ class SphericalMesh : public PeriodicStructuredMesh {
class UnstructuredMesh : public Mesh {

public:
template<typename T>
static std::unique_ptr<UnstructuredMesh> create(T dataset);

// Constructors
UnstructuredMesh() { n_dimension_ = 3; };
UnstructuredMesh(pugi::xml_node node);
UnstructuredMesh(hid_t group);

static const std::string mesh_type;
virtual std::string get_mesh_type() const override;

// Overridden Methods
virtual std::string get_mesh_type() const override;

void surface_bins_crossed(Position r0, Position r1, const Direction& u,
vector<int>& bins) const override;
Expand All @@ -756,6 +758,8 @@ class UnstructuredMesh : public Mesh {

std::string bin_label(int bin) const override;

const std::string& interface() const { return interface_; }

// Methods

//! Add a variable to the mesh instance
Expand Down Expand Up @@ -800,6 +804,9 @@ class UnstructuredMesh : public Mesh {
//! Get the library used for this unstructured mesh
virtual std::string library() const = 0;

//! Get the mesh filename
virtual const std::string& filename() const { return filename_; }

// Data members
bool output_ {
true}; //!< Write tallies onto the unstructured mesh at the end of a run
Expand All @@ -826,12 +833,43 @@ class UnstructuredMesh : public Mesh {
//! \param[in] coords Coordinates of the tetrahedron
//! \param[in] seed Random number generation seed
//! \return Sampled position within the tetrahedron
Position sample_tet(std::array<Position, 4> coords, uint64_t* seed) const;
template<typename V>
Position sample_tet(span<V> coords, uint64_t* seed) const
{
// Uniform distribution
double s = prn(seed);
double t = prn(seed);
double u = prn(seed);

// From PyNE implementation of moab tet sampling C. Rocchini & P. Cignoni
// (2000) Generating Random Points in a Tetrahedron, Journal of Graphics
// Tools, 5:4, 9-12, DOI: 10.1080/10867651.2000.10487528
if (s + t > 1) {
s = 1.0 - s;
t = 1.0 - t;
}
if (s + t + u > 1) {
if (t + u > 1) {
double old_t = t;
t = 1.0 - u;
u = 1.0 - s - old_t;
} else if (t + u <= 1) {
double old_s = s;
s = 1.0 - t - u;
u = old_s + t + u - 1;
}
}
V result = s * (coords[1] - coords[0]) + t * (coords[2] - coords[0]) +
u * (coords[3] - coords[0]) + coords[0];
return {result[0], result[1], result[2]};
}

// Data members
double length_multiplier_ {
-1.0}; //!< Multiplicative factor applied to mesh coordinates
std::string options_; //!< Options for search data structures
std::string interface_ {
"native"}; //!< Name of the interface used for the mesh

//! Determine lower-left and upper-right bounds of mesh
void determine_bounds();
Expand Down
125 changes: 125 additions & 0 deletions include/openmc/xdg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#ifndef OPENMC_XDG_H
#define OPENMC_XDG_H

namespace openmc {
extern "C" const bool XDG_ENABLED;
}

#ifdef OPENMC_XDG_ENABLED

#include "xdg/xdg.h"

#include "openmc/mesh.h"
#include "openmc/position.h"
#include "openmc/xml_interface.h"

namespace openmc {

class XDGMesh : public UnstructuredMesh {

public:
//----------------------------------------------------------------------------
// Constructors
XDGMesh() = default;
XDGMesh(pugi::xml_node node);
XDGMesh(hid_t group);
XDGMesh(const std::string& filename, double length_multiplier = 1.0);
XDGMesh(std::shared_ptr<xdg::XDG> external_xdg);

static const std::string mesh_interface;

//----------------------------------------------------------------------------
// Methods

//! Get the underlying XDG instance
//!
//! \return Shared pointer to the XDG instance
const std::shared_ptr<xdg::XDG>& xdg_instance() const { return xdg_; }

//! Check whether a bin index is valid
//!
//! \param[in] bin Bin index to check
//! \return True if the bin index is in [0, n_bins())
bool bin_is_valid(int bin) const { return bin >= 0 && bin < n_bins(); }

//! Convert a mesh bin index to an XDG MeshID
//!
//! \param[in] bin Bin index to convert
//! \return XDG MeshID corresponding to the bin
xdg::MeshID bin_to_mesh_id(int bin) const;

//! Convert an XDG MeshID to a mesh bin index
//!
//! \param[in] id XDG MeshID to convert
//! \return Bin index corresponding to the MeshID, or -1 if invalid
int mesh_id_to_bin(xdg::MeshID id) const;

//! Get the name of the underlying mesh library
//!
//! \return Name of the mesh library being used in XDG
std::string library() const override;

//----------------------------------------------------------------------------
// Overridden Methods

//! Perform any preparation needed to support use in mesh filters
void prepare_for_point_location() override;

Position sample_element(int32_t bin, uint64_t* seed) const override;

void bins_crossed(Position r0, Position r1, const Direction& u,
vector<int>& bins, vector<double>& lengths) const override;

int get_bin(Position r) const override;

int n_bins() const override;

int n_surface_bins() const override;

std::pair<vector<double>, vector<double>> plot(
Position plot_ll, Position plot_ur) const override;

//! Add a score to the mesh instance
void add_score(const std::string& score) override {};

//! Remove all scores from the mesh instance
void remove_scores() override {};

//! Set data for a score
void set_score_data(const std::string& score, const vector<double>& values,
const vector<double>& std_dev) override {};

//! Write the mesh with any current tally data
void write(const std::string& base_filename) const override;

Position centroid(int bin) const override;

int n_vertices() const override;

Position vertex(int id) const override;

std::vector<int> connectivity(int id) const override;

//! Get the volume of a mesh bin
//
//! \param[in] bin Bin to return the volume for
//! \return Volume of the bin
double volume(int bin) const override;

private:
void initialize() override;

int n_surface_bins_ {0}; //!< Number of surface bins in the mesh

//----------------------------------------------------------------------------
// Private data members
std::shared_ptr<xdg::XDG> xdg_; //!< XDG instance
xdg::MeshLibrary mesh_library_ {
xdg::MeshLibrary::LIBMESH}; //!< Mesh library type
};

} // namespace openmc

#endif // OPENMC_XDG_ENABLED

#endif // OPENMC_XDG_H
Loading
Loading