xref: /petsc/doc/tutorials/guide_to_examples_by_physics.md (revision bfe80ac4a46d58cb7760074b25f5e81b2f541d8a)
1# Tutorials, by Physics
2
3```{highlight} none
4```
5
6Below 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.
7
8## Poisson
9
10The Poisson equation
11
12$$
13-\Delta u = f
14$$
15
16is used to model electrostatics, steady-state diffusion, and other physical processes. Many PETSc examples solve this equation.
17
18> Finite Difference
19> : ```{eval-rst}
20>
21>   :2D: `SNES example 5 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex5.c.html>`_
22>   :3D: `KSP example 45 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex45.c.html>`_
23>   ```
24>
25> Finite Element
26> : ```{eval-rst}
27>
28>   :2D: `SNES example 12 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex12.c.html>`_
29>   :3D: `SNES example 12 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex12.c.html>`_
30>   ```
31
32## Elastostatics
33
34The equation for elastostatics balances body forces against stresses in the body
35
36$$
37-\nabla\cdot \bm \sigma = \bm f
38$$
39
40where $\bm\sigma$ is the stress tensor. Linear, isotropic elasticity governing infinitesimal strains has the particular stress-strain relation
41
42$$
43-\nabla\cdot \left( \lambda I \operatorname{trace}(\bm\varepsilon) + 2\mu \bm\varepsilon \right) = \bm f
44$$
45
46where the strain tensor $\bm \varepsilon$ is given by
47
48$$
49\bm \varepsilon = \frac{1}{2} \left(\nabla \bm u + (\nabla \bm u)^T \right)
50$$
51
52where $\bm u$ is the infinitesimal displacement of the body. The resulting discretizations use PETSc's nonlinear solvers
53
54Finite Element
55: ```{eval-rst}
56
57  :2D: `SNES example 17 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex17.c.html>`_
58  :3D: `SNES example 17 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex17.c.html>`_
59  :3D: `SNES example 56 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex56.c.html>`_
60  ```
61
62If we allow finite strains in the body, we can express the stress-strain relation in terms of the Jacobian of the deformation gradient
63
64$$
65J = \mathrm{det}(F) = \mathrm{det}\left(\nabla u\right)
66$$
67
68and the right Cauchy-Green deformation tensor
69
70$$
71C = F^T F
72$$
73
74so that
75
76$$
77\frac{\mu}{2} \left( \mathrm{Tr}(C) - 3 \right) + J p + \frac{\kappa}{2} (J - 1) = 0
78$$
79
80In the example everything is expressed in terms of determinants and cofactors of $F$.
81
82> Finite Element
83> :
84
85## Stokes
86
87{doc}`physics/guide_to_stokes`
88
89## Euler
90
91Not yet developed
92
93## Heat equation
94
95The time-dependent heat equation
96
97$$
98\frac{\partial u}{\partial t} - \Delta u = f
99$$
100
101is used to model heat flow, time-dependent diffusion, and other physical processes.
102
103> Finite Element
104> : ```{eval-rst}
105>
106>   :2D: `TS example 45 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex45.c.html>`_
107>   :3D: `TS example 45 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex45.c.html>`_
108>   ```
109
110## Navier-Stokes
111
112The time-dependent incompressible Navier-Stokes equations
113
114$$
115\begin{aligned}
116\frac{\partial u}{\partial t} + u\cdot\nabla u - \nabla \cdot \left(\mu \left(\nabla u + \nabla u^T\right)\right) + \nabla p + f &= 0 \\
117\nabla\cdot u &= 0 \end{aligned}
118$$
119
120are appropriate for flow of an incompressible fluid at low to moderate Reynolds number.
121
122> Finite Element
123> : ```{eval-rst}
124>
125>   :2D: `TS example 46 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex46.c.html>`_
126>   :3D: `TS example 46 <PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex46.c.html>`_
127>   ```
128