Skip to content

Latest commit

 

History

37 Commits

Folders and files

Repository files navigation

HyperFEM tutorials

Dev CI

Tutorials of HyperFEM.jl, a library of the Gridap ecosystem for the finite-element simulation of multiphysics problems with hyperelastic materials: thermo-, electro- and magneto-mechanics at finite strains, contact, fluids, transient problems and solvers for large systems.

Two kinds of self-contained Julia scripts:

  • Tutorials (tutorials/): short scripts to learn HyperFEM, in order, each with the problem, the theory it needs and a simple implementation. Start here.
  • Validation examples (validation/): larger problems solved in full, with quantitative checks of their results (exact solutions, published benchmarks, conservation laws), which are also the test suite of this repository.

The documentation turns each script into a page, with a Jupyter notebook generated from the same script.

Getting started

Julia 1.12 or later is needed. Clone the repository and install the dependencies (HyperFEM 0.4, HyperFEMKernels 0.2.6, Gridap 0.20.8, …):

git clone https://github.com/MultiSimOLab/HyperFEMTutorials.git
cd HyperFEMTutorials
julia --project=. -e 'using Pkg; Pkg.instantiate()'

Run a tutorial or a validation example from the root of the repository (several use threads):

julia -t 4 --project=. tutorials/poisson.jl
julia -t 4 --project=. validation/E02_Hyperelastic_stretch.jl

On Linux, PETSc has crashed with several threads: run tutorial 12 (linear_solvers.jl) with one thread there (julia -t 1).

The tutorials write their results (VTK files for ParaView) to results/<tutorial>/, the validation examples (VTK files, CSV tables) to data/sims/<example>/. With HYPERFEM_TUTORIALS_FAST=1 every validation example runs a reduced case that finishes in a few minutes at most. When several Julia processes run at the same time, limit the BLAS threads (OPENBLAS_NUM_THREADS=4): the sparse LU factorisations otherwise compete for the cores and become many times slower.

Tutorials

Tutorial What you learn
1 Poisson equation mesh and tags, boundary conditions, finite element spaces, a linear problem, VTK output
2 Stretching a hyperelastic bar a constitutive model, loads that grow, the nonlinear solver, post-processing
3 Bending a dielectric plate with a voltage two fields, a coupled electro-mechanical model, its weak form
4 Free vibration of a cantilever transient problems: mass, time scheme, time stepping, a history in time
5 Choosing and writing a constitutive model calling a model, stresses and tangents at a point, writing your own model and checking it
6 A fibre-reinforced tube under pressure an anisotropic model, fibre directions as fields, a pressure that follows the surface
7 A magnetic soft beam in a field a hard-magnetic material: a magnetic load written by hand and taken at the previous increment, a Gmsh mesh
8 Creep of a viscoelastic actuator viscoelasticity: internal variables at the quadrature points, a time loop without inertia
9 Heating a constrained bar thermo-mechanics: a coupled temperature field and transient heat conduction
10 Stokes flow around a cylinder a mixed velocity–pressure problem: Taylor–Hood elements, a field without boundary conditions, forces on a body
11 Unsteady flow around a cylinder transient Navier–Stokes: forms with the time context of a step, stabilised linear elements, a benchmark value
12 Changing the linear solver an iterative solver from PETSc: conjugate gradients with algebraic multigrid and the rigid-body modes
13 Contact through a third medium contact without contact search: two subdomains, a facet (skeleton) term, a line search that keeps elements valid
14 Solving two fields in turn a staggered solution: three problems solved in turn (StaggeredModel), states shared between them, values moved between meshes

Validation examples

Nº Example What it shows
01 Poisson equation linear problems, Dirichlet and Neumann conditions, convergence under refinement
02 Uniaxial stretch of a hyperelastic bar constitutive models, load stepping, Newton–Raphson, post-processing
03 Fibre-reinforced cylinder under internal pressure anisotropic models, fibre fields, follower pressure
04 Electro-mechanics of a dielectric elastomer multi-field problems, coupled weak forms
05 Anisotropic electro-mechanics composition of models, extra arguments of the constitutive functions
06 Third-medium contact contact through a soft medium, injectivity line search, hybrid Newton
07 Topology optimisation in preparation (HyperShape.jl)
08 Magneto-mechanical hMRE beam hard-magnetic soft materials, lagged loads
09 hMRE beam in vacuum: staggered solution staggered models, coupling between meshes, transfers
10 Stokes flow around a cylinder mixed and stabilised formulations
11 Transient Navier–Stokes flow around a cylinder time integration with TransientModel, benchmarks
12 Pulsatile blood flow in a patient aorta 3D transient flow, Windkessel outlet conditions
13 Linear solvers for large problems direct, Krylov and algebraic multigrid solvers, inexact Newton
14 Geometric h- and p-multigrid mesh hierarchies, matrix-free p-multigrid
15 Elastodynamics: free vibration of a cantilever structural dynamics, energy conservation
16 Visco-electro-mechanics: creep of a dielectric bimorph generalised Maxwell viscoelasticity, internal variables, quasi-static time stepping
17 Thermo-mechanics: transient heat conduction and thermal expansion coupled thermal and mechanical fields, weak forms from the energy, adaptive BDF2
18 Explicit dynamics: wave propagation in a bar central differences, lumped mass, critical time step, wave speed
19 Constitutive models: energies, stresses and tangents the constitutive-model API, homogeneous tests, writing your own model

Notebooks

Every page of the documentation links to a Jupyter notebook (not executed) generated from the same script with Literate.jl. To use them, install IJulia and generate the notebooks inside your clone, so that the paths to data/ work:

julia --project=docs -e 'using Pkg; Pkg.instantiate()'
julia --project=docs docs/make.jl notebooks     # writes notebooks/<name>.ipynb and notebooks/E<NN>_<Name>.ipynb

Tests

julia -t 4 --project=. -e 'using Pkg; Pkg.test()'

runs every tutorial as published and every validation example in its reduced case. HYPERFEM_TUTORIALS_GROUP (tutorials, basics, coupled, contact, fluids, solvers, dynamics) and HYPERFEM_TUTORIALS_ONLY (e.g. E02,E10 or hyperelastic) select them; HYPERFEM_TUTORIALS_PETSC=0 skips the parts that use PETSc. See Running and testing.

How to cite

If you use HyperFEM, please cite

C. Perez-Garcia, R. Ortigosa, J. Martínez-Frutos and D. Garcia-Gonzalez, Topology and material optimization in ultra-soft magnetoactive structures: making advantage of residual anisotropies. Adv. Mater. (2025) e18489. https://doi.org/10.1002/adma.202518489

along with the citations requested by Gridap (see CITATION.cff).

Funding

Grants PID2022-141957OA-C22/PID2022-141957OB-C22 funded by MCIN/AEI/10.13039/501100011033 and by "ERDF A way of making Europe".

Contact

Contact the project administrator Jesús Martínez-Frutos for questions about licenses and terms of use.

Releases

Packages

Contributors

Languages