xref: /libCEED/examples/solids/README.md (revision 17be3a414c6fae47654f1361bae9c9dbcdd66795)
1bcb2dfaeSJed Brown# libCEED: Solid Mechanics Example
2bcb2dfaeSJed Brown
3*17be3a41SJeremy L ThompsonThis page provides a description of the solid mechanics example for the libCEED library, based on PETSc.
4b8962995SJeremy L ThompsonPETSc v3.17 or a development version of PETSc at commit 0e95d842 or later is required.
5bcb2dfaeSJed Brown
6bcb2dfaeSJed BrownThis code solves the steady-state static momentum balance equations using unstructured high-order finite/spectral element spatial discretizations.
7bcb2dfaeSJed BrownIn this mini-app, we consider three formulations used in solid mechanics applications: linear elasticity, Neo-Hookean hyperelasticity at small strain, and Neo-Hookean hyperelasticity at finite strain.
8bcb2dfaeSJed BrownAll three of these formulations are for compressible materials.
9bcb2dfaeSJed Brown
10bcb2dfaeSJed BrownBuild by using:
11bcb2dfaeSJed Brown
12bcb2dfaeSJed Brown```
13bcb2dfaeSJed Brownmake
14bcb2dfaeSJed Brown```
15bcb2dfaeSJed Brown
16bcb2dfaeSJed Brownand run with:
17bcb2dfaeSJed Brown
18bcb2dfaeSJed Brown```
19bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree [degree] -nu [nu] -E [E] [boundary options] -problem [problem type] -forcing [forcing] -ceed [ceed]
20bcb2dfaeSJed Brown```
21bcb2dfaeSJed Brown
22bcb2dfaeSJed Brown## Runtime options
23bcb2dfaeSJed Brown
24bcb2dfaeSJed Brown% inclusion-solids-marker
25bcb2dfaeSJed Brown
26b425b72cSLeila GhaffariThe elasticity mini-app is controlled via command-line options, the following of which are mandatory.
27bcb2dfaeSJed Brown
2868e843eeSJed Brown:::{list-table} Mandatory Runtime Options
29bcb2dfaeSJed Brown:header-rows: 1
3068e843eeSJed Brown:widths: 3 7
31bcb2dfaeSJed Brown
32bcb2dfaeSJed Brown* - Option
33bcb2dfaeSJed Brown  - Description
3468e843eeSJed Brown* - `-mesh [filename]`
35bcb2dfaeSJed Brown  - Path to mesh file in any format supported by PETSc.
3668e843eeSJed Brown* - `-degree [int]`
37bcb2dfaeSJed Brown  - Polynomial degree of the finite element basis
3868e843eeSJed Brown* - `-E [real]`
3968e843eeSJed Brown  - [Young's modulus](https://en.wikipedia.org/wiki/Young%27s_modulus), $E > 0$
4068e843eeSJed Brown* - `-nu [real]`
4168e843eeSJed Brown  - [Poisson's ratio](https://en.wikipedia.org/wiki/Poisson%27s_ratio), $\nu < 0.5$
4268e843eeSJed Brown* - `-bc_clamp [int list]`
43*17be3a41SJeremy L Thompson  - List of face sets on which to displace by `-bc_clamp_[facenumber]_translate [x,y,z]` and/or `bc_clamp_[facenumber]_rotate [rx,ry,rz,c_0,c_1]`.
44*17be3a41SJeremy L Thompson    Note: The default for a clamped face is zero displacement.
45*17be3a41SJeremy L Thompson    All displacement is with respect to the initial configuration.
4668e843eeSJed Brown* - `-bc_traction [int list]`
47*17be3a41SJeremy L Thompson  - List of face sets on which to set traction boundary conditions with the traction vector `-bc_traction_[facenumber] [tx,ty,tz]`
4868e843eeSJed Brown:::
49bcb2dfaeSJed Brown
50bcb2dfaeSJed Brown:::{note}
51bcb2dfaeSJed BrownThis solver can use any mesh format that PETSc's `DMPlex` can read (Exodus, Gmsh, Med, etc.).
52bcb2dfaeSJed BrownOur tests have primarily been using Exodus meshes created using [CUBIT]; sample meshes used for the example runs suggested here can be found in [this repository].
53bcb2dfaeSJed BrownNote that many mesh formats require PETSc to be configured appropriately; e.g., `--download-exodusii` for Exodus support.
54bcb2dfaeSJed Brown:::
55bcb2dfaeSJed Brown
56bcb2dfaeSJed BrownConsider the specific example of the mesh seen below:
57bcb2dfaeSJed Brown
58bcb2dfaeSJed Brown```{image} https://github.com/jeremylt/ceedSampleMeshes/raw/master/cylinderDiagram.png
59bcb2dfaeSJed Brown```
60bcb2dfaeSJed Brown
61bcb2dfaeSJed BrownWith the sidesets defined in the figure, we provide here an example of a minimal set of command line options:
62bcb2dfaeSJed Brown
63bcb2dfaeSJed Brown```
64bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree 4 -E 1e6 -nu 0.3 -bc_clamp 998,999 -bc_clamp_998_translate 0,-0.5,1
65bcb2dfaeSJed Brown```
66bcb2dfaeSJed Brown
67bcb2dfaeSJed BrownIn this example, we set the left boundary, face set $999$, to zero displacement and the right boundary, face set $998$, to displace $0$ in the $x$ direction, $-0.5$ in the $y$, and $1$ in the $z$.
68bcb2dfaeSJed Brown
69bcb2dfaeSJed BrownAs an alternative to specifying a mesh with {code}`-mesh`, the user may use a DMPlex box mesh by specifying {code}`-dm_plex_box_faces [int list]`, {code}`-dm_plex_box_upper [real list]`, and {code}`-dm_plex_box_lower [real list]`.
70bcb2dfaeSJed Brown
71*17be3a41SJeremy L ThompsonAs an alternative example exploiting {code}`-dm_plex_box_faces`, we consider a {code}`4 x 4 x 4` mesh where essential (Drichlet) boundary condition is placed on all sides.
72*17be3a41SJeremy L ThompsonSides 1 through 6 are rotated around $x$-axis:
73bcb2dfaeSJed Brown
74bcb2dfaeSJed Brown```
75bcb2dfaeSJed Brown./elasticity -problem FSInitial-NH1 -E 1 -nu 0.3 -num_steps 40 -snes_linesearch_type cp -dm_plex_box_faces 4,4,4 -bc_clamp 1,2,3,4,5,6 -bc_clamp_1_rotate 0,0,1,0,.3 -bc_clamp_2_rotate 0,0,1,0,.3 -bc_clamp_3_rotate 0,0,1,0,.3 -bc_clamp_4_rotate 0,0,1,0,.3 -bc_clamp_5_rotate 0,0,1,0,.3 -bc_clamp_6_rotate 0,0,1,0,.3
76bcb2dfaeSJed Brown```
77bcb2dfaeSJed Brown
78bcb2dfaeSJed Brown:::{note}
79bcb2dfaeSJed BrownIf the coordinates for a particular side of a mesh are zero along the axis of rotation, it may appear that particular side is clamped zero.
80bcb2dfaeSJed Brown:::
81bcb2dfaeSJed Brown
82bcb2dfaeSJed BrownOn each boundary node, the rotation magnitude is computed: {code}`theta = (c_0 + c_1 * cx) * loadIncrement` where {code}`cx = kx * x + ky * y + kz * z`, with {code}`kx`, {code}`ky`, {code}`kz` are normalized values.
83bcb2dfaeSJed Brown
84bcb2dfaeSJed BrownThe command line options just shown are the minimum requirements to run the mini-app, but additional options may also be set as follows
85bcb2dfaeSJed Brown
8668e843eeSJed Brown:::{list-table} Additional Runtime Options
87bcb2dfaeSJed Brown:header-rows: 1
88bcb2dfaeSJed Brown
89bcb2dfaeSJed Brown* - Option
90bcb2dfaeSJed Brown  - Description
91bcb2dfaeSJed Brown  - Default value
92bcb2dfaeSJed Brown
9368e843eeSJed Brown* - `-ceed`
94bcb2dfaeSJed Brown  - CEED resource specifier
9568e843eeSJed Brown  - `/cpu/self`
96bcb2dfaeSJed Brown
972288fb52SJeremy L Thompson* - `-q_extra`
98bcb2dfaeSJed Brown  - Number of extra quadrature points
9968e843eeSJed Brown  - `0`
100bcb2dfaeSJed Brown
10168e843eeSJed Brown* - `-test`
102bcb2dfaeSJed Brown  - Run in test mode
103bcb2dfaeSJed Brown  -
104bcb2dfaeSJed Brown
10568e843eeSJed Brown* - `-problem`
10668e843eeSJed Brown  - Problem to solve (`Linear`, `SS-NH`, `FSInitial-NH1`, etc.)
10768e843eeSJed Brown  - `Linear`
108bcb2dfaeSJed Brown
10968e843eeSJed Brown* - `-forcing`
11068e843eeSJed Brown  -  Forcing term option (`none`, `constant`, or `mms`)
11168e843eeSJed Brown  - `none`
112bcb2dfaeSJed Brown
11368e843eeSJed Brown* - `-forcing_vec`
114bcb2dfaeSJed Brown  -  Forcing vector
11568e843eeSJed Brown  - `0,-1,0`
116bcb2dfaeSJed Brown
11768e843eeSJed Brown* - `-multigrid`
11868e843eeSJed Brown  - Multigrid coarsening to use (`logarithmic`, `uniform` or `none`)
11968e843eeSJed Brown  - `logarithmic`
120bcb2dfaeSJed Brown
12168e843eeSJed Brown* - `-nu_smoother [real]`
12268e843eeSJed Brown  - Poisson's ratio for multigrid smoothers, $\nu < 0.5$
123bcb2dfaeSJed Brown  -
124bcb2dfaeSJed Brown
12568e843eeSJed Brown* - `-num_steps`
126bcb2dfaeSJed Brown  - Number of load increments for continuation method
12768e843eeSJed Brown  - `1` if `Linear` else `10`
128bcb2dfaeSJed Brown
12968e843eeSJed Brown* - `-view_soln`
130bcb2dfaeSJed Brown  - Output solution at each load increment for viewing
131bcb2dfaeSJed Brown  -
132bcb2dfaeSJed Brown
13368e843eeSJed Brown* - `-view_final_soln`
134bcb2dfaeSJed Brown  - Output solution at final load increment for viewing
135bcb2dfaeSJed Brown  -
136bcb2dfaeSJed Brown
13768e843eeSJed Brown* - `-snes_view`
13868e843eeSJed Brown  - View PETSc `SNES` nonlinear solver configuration
139bcb2dfaeSJed Brown  -
140bcb2dfaeSJed Brown
14168e843eeSJed Brown* - `-log_view`
142bcb2dfaeSJed Brown  - View PETSc performance log
143bcb2dfaeSJed Brown  -
144bcb2dfaeSJed Brown
14568e843eeSJed Brown* - `-output_dir`
146bcb2dfaeSJed Brown  - Output directory
14768e843eeSJed Brown  - `.`
148bcb2dfaeSJed Brown
14968e843eeSJed Brown* - `-help`
150bcb2dfaeSJed Brown  - View comprehensive information about run-time options
151bcb2dfaeSJed Brown  -
15268e843eeSJed Brown:::
153bcb2dfaeSJed Brown
154bcb2dfaeSJed BrownTo verify the convergence of the linear elasticity formulation on a given mesh with the method of manufactured solutions, run:
155bcb2dfaeSJed Brown
156bcb2dfaeSJed Brown```
157bcb2dfaeSJed Brown./elasticity -mesh [mesh] -degree [degree] -nu [nu] -E [E] -forcing mms
158bcb2dfaeSJed Brown```
159bcb2dfaeSJed Brown
160bcb2dfaeSJed BrownThis option attempts to recover a known solution from an analytically computed forcing term.
161bcb2dfaeSJed Brown
162bcb2dfaeSJed Brown### On algebraic solvers
163bcb2dfaeSJed Brown
164bcb2dfaeSJed BrownThis mini-app is configured to use the following Newton-Krylov-Multigrid method by default.
165bcb2dfaeSJed Brown
166bcb2dfaeSJed Brown- Newton-type methods for the nonlinear solve, with the hyperelasticity models globalized using load increments.
167bcb2dfaeSJed Brown- Preconditioned conjugate gradients to solve the symmetric positive definite linear systems arising at each Newton step.
168bcb2dfaeSJed Brown- Preconditioning via $p$-version multigrid coarsening to linear elements, with algebraic multigrid (PETSc's `GAMG`) for the coarse solve.
169bcb2dfaeSJed Brown  The default smoother uses degree 3 Chebyshev with Jacobi preconditioning.
170bcb2dfaeSJed Brown  (Lower degree is often faster, albeit less robust; try {code}`-outer_mg_levels_ksp_max_it 2`, for example.)
171bcb2dfaeSJed Brown  Application of the linear operators for all levels with degree $p > 1$ is performed matrix-free using analytic Newton linearization, while the lowest order $p = 1$ operators are assembled explicitly (using coloring at present).
172bcb2dfaeSJed Brown
173bcb2dfaeSJed BrownMany related solvers can be implemented by composing PETSc command-line options.
174bcb2dfaeSJed Brown
175bcb2dfaeSJed Brown### Nondimensionalization
176bcb2dfaeSJed Brown
177bcb2dfaeSJed BrownQuantities such as the Young's modulus vary over many orders of magnitude, and thus can lead to poorly scaled equations.
178bcb2dfaeSJed BrownOne can nondimensionalize the model by choosing an alternate system of units, such that displacements and residuals are of reasonable scales.
179bcb2dfaeSJed Brown
18068e843eeSJed Brown:::{list-table} (Non)dimensionalization options
181bcb2dfaeSJed Brown:header-rows: 1
182bcb2dfaeSJed Brown
183bcb2dfaeSJed Brown* - Option
184bcb2dfaeSJed Brown  - Description
185bcb2dfaeSJed Brown  - Default value
186bcb2dfaeSJed Brown
1871fbe68c1SLawrence Mitchell* - `-units_meter`
188bcb2dfaeSJed Brown  - 1 meter in scaled length units
1891fbe68c1SLawrence Mitchell  - `1`
190bcb2dfaeSJed Brown
1911fbe68c1SLawrence Mitchell* - `-units_second`
192bcb2dfaeSJed Brown  - 1 second in scaled time units
1931fbe68c1SLawrence Mitchell  - `1`
194bcb2dfaeSJed Brown
1951fbe68c1SLawrence Mitchell* - `-units_kilogram`
196bcb2dfaeSJed Brown  - 1 kilogram in scaled mass units
1971fbe68c1SLawrence Mitchell  - `1`
19868e843eeSJed Brown:::
199bcb2dfaeSJed Brown
200bcb2dfaeSJed BrownFor example, consider a problem involving metals subject to gravity.
201bcb2dfaeSJed Brown
20268e843eeSJed Brown:::{list-table} Characteristic units for metals
203bcb2dfaeSJed Brown:header-rows: 1
204bcb2dfaeSJed Brown
205bcb2dfaeSJed Brown* - Quantity
206bcb2dfaeSJed Brown  - Typical value in SI units
207bcb2dfaeSJed Brown
20868e843eeSJed Brown* - Displacement, $\bm u$
20968e843eeSJed Brown  - $1 \,\mathrm{cm} = 10^{-2} \,\mathrm m$
210bcb2dfaeSJed Brown
21168e843eeSJed Brown* - Young's modulus, $E$
21268e843eeSJed Brown  - $10^{11} \,\mathrm{Pa} = 10^{11} \,\mathrm{kg}\, \mathrm{m}^{-1}\, \mathrm s^{-2}$
213bcb2dfaeSJed Brown
21468e843eeSJed Brown* - Body force (gravity) on volume, $\int \rho \bm g$
21568e843eeSJed Brown  - $5 \cdot 10^4 \,\mathrm{kg}\, \mathrm m^{-2} \, \mathrm s^{-2} \cdot (\text{volume} \, \mathrm m^3)$
21668e843eeSJed Brown:::
217bcb2dfaeSJed Brown
218bcb2dfaeSJed BrownOne can choose units of displacement independently (e.g., {code}`-units_meter 100` to measure displacement in centimeters), but $E$ and $\int \rho \bm g$ have the same dependence on mass and time, so cannot both be made of order 1.
219bcb2dfaeSJed BrownThis reflects the fact that both quantities are not equally significant for a given displacement size; the relative significance of gravity increases as the domain size grows.
220bcb2dfaeSJed Brown
221bcb2dfaeSJed Brown### Diagnostic Quantities
222bcb2dfaeSJed Brown
223bcb2dfaeSJed BrownDiagnostic quantities for viewing are provided when the command line options for visualization output, {code}`-view_soln` or {code}`-view_final_soln` are used.
224bcb2dfaeSJed BrownThe diagnostic quantities include displacement in the $x$ direction, displacement in the $y$ direction, displacement in the $z$ direction, pressure, $\operatorname{trace} \bm{E}$, $\operatorname{trace} \bm{E}^2$, $\lvert J \rvert$, and strain energy density.
225bcb2dfaeSJed BrownThe table below summarizes the formulations of each of these quantities for each problem type.
226bcb2dfaeSJed Brown
22768e843eeSJed Brown:::{list-table} Diagnostic quantities
228bcb2dfaeSJed Brown   :header-rows: 1
229bcb2dfaeSJed Brown
230bcb2dfaeSJed Brown   * - Quantity
231bcb2dfaeSJed Brown     - Linear Elasticity
232bcb2dfaeSJed Brown     - Hyperelasticity, Small Strain
233bcb2dfaeSJed Brown     - Hyperelasticity, Finite Strain
234bcb2dfaeSJed Brown
235bcb2dfaeSJed Brown   * - Pressure
23668e843eeSJed Brown     - $\lambda \operatorname{trace} \bm{\epsilon}$
23768e843eeSJed Brown     - $\lambda \log \operatorname{trace} \bm{\epsilon}$
23868e843eeSJed Brown     - $\lambda \log J$
239bcb2dfaeSJed Brown
240bcb2dfaeSJed Brown   * - Volumetric Strain
24168e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}$
24268e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}$
24368e843eeSJed Brown     - $\operatorname{trace} \bm{E}$
244bcb2dfaeSJed Brown
24568e843eeSJed Brown   * - $\operatorname{trace} \bm{E}^2$
24668e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}^2$
24768e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}^2$
24868e843eeSJed Brown     - $\operatorname{trace} \bm{E}^2$
249bcb2dfaeSJed Brown
25068e843eeSJed Brown   * - $\lvert J \rvert$
25168e843eeSJed Brown     - $1 + \operatorname{trace} \bm{\epsilon}$
25268e843eeSJed Brown     - $1 + \operatorname{trace} \bm{\epsilon}$
25368e843eeSJed Brown     - $\lvert J \rvert$
254bcb2dfaeSJed Brown
255bcb2dfaeSJed Brown   * - Strain Energy Density
25668e843eeSJed Brown     - $\frac{\lambda}{2} (\operatorname{trace} \bm{\epsilon})^2 + \mu \bm{\epsilon} : \bm{\epsilon}$
25768e843eeSJed Brown     - $\lambda (1 + \operatorname{trace} \bm{\epsilon}) (\log(1 + \operatorname{trace} \bm{\epsilon} ) - 1) + \mu \bm{\epsilon} : \bm{\epsilon}$
25868e843eeSJed Brown     - $\frac{\lambda}{2}(\log J)^2 + \mu \operatorname{trace} \bm{E} - \mu \log J$
25968e843eeSJed Brown:::
260bcb2dfaeSJed Brown
261bcb2dfaeSJed Brown[cubit]: https://cubit.sandia.gov/
262bcb2dfaeSJed Brown[this repository]: https://github.com/jeremylt/ceedSampleMeshes
263