Tutorials, by Physics#

Below we list examples which simulate particular physics problems so that users interested in a particular set of governing equations can easily locate a relevant example. Often PETSc will have several examples looking at the same physics using different numerical tools, such as different discretizations, meshing strategy, closure model, or parameter regime.

Poisson#

The Poisson equation

Δu=f-\Delta u = f

is used to model electrostatics, steady-state diffusion, and other physical processes. Many PETSc examples solve this equation.

Finite Difference
2D

SNES example 5

3D

KSP example 45

Finite Element
2D

SNES example 12

3D

SNES example 12

Elastostatics#

The equation for elastostatics balances body forces against stresses in the body

σ=f-\nabla\cdot \bm \sigma = \bm f

where σ\bm\sigma is the stress tensor. Linear, isotropic elasticity governing infinitesimal strains has the particular stress-strain relation

(λItrace(ε)+2με)=f-\nabla\cdot \left( \lambda I \operatorname{trace}(\bm\varepsilon) + 2\mu \bm\varepsilon \right) = \bm f

where the strain tensor ε\bm \varepsilon is given by

ε=12(u+(u)T)\bm \varepsilon = \frac{1}{2} \left(\nabla \bm u + (\nabla \bm u)^T \right)

where u\bm u is the infinitesimal displacement of the body. The resulting discretizations use PETSc’s nonlinear solvers

Finite Element
2D

SNES example 17

3D

SNES example 17

3D

SNES example 56

If we allow finite strains in the body, we can express the stress-strain relation in terms of the Jacobian of the deformation gradient

J=det(F)=det(u)J = \mathrm{det}(F) = \mathrm{det}\left(\nabla u\right)

and the right Cauchy-Green deformation tensor

C=FTFC = F^T F

so that

μ2(Tr(C)3)+Jp+κ2(J1)=0\frac{\mu}{2} \left( \mathrm{Tr}(C) - 3 \right) + J p + \frac{\kappa}{2} (J - 1) = 0

In the example everything is expressed in terms of determinants and cofactors of FF.

Finite Element
3D

SNES example 77

Stokes#

Guide to the Stokes Equations using Finite Elements

Euler#

Not yet developed

Heat equation#

The time-dependent heat equation

utΔu=f\frac{\partial u}{\partial t} - \Delta u = f

is used to model heat flow, time-dependent diffusion, and other physical processes.

Finite Element
2D

TS example 45

3D

TS example 45