Skip to content

sclaus2/CutFEMx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CutFEMx Logo

CutFEMx is a cut finite element library for FEniCSx. It is developed to support cut finite element methods as described in

@article{CutFEM2015,
  title={CutFEM: discretizing geometry and partial differential equations},
  author={Burman, Erik and Claus, Susanne and Hansbo, Peter and Larson, Mats G and Massing, Andr{\'e}},
  journal={International Journal for Numerical Methods in Engineering},
  volume={104},
  number={7},
  pages={472--501},
  year={2015},
  publisher={Wiley Online Library}
}

The current version supports FEniCSx 0.9 with a customised ffcx version for runtime quadrature at ffcx-runtime.

SVG Image

image info Poisson problem in a circular domain described by a level set function.

Features

  • Unfitted Discretization: Solve PDEs on geometries defined by level set functions without remeshing.
  • Runtime Quadrature: Automatically generates high-order quadrature rules on cut elements using the CutCells library and a custom FFCX backend.
  • Stabilization: Implements Ghost Penalty stabilization to ensure condition number robustness independent of cut geometry..
  • Parallel Support: Fully compatible with MPI for large-scale distributed simulations.

Installation Instructions

The CutFEMx library requires a FEniCSx installation version 0.9.0 with an extended version of ffcx from here git clone git@github.com:sclaus2/ffcx-runtime-0.9.0.git . CutFEMx also requires CutCells. The installation instructions using conda to manage the dependencies are detailed below. Make sure to use python 3.12.

  1. Create and activate a new conda environment:

    conda create -n cutfemx
    conda activate cutfemx
  2. Install general packages required for the build:

    conda install -c conda-forge cxx-compiler cmake python pkg-config pip nanobind
  3. Install dependencies:

    conda install -c conda-forge numpy scipy sympy numba pyvista pytest
    conda install -c conda-forge blas blas-devel lapack libblas libcblas liblapack liblapacke libtmglib
    conda install -c conda-forge mpi mpich kahip libboost-devel parmetis libscotch libptscotch pugixml spdlog
    conda install -c conda-forge mpi4py petsc4py slepc4py scikit-build-core 
    conda install -c conda-forge 'hdf5=*=mpi*' 'petsc=*=*real*' 'slepc=*=*real*' 'libadios2=*=mpi*'
  4. Install Basix:

    git clone git@github.com:FEniCS/basix.git
    cd basix
    git checkout v0.9.0
    
    cd cpp
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" -B build-dir -S .
    cmake --build build-dir
    cmake --install build-dir
    
    cd ../python
    pip install .
  5. Install UFL:

    git clone https://github.com/FEniCS/ufl.git
    cd ufl
    git checkout 2024.2.0
    pip install .
  6. Install runtime integral extended FFCX:

    git clone git@github.com:sclaus2/ffcx-runtime-0.9.0.git
    cd ffcx
    pip install .
  7. Install DOLFINx:

    git clone git@github.com:FEniCS/dolfinx.git
    cd dolfinx
    git checkout v0.9.0
    
    cd cpp
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" -B build-dir -S .
    cmake --build build-dir
    cmake --install build-dir
    
    cd ../python
    pip install -r build-requirements.txt
    pip install --check-build-dependencies --no-build-isolation .
  8. Install CutCells:

    git clone git@github.com:sclaus2/cutcells.git
    
    cd cutcells/cpp
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" -B build-dir -S .
    cmake --build build-dir
    cmake --install build-dir
    
    cd ../python
    pip install .
  9. Install CutFEMx:

    git clone https://github.com/sclaus2/CutFEMx
    
    cd CutFEMx
    export CMAKE_PREFIX_PATH=$CONDA_PREFIX
    export CMAKE_INSTALL_PREFIX=$CONDA_PREFIX
    
    # Install CutFEMx  (triggers C++ build via scikit-build-core)
    python -m pip install --check-build-dependencies --no-build-isolation -v .

Available Demos

The python/demo directory contains several examples illustrating the usage of CutFEMx:

  • Poisson Equation (demo_cut_poisson.py): Solving the Poisson equation on a circular domain using Nitsche's method and ghost penalty stabilization.
  • Stokes Flow (demo_stokes.py): Simulating Stokes flow around a cylinder using P1-P1 elements. Features include:
    • Global Continuous Interior Penalty (CIP) stabilization for pressure.
    • Ghost penalty stabilization for velocity.
    • VTX output for parallel visualization.
  • Moving Domain (demo_moving_poisson.py): solving a time-dependent problem with a moving interface, demonstrating how to update quadrature rules and integration domains dynamically at each time step.

About

Cut finite elements for FEniCSx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published