This repository contains an implementation of reinitialization methods for the Level-Set method, using FEniCSx and CutFEMx.
main.py: Main entry point for the reinitialization process.data.py: Configuration file for simulation parameters.src/: Contains the main source code (library).reinitialization.py: Main class for reinitialization.reinitialization_mpi.py: MPI-compatible version.mesh_generation.py: Mesh generation utilities.geometry_ls.py: Geometry definitions and noise application.compute_error.py: Error computation functions.
scripts/: Execution and demonstration scripts.demo_convergence_2d.py: Convergence study on a 2D case (circle).demo_3d.py: 3D demonstration (torus/sphere).demo_mpi.py: Demonstration using MPI.
requirements.txt: List of Python dependencies.
To run the standard reinitialization process:
- Configure your simulation parameters in
data.py(mesh size, level set function, noise, etc.). - Run the main script:
python3 main.pyResults will be saved in the res/ directory.
It is recommended to use a Conda environment with FEniCSx installed.
# Example installation with Conda
conda create -n fenicsx-env
conda activate fenicsx-env
conda install -c conda-forge fenics-dolfinx mpich pyvista matplotlib
pip install -r requirements.txt
# Install cutfemx
# Please refer to the official repository for installation instructions:
# https://github.com/sclaus2/CutFEMxMake sure the project root folder is in your PYTHONPATH or run the scripts from the root as follows.
To run the demonstrations, execute the scripts from the project root:
python3 scripts/demo_convergence_2d.pypython3 scripts/demo_3d.pympirun -n 4 python3 scripts/demo_mpi.pyAmina El Bachari 2025 ONERA and MINES Paris - PSL
If you use this code in your research, please cite the following paper:
A predictor-corrector scheme for approximating signed distances using finite element methods Amina El Bachari, Johann Rannou, Vladislav Yastrebov, Pierre Kerfriden, Susanne Claus Preprint, 2025 Read the paper