xref: /libCEED/examples/solids/README.md (revision b425b72ce6207063c385cb41f0ea18e8c839ca9f)
1bcb2dfaeSJed Brown# libCEED: Solid Mechanics Example
2bcb2dfaeSJed Brown
3bcb2dfaeSJed BrownThis page provides a description of the solid mechanics example for the
4bcb2dfaeSJed BrownlibCEED library, based on PETSc.
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
26*b425b72cSLeila 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]`
4368e843eeSJed Brown  - List of face sets on which to displace by `-bc_clamp_[facenumber]_translate [x,y,z]`
4468e843eeSJed Brown    and/or `bc_clamp_[facenumber]_rotate [rx,ry,rz,c_0,c_1]`. Note: The default
4568e843eeSJed Brown    for a clamped face is zero displacement. All displacement is with respect to
4668e843eeSJed Brown    the initial configuration.
4768e843eeSJed Brown* - `-bc_traction [int list]`
4868e843eeSJed Brown  - List of face sets on which to set traction boundary conditions with the
4968e843eeSJed Brown    traction vector `-bc_traction_[facenumber] [tx,ty,tz]`
5068e843eeSJed Brown:::
51bcb2dfaeSJed Brown
52bcb2dfaeSJed Brown:::{note}
53bcb2dfaeSJed BrownThis solver can use any mesh format that PETSc's `DMPlex` can read (Exodus, Gmsh, Med, etc.).
54bcb2dfaeSJed 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].
55bcb2dfaeSJed BrownNote that many mesh formats require PETSc to be configured appropriately; e.g., `--download-exodusii` for Exodus support.
56bcb2dfaeSJed Brown:::
57bcb2dfaeSJed Brown
58bcb2dfaeSJed BrownConsider the specific example of the mesh seen below:
59bcb2dfaeSJed Brown
60bcb2dfaeSJed Brown```{image} https://github.com/jeremylt/ceedSampleMeshes/raw/master/cylinderDiagram.png
61bcb2dfaeSJed Brown```
62bcb2dfaeSJed Brown
63bcb2dfaeSJed BrownWith the sidesets defined in the figure, we provide here an example of a minimal set of command line options:
64bcb2dfaeSJed Brown
65bcb2dfaeSJed Brown```
66bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree 4 -E 1e6 -nu 0.3 -bc_clamp 998,999 -bc_clamp_998_translate 0,-0.5,1
67bcb2dfaeSJed Brown```
68bcb2dfaeSJed Brown
69bcb2dfaeSJed 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$.
70bcb2dfaeSJed Brown
71bcb2dfaeSJed 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]`.
72bcb2dfaeSJed Brown
73bcb2dfaeSJed BrownAs 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. Sides 1 through 6 are rotated around $x$-axis:
74bcb2dfaeSJed Brown
75bcb2dfaeSJed Brown```
76bcb2dfaeSJed 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
77bcb2dfaeSJed Brown```
78bcb2dfaeSJed Brown
79bcb2dfaeSJed Brown:::{note}
80bcb2dfaeSJed 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.
81bcb2dfaeSJed Brown:::
82bcb2dfaeSJed Brown
83bcb2dfaeSJed 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.
84bcb2dfaeSJed Brown
85bcb2dfaeSJed BrownThe command line options just shown are the minimum requirements to run the mini-app, but additional options may also be set as follows
86bcb2dfaeSJed Brown
8768e843eeSJed Brown:::{list-table} Additional Runtime Options
88bcb2dfaeSJed Brown:header-rows: 1
89bcb2dfaeSJed Brown
90bcb2dfaeSJed Brown* - Option
91bcb2dfaeSJed Brown  - Description
92bcb2dfaeSJed Brown  - Default value
93bcb2dfaeSJed Brown
9468e843eeSJed Brown* - `-ceed`
95bcb2dfaeSJed Brown  - CEED resource specifier
9668e843eeSJed Brown  - `/cpu/self`
97bcb2dfaeSJed Brown
9868e843eeSJed Brown* - `-qextra`
99bcb2dfaeSJed Brown  - Number of extra quadrature points
10068e843eeSJed Brown  - `0`
101bcb2dfaeSJed Brown
10268e843eeSJed Brown* - `-test`
103bcb2dfaeSJed Brown  - Run in test mode
104bcb2dfaeSJed Brown  -
105bcb2dfaeSJed Brown
10668e843eeSJed Brown* - `-problem`
10768e843eeSJed Brown  - Problem to solve (`Linear`, `SS-NH`, `FSInitial-NH1`, etc.)
10868e843eeSJed Brown  - `Linear`
109bcb2dfaeSJed Brown
11068e843eeSJed Brown* - `-forcing`
11168e843eeSJed Brown  -  Forcing term option (`none`, `constant`, or `mms`)
11268e843eeSJed Brown  - `none`
113bcb2dfaeSJed Brown
11468e843eeSJed Brown* - `-forcing_vec`
115bcb2dfaeSJed Brown  -  Forcing vector
11668e843eeSJed Brown  - `0,-1,0`
117bcb2dfaeSJed Brown
11868e843eeSJed Brown* - `-multigrid`
11968e843eeSJed Brown  - Multigrid coarsening to use (`logarithmic`, `uniform` or `none`)
12068e843eeSJed Brown  - `logarithmic`
121bcb2dfaeSJed Brown
12268e843eeSJed Brown* - `-nu_smoother [real]`
12368e843eeSJed Brown  - Poisson's ratio for multigrid smoothers, $\nu < 0.5$
124bcb2dfaeSJed Brown  -
125bcb2dfaeSJed Brown
12668e843eeSJed Brown* - `-num_steps`
127bcb2dfaeSJed Brown  - Number of load increments for continuation method
12868e843eeSJed Brown  - `1` if `Linear` else `10`
129bcb2dfaeSJed Brown
13068e843eeSJed Brown* - `-view_soln`
131bcb2dfaeSJed Brown  - Output solution at each load increment for viewing
132bcb2dfaeSJed Brown  -
133bcb2dfaeSJed Brown
13468e843eeSJed Brown* - `-view_final_soln`
135bcb2dfaeSJed Brown  - Output solution at final load increment for viewing
136bcb2dfaeSJed Brown  -
137bcb2dfaeSJed Brown
13868e843eeSJed Brown* - `-snes_view`
13968e843eeSJed Brown  - View PETSc `SNES` nonlinear solver configuration
140bcb2dfaeSJed Brown  -
141bcb2dfaeSJed Brown
14268e843eeSJed Brown* - `-log_view`
143bcb2dfaeSJed Brown  - View PETSc performance log
144bcb2dfaeSJed Brown  -
145bcb2dfaeSJed Brown
14668e843eeSJed Brown* - `-output_dir`
147bcb2dfaeSJed Brown  - Output directory
14868e843eeSJed Brown  - `.`
149bcb2dfaeSJed Brown
15068e843eeSJed Brown* - `-help`
151bcb2dfaeSJed Brown  - View comprehensive information about run-time options
152bcb2dfaeSJed Brown  -
15368e843eeSJed Brown:::
154bcb2dfaeSJed Brown
155bcb2dfaeSJed BrownTo verify the convergence of the linear elasticity formulation on a given mesh with the method of manufactured solutions, run:
156bcb2dfaeSJed Brown
157bcb2dfaeSJed Brown```
158bcb2dfaeSJed Brown./elasticity -mesh [mesh] -degree [degree] -nu [nu] -E [E] -forcing mms
159bcb2dfaeSJed Brown```
160bcb2dfaeSJed Brown
161bcb2dfaeSJed BrownThis option attempts to recover a known solution from an analytically computed forcing term.
162bcb2dfaeSJed Brown
163bcb2dfaeSJed Brown### On algebraic solvers
164bcb2dfaeSJed Brown
165bcb2dfaeSJed BrownThis mini-app is configured to use the following Newton-Krylov-Multigrid method by default.
166bcb2dfaeSJed Brown
167bcb2dfaeSJed Brown- Newton-type methods for the nonlinear solve, with the hyperelasticity models globalized using load increments.
168bcb2dfaeSJed Brown- Preconditioned conjugate gradients to solve the symmetric positive definite linear systems arising at each Newton step.
169bcb2dfaeSJed Brown- Preconditioning via $p$-version multigrid coarsening to linear elements, with algebraic multigrid (PETSc's `GAMG`) for the coarse solve.
170bcb2dfaeSJed Brown  The default smoother uses degree 3 Chebyshev with Jacobi preconditioning.
171bcb2dfaeSJed Brown  (Lower degree is often faster, albeit less robust; try {code}`-outer_mg_levels_ksp_max_it 2`, for example.)
172bcb2dfaeSJed 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).
173bcb2dfaeSJed Brown
174bcb2dfaeSJed BrownMany related solvers can be implemented by composing PETSc command-line options.
175bcb2dfaeSJed Brown
176bcb2dfaeSJed Brown### Nondimensionalization
177bcb2dfaeSJed Brown
178bcb2dfaeSJed BrownQuantities such as the Young's modulus vary over many orders of magnitude, and thus can lead to poorly scaled equations.
179bcb2dfaeSJed BrownOne can nondimensionalize the model by choosing an alternate system of units, such that displacements and residuals are of reasonable scales.
180bcb2dfaeSJed Brown
18168e843eeSJed Brown:::{list-table} (Non)dimensionalization options
182bcb2dfaeSJed Brown:header-rows: 1
183bcb2dfaeSJed Brown
184bcb2dfaeSJed Brown* - Option
185bcb2dfaeSJed Brown  - Description
186bcb2dfaeSJed Brown  - Default value
187bcb2dfaeSJed Brown
188bcb2dfaeSJed Brown* - :code:`-units_meter`
189bcb2dfaeSJed Brown  - 1 meter in scaled length units
190bcb2dfaeSJed Brown  - :code:`1`
191bcb2dfaeSJed Brown
192bcb2dfaeSJed Brown* - :code:`-units_second`
193bcb2dfaeSJed Brown  - 1 second in scaled time units
194bcb2dfaeSJed Brown  - :code:`1`
195bcb2dfaeSJed Brown
196bcb2dfaeSJed Brown* - :code:`-units_kilogram`
197bcb2dfaeSJed Brown  - 1 kilogram in scaled mass units
198bcb2dfaeSJed Brown  - :code:`1`
19968e843eeSJed Brown:::
200bcb2dfaeSJed Brown
201bcb2dfaeSJed BrownFor example, consider a problem involving metals subject to gravity.
202bcb2dfaeSJed Brown
20368e843eeSJed Brown:::{list-table} Characteristic units for metals
204bcb2dfaeSJed Brown:header-rows: 1
205bcb2dfaeSJed Brown
206bcb2dfaeSJed Brown* - Quantity
207bcb2dfaeSJed Brown  - Typical value in SI units
208bcb2dfaeSJed Brown
20968e843eeSJed Brown* - Displacement, $\bm u$
21068e843eeSJed Brown  - $1 \,\mathrm{cm} = 10^{-2} \,\mathrm m$
211bcb2dfaeSJed Brown
21268e843eeSJed Brown* - Young's modulus, $E$
21368e843eeSJed Brown  - $10^{11} \,\mathrm{Pa} = 10^{11} \,\mathrm{kg}\, \mathrm{m}^{-1}\, \mathrm s^{-2}$
214bcb2dfaeSJed Brown
21568e843eeSJed Brown* - Body force (gravity) on volume, $\int \rho \bm g$
21668e843eeSJed Brown  - $5 \cdot 10^4 \,\mathrm{kg}\, \mathrm m^{-2} \, \mathrm s^{-2} \cdot (\text{volume} \, \mathrm m^3)$
21768e843eeSJed Brown:::
218bcb2dfaeSJed Brown
219bcb2dfaeSJed 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.
220bcb2dfaeSJed 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.
221bcb2dfaeSJed Brown
222bcb2dfaeSJed Brown### Diagnostic Quantities
223bcb2dfaeSJed Brown
224bcb2dfaeSJed BrownDiagnostic quantities for viewing are provided when the command line options for visualization output, {code}`-view_soln` or {code}`-view_final_soln` are used.
225bcb2dfaeSJed 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.
226bcb2dfaeSJed BrownThe table below summarizes the formulations of each of these quantities for each problem type.
227bcb2dfaeSJed Brown
22868e843eeSJed Brown:::{list-table} Diagnostic quantities
229bcb2dfaeSJed Brown   :header-rows: 1
230bcb2dfaeSJed Brown
231bcb2dfaeSJed Brown   * - Quantity
232bcb2dfaeSJed Brown     - Linear Elasticity
233bcb2dfaeSJed Brown     - Hyperelasticity, Small Strain
234bcb2dfaeSJed Brown     - Hyperelasticity, Finite Strain
235bcb2dfaeSJed Brown
236bcb2dfaeSJed Brown   * - Pressure
23768e843eeSJed Brown     - $\lambda \operatorname{trace} \bm{\epsilon}$
23868e843eeSJed Brown     - $\lambda \log \operatorname{trace} \bm{\epsilon}$
23968e843eeSJed Brown     - $\lambda \log J$
240bcb2dfaeSJed Brown
241bcb2dfaeSJed Brown   * - Volumetric Strain
24268e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}$
24368e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}$
24468e843eeSJed Brown     - $\operatorname{trace} \bm{E}$
245bcb2dfaeSJed Brown
24668e843eeSJed Brown   * - $\operatorname{trace} \bm{E}^2$
24768e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}^2$
24868e843eeSJed Brown     - $\operatorname{trace} \bm{\epsilon}^2$
24968e843eeSJed Brown     - $\operatorname{trace} \bm{E}^2$
250bcb2dfaeSJed Brown
25168e843eeSJed Brown   * - $\lvert J \rvert$
25268e843eeSJed Brown     - $1 + \operatorname{trace} \bm{\epsilon}$
25368e843eeSJed Brown     - $1 + \operatorname{trace} \bm{\epsilon}$
25468e843eeSJed Brown     - $\lvert J \rvert$
255bcb2dfaeSJed Brown
256bcb2dfaeSJed Brown   * - Strain Energy Density
25768e843eeSJed Brown     - $\frac{\lambda}{2} (\operatorname{trace} \bm{\epsilon})^2 + \mu \bm{\epsilon} : \bm{\epsilon}$
25868e843eeSJed Brown     - $\lambda (1 + \operatorname{trace} \bm{\epsilon}) (\log(1 + \operatorname{trace} \bm{\epsilon} ) - 1) + \mu \bm{\epsilon} : \bm{\epsilon}$
25968e843eeSJed Brown     - $\frac{\lambda}{2}(\log J)^2 + \mu \operatorname{trace} \bm{E} - \mu \log J$
26068e843eeSJed Brown:::
261bcb2dfaeSJed Brown
262bcb2dfaeSJed Brown[cubit]: https://cubit.sandia.gov/
263bcb2dfaeSJed Brown[this repository]: https://github.com/jeremylt/ceedSampleMeshes
264