Skip to content
Draft
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
53 changes: 51 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ on:
jobs:
main:
name: |
libMesh=${{ matrix.libmesh }};MOAB=${{ matrix.moab }}
libMesh=${{ matrix.libmesh }};MOAB=${{ matrix.moab }}; mfem=${{ matrix.mfem }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
libmesh: [true, false]
moab: [true, false]
mfem: [true, false]
exclude:
- moab: false
libmesh: false
Comment on lines 17 to 23

@Waqar-ukaea Waqar-ukaea Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add an exclude for mfem too:

```suggestion
matrix:
libmesh: [true, false]
moab: [true, false]
        mfem: [true, false]
exclude:
- moab: false
libmesh: false
mfem: false

Currently we are excluding the case moab=false, libmesh=false, mfem=true but this change should ensure that job runs too

mfem: false

steps:
- name: Checkout
Expand Down Expand Up @@ -81,6 +83,15 @@ jobs:
cd libmesh
git checkout v1.7.0

- name: mfem Clone
if: ${{ matrix.mfem }}
shell: bash
run: |
cd ~
git clone https://github.com/mfem/mfem.git
cd mfem
git checkout v4.9

- name: OpenMP Environment Variables
run: |
echo "OMP_NUM_THREADS=1" >> $GITHUB_ENV
Expand All @@ -97,6 +108,11 @@ jobs:
# Enforce that we're using the debug build of libMesh
echo "METHOD=dbg" >> $GITHUB_ENV

- name: mfem Environment Variables
if: ${{ matrix.mfem }}
run: |
echo "MFEM_SHA"=$(cd ~/mfem && git rev-parse HEAD) >> $GITHUB_ENV

- name: MOAB Cache
if: ${{ matrix.moab }}
id: moab-cache
Expand All @@ -117,6 +133,16 @@ jobs:
path: ~/LIBMESH
key: libmesh-${{ runner.os }}-${{ env.cache-name }}-${{ env.LIBMESH_SHA }}

# - name: mfem Cache
# if: ${{ matrix.mfem }}
# id: mfem-cache
# uses: actions/cache@v3
# env:
# cache-name: mfem-cache
# with:
# path: ~/mfem
# key: mfem-${{ runner.os }}-${{ env.cache-name }}-${{ env.MFEM_SHA }}

- if: ${{ matrix.moab && steps.moab-cache.outputs.cache-hit != 'true' }}
name: Build MOAB
run: |
Expand All @@ -141,6 +167,23 @@ jobs:
make -j4
sudo make install

- if: ${{ matrix.mfem && steps.mfem-cache.outputs.cache-hit != 'true' }}
name: Build mfem
shell: bash
run: |
# first let's get netcdf
sudo apt-get update
sudo apt-get install -y libnetcdf-dev libhdf5-dev
cd ~
cd mfem
git checkout v4.9
mkdir build
cd build
# manually entering the hdf5 dir since cmake can't find it on its own
cmake .. -DMFEM_USE_HYPRE=OFF -DMFEM_USE_NETCDF=ON -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug -DHDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial -DBUILD_SHARED_LIBS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
make -j4
sudo make install

- name: Build
shell: bash
run: |
Expand All @@ -157,7 +200,13 @@ jobs:
fi
CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}$HOME/MOAB"
fi
cmake .. -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" -DCMAKE_INSTALL_PREFIX=$HOME/opt -DXDG_ENABLE_MOAB=${{ matrix.moab && 'ON' || 'OFF' }} -DXDG_ENABLE_LIBMESH=${{ matrix.libmesh && 'ON' || 'OFF' }}
if [ "${{ matrix.mfem }}" = 'true' ]; then
if [ -n "$CMAKE_PREFIX_PATH" ]; then
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;"
fi
CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}$HOME/mfem/install"
fi
cmake .. -DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" -DCMAKE_INSTALL_PREFIX=$HOME/opt -DXDG_ENABLE_MOAB=${{ matrix.moab && 'ON' || 'OFF' }} -DXDG_ENABLE_LIBMESH=${{ matrix.libmesh && 'ON' || 'OFF' }} -DXDG_ENABLE_MFEM=${{ matrix.mfem && 'ON' || 'OFF' }}
make -j4 install

- name: Test
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bld
build
build*
.vscode
docs/_build
docs/Doxyfile
.vscode
*.jou
29 changes: 28 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ if (NOT MOAB_USE_HDF5)
endif()
endif()

#===============================================================================
# MFEM
#===============================================================================
if (XDG_ENABLE_MFEM)
find_package(MFEM REQUIRED HINTS ${MFEM_DIR})
if (NOT MFEM_FOUND)
message(FATAL_ERROR "MFEM package was not found")
endif()
message(STATUS "Found MFEM ${MFEM_VERSION} at ${MFEM_DIR}")
endif()

if (XDG_ENABLE_EMBREE)
# find Embree for CPU ray tracing

Expand Down Expand Up @@ -167,10 +178,11 @@ endif()


# Ensure at least one mesh backend is enabled
if (NOT XDG_ENABLE_MOAB AND NOT XDG_ENABLE_LIBMESH)
if (NOT XDG_ENABLE_MOAB AND NOT XDG_ENABLE_LIBMESH AND NOT XDG_ENABLE_MFEM)
message(FATAL_ERROR
"No mesh backend enabled. Enable at least one of:\n"
" -DXDG_ENABLE_MOAB=ON\n"
" -DXDG_ENABLE_MFEM=ON\n"
" -DXDG_ENABLE_LIBMESH=ON")
endif()

Expand Down Expand Up @@ -240,6 +252,13 @@ src/moab/metadata.cpp
)
endif()

if (XDG_ENABLE_MFEM)
list(APPEND xdg_sources
# MFEM
src/mfem/mesh_manager.cpp
)
endif()

#===============================================================================
# RPATH information (from OpenMC)
#===============================================================================
Expand Down Expand Up @@ -314,6 +333,10 @@ if (XDG_ENABLE_LIBMESH)
target_compile_definitions(xdg PUBLIC XDG_ENABLE_LIBMESH)
endif()

if (XDG_ENABLE_MFEM)
target_compile_definitions(xdg PUBLIC XDG_ENABLE_MFEM)
endif()

if (XDG_ENABLE_EMBREE)
target_compile_definitions(xdg PUBLIC XDG_ENABLE_EMBREE)
endif()
Expand Down Expand Up @@ -369,6 +392,10 @@ if (XDG_ENABLE_MOAB)
target_link_libraries(xdg PRIVATE MOAB)
endif()

if (XDG_ENABLE_MFEM)
target_link_libraries(xdg PUBLIC mfem)
endif()

#=================================================================
# Installation & Packaging
#=================================================================
Expand Down
9 changes: 9 additions & 0 deletions include/xdg/bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ bool operator ==(const BoundingBox& other) {
max_z == other.max_z;
}

void update(const double* v) {
min_x = std::min(min_x, v[0]);
min_y = std::min(min_y, v[1]);
min_z = std::min(min_z, v[2]);
max_x = std::max(max_x, v[0]);
max_y = std::max(max_y, v[1]);
max_z = std::max(max_z, v[2]);
}

void update(const Vertex& v) {
min_x = std::min(min_x, v.x);
min_y = std::min(min_y, v.y);
Expand Down
6 changes: 4 additions & 2 deletions include/xdg/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum class Sense {
enum class MeshLibrary {
MOCK = 0, // mock testing interface
MOAB,
LIBMESH
LIBMESH,
MFEM
};

// Ray Tracing library identifier
Expand All @@ -61,7 +62,8 @@ static const std::map<MeshLibrary, std::string> MESH_LIB_TO_STR =
{
{MeshLibrary::MOCK, "MOCK"},
{MeshLibrary::MOAB, "MOAB"},
{MeshLibrary::LIBMESH, "LIBMESH"}
{MeshLibrary::LIBMESH, "LIBMESH"},
{MeshLibrary::MFEM, "MFEM"}
};

static const std::map<RTLibrary, std::string> RT_LIB_TO_STR =
Expand Down
2 changes: 1 addition & 1 deletion include/xdg/libmesh/mesh_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class LibMeshManager : public MeshManager {

int num_vertices() const override;

std::vector<MeshID> get_volume_elements(MeshID volume) const;
std::vector<MeshID> get_volume_elements(MeshID volume) const override;

std::vector<MeshID> get_surface_faces(MeshID surface) const override;

Expand Down
4 changes: 4 additions & 0 deletions include/xdg/mesh_managers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
#ifdef XDG_ENABLE_LIBMESH
#include "xdg/libmesh/mesh_manager.h"
#endif

#ifdef XDG_ENABLE_MFEM
#include "xdg/mfem/mesh_manager.h"
#endif
Loading
Loading