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