This repository contains elasticity example applications built on top of the IgANet core.
The core repository provides the spline, collocation, multipatch, constraint, and network infrastructure. This repository adds concrete elasticity examples, example configurations, reference runs, result export, and visualization scripts.
This README is written for newcomers. It explains:
- where the important files are
- how to install the required dependencies
- how to configure and build the examples
- how to run the executables
- how to visualize the generated results
iganet-elasticity/
├── CMakeLists.txt
├── README.md
├── filedata/
│ ├── bone_simplified.xml
│ ├── five_patch_cantilever.xml
│ ├── two_cube_parametric.xml
│ └── two_patch_smoke.xml
├── results/
├── src/
│ ├── headers/
│ │ ├── lin_elasticity_multipatch_net.hpp
│ │ ├── lin_elasticity_net.hpp
│ │ └── lin_elasticity_utils.hpp
│ ├── utils/
│ │ ├── config.hpp
│ │ └── paths.hpp
│ ├── examples2D/
│ │ ├── singlePatch/
│ │ └── multiPatch/
│ └── examples3D/
│ ├── singlePatch/
│ └── multiPatch/
└── std_collocation_python/
src/examples2D/singlePatch/iganet_lin_elasticity_2D.cxxsrc/examples2D/singlePatch/iganet_lin_elasticity_2D_optimized.cxxsrc/examples2D/multiPatch/iganet_lin_elasticity_2D_multipatch_parametric.cxxsrc/examples3D/singlePatch/iganet_lin_elasticity_3D.cxxsrc/examples3D/singlePatch/iganet_lin_elasticity_3D_optimized.cxxsrc/examples3D/multiPatch/iganet_lin_elasticity_3D_multipatch_bone.cxxsrc/examples3D/multiPatch/iganet_lin_elasticity_3D_multipatch_parametrized.cxx
src/examples2D/singlePatch/sim_config_2D_single_patch.jsonsrc/examples2D/multiPatch/sim_config_2D_multi_patch.jsonsrc/examples3D/singlePatch/sim_config_3D_single_patch.jsonsrc/examples3D/multiPatch/sim_config_3D_multi_patch_bone.jsonsrc/examples3D/multiPatch/sim_config_3D_multi_patch_parametrized.json
src/examples2D/singlePatch/show_2D_single_patch.pysrc/examples2D/multiPatch/show_2D_multi_patch.pysrc/examples3D/singlePatch/show_3D_single_patch.pysrc/examples3D/multiPatch/show_3D_multi_patch_bone.py
src/headers/lin_elasticity_net.hppsrc/headers/lin_elasticity_multipatch_net.hppsrc/headers/lin_elasticity_utils.hpp
std_collocation_python/run_std_coll.py
Some examples call the Python reference solver automatically and append its data to the same JSON result file.
This repository depends on iganet.
The core is fetched with CMake FetchContent from GitHub. By default, CMake
uses the repository and branch configured in CMakeLists.txt.
You can override the branch, tag, or commit at configure time:
cmake -S . -B build \
-DTorch_DIR=$HOME/libtorch/share/cmake/Torch \
-DIGANET_CORE_GIT_TAG=your_branch_or_commitA local ../iganet checkout is not used automatically.
You need:
- a C++20 compiler
- CMake
>= 3.24 - Python
- LibTorch
For visualization, install these Python packages:
pip install numpy splinepy gustaf vedoFollow the same procedure as in the IgANet core README. The essential point is:
download a LibTorch build that matches your compiler ABI and then point CMake to
its Torch_DIR.
Example for Linux CPU builds, analogous to the core README:
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip -O libtorch.zip
unzip libtorch.zip -d $HOME/Then configure with:
cmake -S . -B build -DTorch_DIR=$HOME/libtorch/share/cmake/TorchIf you use a different LibTorch install location, adjust Torch_DIR
accordingly.
From the repository root:
cmake -S . -B build -DTorch_DIR=$HOME/libtorch/share/cmake/Torch
cmake --build build -j 16This builds all example executables directly into build/.
If you only want one target:
cmake --build build -j 16 --target iganet_lin_elasticity_2D
cmake --build build -j 16 --target iganet_lin_elasticity_2D_optimized
cmake --build build -j 16 --target iganet_lin_elasticity_2D_multipatch_parametric
cmake --build build -j 16 --target iganet_lin_elasticity_3D
cmake --build build -j 16 --target iganet_lin_elasticity_3D_optimized
cmake --build build -j 16 --target iganet_lin_elasticity_3D_multipatch_bone
cmake --build build -j 16 --target iganet_lin_elasticity_3D_multipatch_parametrizedIf you want CUDA, install a CUDA-enabled LibTorch build that matches your CUDA toolchain, then configure CMake with the matching CUDA settings.
Example:
cmake -S . -B build \
-DTorch_DIR=/path/to/libtorch/share/cmake/Torch \
-DCMAKE_CUDA_COMPILER=/path/to/nvcc \
-DCMAKE_CUDA_ARCHITECTURES=75 \
-DCUDA_TOOLKIT_ROOT_DIR=/path/to/cuda
cmake --build build -j 16The exact paths and architecture depend on your machine. CPU build is the default and should be your starting point.
Each executable reads its own config file from the matching example folder.
iganet_lin_elasticity_2Dsrc/examples2D/singlePatch/sim_config_2D_single_patch.json
iganet_lin_elasticity_2D_optimizedsrc/examples2D/singlePatch/sim_config_2D_single_patch.json
iganet_lin_elasticity_2D_multipatch_parametricsrc/examples2D/multiPatch/sim_config_2D_multi_patch.json
iganet_lin_elasticity_3Dsrc/examples3D/singlePatch/sim_config_3D_single_patch.json
iganet_lin_elasticity_3D_optimizedsrc/examples3D/singlePatch/sim_config_3D_single_patch.json
iganet_lin_elasticity_3D_multipatch_bonesrc/examples3D/multiPatch/sim_config_3D_multi_patch_bone.json
iganet_lin_elasticity_3D_multipatch_parametrizedsrc/examples3D/multiPatch/sim_config_3D_multi_patch_parametrized.json
In practice:
- edit the matching JSON config
- rebuild only if you changed C++ code
- if you changed only the config, rerun the executable
Run the executables from the repository root:
./build/iganet_lin_elasticity_2D
./build/iganet_lin_elasticity_2D_optimized./build/iganet_lin_elasticity_2D_multipatch_parametric./build/iganet_lin_elasticity_3D
./build/iganet_lin_elasticity_3D_optimized./build/iganet_lin_elasticity_3D_multipatch_bone
./build/iganet_lin_elasticity_3D_multipatch_parametrizedThe executables write JSON files into results/.
Typical files are:
results/result_iganet_lin_elasticity_2D.jsonresults/result_iganet_lin_elasticity_2D_optimized.jsonresults/result_iganet_lin_elasticity_2D_multipatch_parametric.jsonresults/result_iganet_lin_elasticity_3D.jsonresults/result_iganet_lin_elasticity_3D_optimized.jsonresults/result_iganet_lin_elasticity_3D_multipatch_bone.jsonresults/result_iganet_lin_elasticity_3D_multipatch_parametrized.json
The exact JSON contents depend on the example. Depending on the case, a result file may contain:
- geometry and deformed control points
- displacements
- stresses or derived quantities
- collocation point data
- interface diagnostics
- optional reference data from the Python standard-collocation run
Do not assume that every result file contains every field.
Each show script already has a matching default result file path. In the normal case you can just run the script directly without passing an argument.
python src/examples2D/singlePatch/show_2D_single_patch.pypython src/examples2D/multiPatch/show_2D_multi_patch.pypython src/examples3D/singlePatch/show_3D_single_patch.pypython src/examples3D/multiPatch/show_3D_multi_patch_bone.pyIf you explicitly want to visualize a different JSON file, you can still pass the result path manually, for example:
python src/examples2D/singlePatch/show_2D_single_patch.py \
results/result_iganet_lin_elasticity_2D_optimized.jsonThe show scripts also write PNG screenshots into results/.
If you are new to the repository, start in this order:
iganet_lin_elasticity_2D_optimizediganet_lin_elasticity_2Diganet_lin_elasticity_2D_multipatch_parametriciganet_lin_elasticity_3D_optimizediganet_lin_elasticity_3Diganet_lin_elasticity_3D_multipatch_parametrizediganet_lin_elasticity_3D_multipatch_bone
That keeps the early workflow simple and makes debugging easier.
cmake --build build -j 16 --target iganet_lin_elasticity_2D_optimized
./build/iganet_lin_elasticity_2D_optimized
python src/examples2D/singlePatch/show_2D_single_patch.py \
results/result_iganet_lin_elasticity_2D_optimized.jsonOpen:
src/examples2D/singlePatch/sim_config_2D_single_patch.json
Typical things to change:
- material parameters
- spline settings
- optimizer settings
- boundary conditions
cmake --build build -j 16 --target iganet_lin_elasticity_2D_multipatch_parametric
./build/iganet_lin_elasticity_2D_multipatch_parametric
python src/examples2D/multiPatch/show_2D_multi_patch.pycmake --build build -j 16 --target iganet_lin_elasticity_3D_optimized
./build/iganet_lin_elasticity_3D_optimized
python src/examples3D/singlePatch/show_3D_single_patch.py \
results/result_iganet_lin_elasticity_3D_optimized.jsonSome examples support:
geometry.mode = "parametric"geometry.mode = "xml"
In XML mode, geometries are typically loaded from filedata/, for example:
filedata/two_cube_parametric.xmlfiledata/five_patch_cantilever.xmlfiledata/bone_simplified.xml
If you want to change...
Edit the matching sim_config_*.json.
Edit the corresponding .cxx file in src/examples2D/... or
src/examples3D/....
Edit:
src/headers/lin_elasticity_net.hpp
Edit:
src/headers/lin_elasticity_multipatch_net.hpp
Edit:
src/utils/config.hpp
Edit the matching show_*.py.
Check that the machine has network access and that
IGANET_CORE_GIT_REPOSITORY and IGANET_CORE_GIT_TAG point to an existing
repository and branch, tag, or commit.
Check that Torch_DIR points to:
.../share/cmake/Torch
inside your LibTorch installation.
Re-run CMake configure:
cmake -S . -B build -DTorch_DIR=$HOME/libtorch/share/cmake/TorchThen build again.
Check that:
- the matching executable has been run
- the expected JSON file exists in
results/ - you are using the correct show script for that example
Install:
pip install numpy splinepy gustaf vedoThe shortest path into this repository is still:
- build
iganet_lin_elasticity_2D_optimized - inspect
src/examples2D/singlePatch/sim_config_2D_single_patch.json - run
src/examples2D/singlePatch/show_2D_single_patch.py
That gives you the cleanest first overview of the full workflow.