Overview
Description
gcrack is a 2D finite element solver for simulating crack propagation using Linear Elastic Fracture Mechanics.
It is built on top of fenicsx.
It has several non-classic features :
- crack propagation in anistropic media,
- indirect load control using path-following methods.
Installation
To run gcrack, install the required Python modules in a dedicated environment:
-
Create and activate a new conda environment:
conda create -n gcrack conda activate gcrack -
Install the required dependencies:
conda install -c conda-forge numpy sympy mpich python-gmsh fenics-dolfinx pyvista jax jaxlib=*=*cpu* -
Install gcrack:
pip install . # If you cloned the repo pip install gcrack # If you want to install from pypi
Hands-On: Test with Examples
The examples directory contains ready-to-run scripts.
Just follow these steps:
-
Navigate to the
examplesdirectory.cd gcrack/examples/example_name -
Activate the conda environment:
conda activate gcrack -
Run the provided
run.pyscript using the providedmakefile:make simulation -
Vizualize the results in the directory
results_YYY-MM-DD-HH-mm-ss/.
Usage
Requirements
To run a simulation, the only required file is a Python script (named run.py in the examples).
It contains the definition of a class inheriting from GCrackBase.
In this class, the methods to define the mesh (generate_mesh), to define the boundary conditions (e.g., define_controlled_displacements), and define the critical energy release rate (Gc) must be defined.
Running the Solver
Once the Python script is define, one only need to call the method GCrackBase.run to start the resolution.
-
Activate the
gcrackenvironment:conda activate gcrack -
Run the solver:
python run.py
Notes
-
On some Linux distributions, set
OMP_NUM_THREADS=1to prevent FEniCSx from using all available threads:OMP_NUM_THREADS=1 python run.py
Outputs
Results are saved in the results subdirectory.
Two types of file are exported:
- The displacement fields are saved in
VTKfiles (with the extension.pvd). - The scalar outputs (displacement/force measures, stress intensity factors, etc.) are saved in the
results.csvCSV file.