Skip to content

ordinary-slim/mhs_fenicsx

Repository files navigation

mhs_fenicsx

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:

basic-demo-ss.mp4

3d-lpbf-substepping.mp4

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.

Dependencies

  • 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.

Docker

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:latest

Once 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.

Reproducibility

The numerical examples from Slimani et al. (2026) correspond to the following folders:

  1. 2D square tracktests/2d_substepping/
  2. AMB2018-02examples/amb2018_02/
  3. 3D LPBFexamples/3d_lpbf_cube/

Each folder includes a dedicated README file with instructions for running the simulation.

Postprocessing

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 vtk format. 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])

Build instructions

# 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-isolation

Citations

If you found this library useful in academic or industry work, we appreciate your support if you consider:

  1. Starring the project on Github
  2. 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}
}

About

Moving heat source simulations in FEniCSx, targeted to LPBF modeling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages