mhs_fenicsx is a FEniCSx extension for thermal modeling of Moving Heat Source (MHS) problems,
with a particular focus on Laser Powder Bed Fusion (LPBF).
While support for higher level discretizations is reduced (default is P1 / Q1 elements, Backward-Euler), this repository implements specialized functionality, including:
- Multi-time-step methods see Slimani et al. 2026
basic-demo-ss.mp4
3d-lpbf-substepping.mp4
- Moving subdomain methods, see Slimani et al. 2024
basic-demo-css.mp4
- Monolithic and staggered multi-mesh domain decomposition
Supported physics:
- Heat diffusion
- Latent heat effects (both enthalpy-based and apparent heat capacity treatments)
- Convective and radiative heat transfer
- Thermal dependency of all parameters, including absorptivity
Available heat source profiles:
- Gaussian
- Gusarov
- Lumped volumetric source
Additive Manufacturing (AM) simulations are performed by starting from a mesh
representing the final build and restricting the computational domain to a subset
of active elements at each time step. Degrees of freedom (DOF) deactivation is handled
through the multiphenicsx extension.
-
dolfinx (C++ and python modules)
-
multiphenicsx (C++ and python modules)
Note: The C++ module of multiphenicsx is not installed when using the main branch.
You must install this fork.
Detailed build instructions are reproducible from the Dockerfile.
A pre-built Docker image for linux/amd64 is available. The recommended workflow is to clone this repository locally and launch a container inside it:
docker pull ordinaryslim/mhs_fenicsx:latest
git clone https://github.com/ordinary-slim/mhs_fenicsx
docker run --rm --network=host --shm-size=512m -ti -v $(realpath mhs_fenicsx):/root/shared/ -w /root/shared --entrypoint /bin/bash ordinaryslim/mhs_fenicsx:latestOnce inside the container, you can run the provided examples and tests immediately. Result files will appear directly in your cloned repository folder on the host.
The numerical examples from Slimani et al. (2026) correspond to the following folders:
- 2D square track →
tests/2d_substepping/ - AMB2018-02 →
examples/amb2018_02/ - 3D LPBF →
examples/3d_lpbf_cube/
Each folder includes a dedicated README file with instructions
for running the simulation.
Simulations results are written to vtx or vtk files,
which can be opened in Paraview.
For vtx files, Paraview ≥ 5.13 is recommended to correctly visualize
element-wise fields (e.g. active_elements, material_id).
Postprocessing options can be controlled from the input.yaml file or directly in the Python
script. Available options include:
- Write output at each substep in
vtkformat. Enable via:
substepping_parameters:
writepos: True- Write additional solution fields. In the Python script, pass extra functions to writepos:
p.writepos(extra_funcs=[additional_functions])# Nanobind (c++) module
cmake -B build-dir -S ./cpp/
cmake --build build-dir
cmake --install build-dir
# python module
python3 -m pip -v install -e python --config-settings=build-dir="build" --no-build-isolationIf you found this library useful in academic or industry work, we appreciate your support if you consider:
- Starring the project on Github
- Citing the relevant paper(s):
Substepped and advected subdomain methods for part-scale LPBF modeling
@article{slimani2026,
title = {{S}ubstepped and advected subdomain methods for part-scale {LPBF} modeling},
journal = {Additive Manufacturing},
volume = {119},
pages = {105098},
year = {2026},
issn = {2214-8604},
doi = {https://doi.org/10.1016/j.addma.2026.105098},
url = {https://www.sciencedirect.com/science/article/pii/S2214860426000242},
author = {Mehdi Slimani and Michele Chiumenti and Miguel Cervera},
}A Chimera method for thermal part-scale metal additive manufacturing simulation
@article{slimani2024,
title = {A {C}himera method for thermal part-scale metal additive manufacturing simulation},
journal = {Finite Elements in Analysis and Design},
volume = {241},
pages = {104238},
year = {2024},
issn = {0168-874X},
doi = {https://doi.org/10.1016/j.finel.2024.104238},
url = {https://www.sciencedirect.com/science/article/pii/S0168874X2400132X},
author = {Mehdi Slimani and Miguel Cervera and Michele Chiumenti}
}