xref: /libCEED/examples/solids/README.md (revision bcb2dfae4c301ddfdddf58806f08f6e7d17f4ea5)
1*bcb2dfaeSJed Brown# libCEED: Solid Mechanics Example
2*bcb2dfaeSJed Brown
3*bcb2dfaeSJed BrownThis page provides a description of the solid mechanics example for the
4*bcb2dfaeSJed BrownlibCEED library, based on PETSc.
5*bcb2dfaeSJed Brown
6*bcb2dfaeSJed BrownThis code solves the steady-state static momentum balance equations using unstructured high-order finite/spectral element spatial discretizations.
7*bcb2dfaeSJed 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.
8*bcb2dfaeSJed BrownAll three of these formulations are for compressible materials.
9*bcb2dfaeSJed Brown
10*bcb2dfaeSJed BrownBuild by using:
11*bcb2dfaeSJed Brown
12*bcb2dfaeSJed Brown```
13*bcb2dfaeSJed Brownmake
14*bcb2dfaeSJed Brown```
15*bcb2dfaeSJed Brown
16*bcb2dfaeSJed Brownand run with:
17*bcb2dfaeSJed Brown
18*bcb2dfaeSJed Brown```
19*bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree [degree] -nu [nu] -E [E] [boundary options] -problem [problem type] -forcing [forcing] -ceed [ceed]
20*bcb2dfaeSJed Brown```
21*bcb2dfaeSJed Brown
22*bcb2dfaeSJed Brown## Runtime options
23*bcb2dfaeSJed Brown
24*bcb2dfaeSJed Brown% inclusion-solids-marker
25*bcb2dfaeSJed Brown
26*bcb2dfaeSJed BrownThe elasticity min-app is controlled via command-line options, the following of which are mandatory.
27*bcb2dfaeSJed Brown
28*bcb2dfaeSJed Brown```{eval-rst}
29*bcb2dfaeSJed Brown.. list-table:: Mandatory Runtime Options
30*bcb2dfaeSJed Brown   :header-rows: 1
31*bcb2dfaeSJed Brown
32*bcb2dfaeSJed Brown   * - Option
33*bcb2dfaeSJed Brown     - Description
34*bcb2dfaeSJed Brown
35*bcb2dfaeSJed Brown   * - :code:`-mesh [filename]`
36*bcb2dfaeSJed Brown     - Path to mesh file in any format supported by PETSc.
37*bcb2dfaeSJed Brown
38*bcb2dfaeSJed Brown   * - :code:`-degree [int]`
39*bcb2dfaeSJed Brown     - Polynomial degree of the finite element basis
40*bcb2dfaeSJed Brown
41*bcb2dfaeSJed Brown   * - :code:`-E [real]`
42*bcb2dfaeSJed Brown     - `Young's modulus <https://en.wikipedia.org/wiki/Young%27s_modulus>`_, :math:`E > 0`
43*bcb2dfaeSJed Brown
44*bcb2dfaeSJed Brown   * - :code:`-nu [real]`
45*bcb2dfaeSJed Brown     - `Poisson's ratio <https://en.wikipedia.org/wiki/Poisson%27s_ratio>`_, :math:`\nu < 0.5`
46*bcb2dfaeSJed Brown
47*bcb2dfaeSJed Brown   * - :code:`-bc_clamp [int list]`
48*bcb2dfaeSJed Brown     - List of face sets on which to displace by :code:`-bc_clamp_[facenumber]_translate [x,y,z]` and/or :code:`bc_clamp_[facenumber]_rotate [rx,ry,rz,c_0,c_1]`
49*bcb2dfaeSJed Brown
50*bcb2dfaeSJed Brown```
51*bcb2dfaeSJed Brown
52*bcb2dfaeSJed BrownNote: The default for a clamped face is zero displacement. All displacement is with respect to the initial configuration.
53*bcb2dfaeSJed Brown
54*bcb2dfaeSJed Brown> - - {code}`-bc_traction [int list]`
55*bcb2dfaeSJed Brown>   - List of face sets on which to set traction boundary conditions with the traction vector {code}`-bc_traction_[facenumber] [tx,ty,tz]`
56*bcb2dfaeSJed Brown
57*bcb2dfaeSJed Brown:::{note}
58*bcb2dfaeSJed BrownThis solver can use any mesh format that PETSc's `DMPlex` can read (Exodus, Gmsh, Med, etc.).
59*bcb2dfaeSJed 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].
60*bcb2dfaeSJed BrownNote that many mesh formats require PETSc to be configured appropriately; e.g., `--download-exodusii` for Exodus support.
61*bcb2dfaeSJed Brown:::
62*bcb2dfaeSJed Brown
63*bcb2dfaeSJed BrownConsider the specific example of the mesh seen below:
64*bcb2dfaeSJed Brown
65*bcb2dfaeSJed Brown```{image} https://github.com/jeremylt/ceedSampleMeshes/raw/master/cylinderDiagram.png
66*bcb2dfaeSJed Brown```
67*bcb2dfaeSJed Brown
68*bcb2dfaeSJed BrownWith the sidesets defined in the figure, we provide here an example of a minimal set of command line options:
69*bcb2dfaeSJed Brown
70*bcb2dfaeSJed Brown```
71*bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree 4 -E 1e6 -nu 0.3 -bc_clamp 998,999 -bc_clamp_998_translate 0,-0.5,1
72*bcb2dfaeSJed Brown```
73*bcb2dfaeSJed Brown
74*bcb2dfaeSJed 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$.
75*bcb2dfaeSJed Brown
76*bcb2dfaeSJed 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]`.
77*bcb2dfaeSJed Brown
78*bcb2dfaeSJed 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:
79*bcb2dfaeSJed Brown
80*bcb2dfaeSJed Brown```
81*bcb2dfaeSJed 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
82*bcb2dfaeSJed Brown```
83*bcb2dfaeSJed Brown
84*bcb2dfaeSJed Brown:::{note}
85*bcb2dfaeSJed 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.
86*bcb2dfaeSJed Brown:::
87*bcb2dfaeSJed Brown
88*bcb2dfaeSJed 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.
89*bcb2dfaeSJed Brown
90*bcb2dfaeSJed BrownThe command line options just shown are the minimum requirements to run the mini-app, but additional options may also be set as follows
91*bcb2dfaeSJed Brown
92*bcb2dfaeSJed Brown```{eval-rst}
93*bcb2dfaeSJed Brown.. list-table:: Additional Runtime Options
94*bcb2dfaeSJed Brown   :header-rows: 1
95*bcb2dfaeSJed Brown
96*bcb2dfaeSJed Brown   * - Option
97*bcb2dfaeSJed Brown     - Description
98*bcb2dfaeSJed Brown     - Default value
99*bcb2dfaeSJed Brown
100*bcb2dfaeSJed Brown   * - :code:`-ceed`
101*bcb2dfaeSJed Brown     - CEED resource specifier
102*bcb2dfaeSJed Brown     - :code:`/cpu/self`
103*bcb2dfaeSJed Brown
104*bcb2dfaeSJed Brown   * - :code:`-qextra`
105*bcb2dfaeSJed Brown     - Number of extra quadrature points
106*bcb2dfaeSJed Brown     - :code:`0`
107*bcb2dfaeSJed Brown
108*bcb2dfaeSJed Brown   * - :code:`-test`
109*bcb2dfaeSJed Brown     - Run in test mode
110*bcb2dfaeSJed Brown     -
111*bcb2dfaeSJed Brown
112*bcb2dfaeSJed Brown   * - :code:`-problem`
113*bcb2dfaeSJed Brown     - Problem to solve (:code:`Linear`, :code:`SS-NH`, :code:`FSInitial-NH1`, etc.)
114*bcb2dfaeSJed Brown     - :code:`Linear`
115*bcb2dfaeSJed Brown
116*bcb2dfaeSJed Brown   * - :code:`-forcing`
117*bcb2dfaeSJed Brown     -  Forcing term option (:code:`none`, :code:`constant`, or :code:`mms`)
118*bcb2dfaeSJed Brown     - :code:`none`
119*bcb2dfaeSJed Brown
120*bcb2dfaeSJed Brown   * - :code:`-forcing_vec`
121*bcb2dfaeSJed Brown     -  Forcing vector
122*bcb2dfaeSJed Brown     - :code:`0,-1,0`
123*bcb2dfaeSJed Brown
124*bcb2dfaeSJed Brown   * - :code:`-multigrid`
125*bcb2dfaeSJed Brown     - Multigrid coarsening to use (:code:`logarithmic`, :code:`uniform` or :code:`none`)
126*bcb2dfaeSJed Brown     - :code:`logarithmic`
127*bcb2dfaeSJed Brown
128*bcb2dfaeSJed Brown   * - :code:`-nu_smoother [real]`
129*bcb2dfaeSJed Brown     - Poisson's ratio for multigrid smoothers, :math:`\nu < 0.5`
130*bcb2dfaeSJed Brown     -
131*bcb2dfaeSJed Brown
132*bcb2dfaeSJed Brown   * - :code:`-num_steps`
133*bcb2dfaeSJed Brown     - Number of load increments for continuation method
134*bcb2dfaeSJed Brown     - :code:`1` if :code:`Linear` else :code:`10`
135*bcb2dfaeSJed Brown
136*bcb2dfaeSJed Brown   * - :code:`-view_soln`
137*bcb2dfaeSJed Brown     - Output solution at each load increment for viewing
138*bcb2dfaeSJed Brown     -
139*bcb2dfaeSJed Brown
140*bcb2dfaeSJed Brown   * - :code:`-view_final_soln`
141*bcb2dfaeSJed Brown     - Output solution at final load increment for viewing
142*bcb2dfaeSJed Brown     -
143*bcb2dfaeSJed Brown
144*bcb2dfaeSJed Brown   * - :code:`-snes_view`
145*bcb2dfaeSJed Brown     - View PETSc :code:`SNES` nonlinear solver configuration
146*bcb2dfaeSJed Brown     -
147*bcb2dfaeSJed Brown
148*bcb2dfaeSJed Brown   * - :code:`-log_view`
149*bcb2dfaeSJed Brown     - View PETSc performance log
150*bcb2dfaeSJed Brown     -
151*bcb2dfaeSJed Brown
152*bcb2dfaeSJed Brown   * - :code:`-output_dir`
153*bcb2dfaeSJed Brown     - Output directory
154*bcb2dfaeSJed Brown     - :code:`.`
155*bcb2dfaeSJed Brown
156*bcb2dfaeSJed Brown   * - :code:`-help`
157*bcb2dfaeSJed Brown     - View comprehensive information about run-time options
158*bcb2dfaeSJed Brown     -
159*bcb2dfaeSJed Brown```
160*bcb2dfaeSJed Brown
161*bcb2dfaeSJed BrownTo verify the convergence of the linear elasticity formulation on a given mesh with the method of manufactured solutions, run:
162*bcb2dfaeSJed Brown
163*bcb2dfaeSJed Brown```
164*bcb2dfaeSJed Brown./elasticity -mesh [mesh] -degree [degree] -nu [nu] -E [E] -forcing mms
165*bcb2dfaeSJed Brown```
166*bcb2dfaeSJed Brown
167*bcb2dfaeSJed BrownThis option attempts to recover a known solution from an analytically computed forcing term.
168*bcb2dfaeSJed Brown
169*bcb2dfaeSJed Brown### On algebraic solvers
170*bcb2dfaeSJed Brown
171*bcb2dfaeSJed BrownThis mini-app is configured to use the following Newton-Krylov-Multigrid method by default.
172*bcb2dfaeSJed Brown
173*bcb2dfaeSJed Brown- Newton-type methods for the nonlinear solve, with the hyperelasticity models globalized using load increments.
174*bcb2dfaeSJed Brown- Preconditioned conjugate gradients to solve the symmetric positive definite linear systems arising at each Newton step.
175*bcb2dfaeSJed Brown- Preconditioning via $p$-version multigrid coarsening to linear elements, with algebraic multigrid (PETSc's `GAMG`) for the coarse solve.
176*bcb2dfaeSJed Brown  The default smoother uses degree 3 Chebyshev with Jacobi preconditioning.
177*bcb2dfaeSJed Brown  (Lower degree is often faster, albeit less robust; try {code}`-outer_mg_levels_ksp_max_it 2`, for example.)
178*bcb2dfaeSJed 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).
179*bcb2dfaeSJed Brown
180*bcb2dfaeSJed BrownMany related solvers can be implemented by composing PETSc command-line options.
181*bcb2dfaeSJed Brown
182*bcb2dfaeSJed Brown### Nondimensionalization
183*bcb2dfaeSJed Brown
184*bcb2dfaeSJed BrownQuantities such as the Young's modulus vary over many orders of magnitude, and thus can lead to poorly scaled equations.
185*bcb2dfaeSJed BrownOne can nondimensionalize the model by choosing an alternate system of units, such that displacements and residuals are of reasonable scales.
186*bcb2dfaeSJed Brown
187*bcb2dfaeSJed Brown```{eval-rst}
188*bcb2dfaeSJed Brown.. list-table:: (Non)dimensionalization options
189*bcb2dfaeSJed Brown   :header-rows: 1
190*bcb2dfaeSJed Brown
191*bcb2dfaeSJed Brown   * - Option
192*bcb2dfaeSJed Brown     - Description
193*bcb2dfaeSJed Brown     - Default value
194*bcb2dfaeSJed Brown
195*bcb2dfaeSJed Brown   * - :code:`-units_meter`
196*bcb2dfaeSJed Brown     - 1 meter in scaled length units
197*bcb2dfaeSJed Brown     - :code:`1`
198*bcb2dfaeSJed Brown
199*bcb2dfaeSJed Brown   * - :code:`-units_second`
200*bcb2dfaeSJed Brown     - 1 second in scaled time units
201*bcb2dfaeSJed Brown     - :code:`1`
202*bcb2dfaeSJed Brown
203*bcb2dfaeSJed Brown   * - :code:`-units_kilogram`
204*bcb2dfaeSJed Brown     - 1 kilogram in scaled mass units
205*bcb2dfaeSJed Brown     - :code:`1`
206*bcb2dfaeSJed Brown```
207*bcb2dfaeSJed Brown
208*bcb2dfaeSJed BrownFor example, consider a problem involving metals subject to gravity.
209*bcb2dfaeSJed Brown
210*bcb2dfaeSJed Brown```{eval-rst}
211*bcb2dfaeSJed Brown.. list-table:: Characteristic units for metals
212*bcb2dfaeSJed Brown   :header-rows: 1
213*bcb2dfaeSJed Brown
214*bcb2dfaeSJed Brown   * - Quantity
215*bcb2dfaeSJed Brown     - Typical value in SI units
216*bcb2dfaeSJed Brown
217*bcb2dfaeSJed Brown   * - Displacement, :math:`\bm u`
218*bcb2dfaeSJed Brown     - :math:`1 \,\mathrm{cm} = 10^{-2} \,\mathrm m`
219*bcb2dfaeSJed Brown
220*bcb2dfaeSJed Brown   * - Young's modulus, :math:`E`
221*bcb2dfaeSJed Brown     - :math:`10^{11} \,\mathrm{Pa} = 10^{11} \,\mathrm{kg}\, \mathrm{m}^{-1}\, \mathrm s^{-2}`
222*bcb2dfaeSJed Brown
223*bcb2dfaeSJed Brown   * - Body force (gravity) on volume, :math:`\int \rho \bm g`
224*bcb2dfaeSJed Brown     - :math:`5 \cdot 10^4 \,\mathrm{kg}\, \mathrm m^{-2} \, \mathrm s^{-2} \cdot (\text{volume} \, \mathrm m^3)`
225*bcb2dfaeSJed Brown```
226*bcb2dfaeSJed Brown
227*bcb2dfaeSJed 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.
228*bcb2dfaeSJed 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.
229*bcb2dfaeSJed Brown
230*bcb2dfaeSJed Brown### Diagnostic Quantities
231*bcb2dfaeSJed Brown
232*bcb2dfaeSJed BrownDiagnostic quantities for viewing are provided when the command line options for visualization output, {code}`-view_soln` or {code}`-view_final_soln` are used.
233*bcb2dfaeSJed 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.
234*bcb2dfaeSJed BrownThe table below summarizes the formulations of each of these quantities for each problem type.
235*bcb2dfaeSJed Brown
236*bcb2dfaeSJed Brown```{eval-rst}
237*bcb2dfaeSJed Brown.. list-table:: Diagnostic quantities
238*bcb2dfaeSJed Brown   :header-rows: 1
239*bcb2dfaeSJed Brown
240*bcb2dfaeSJed Brown   * - Quantity
241*bcb2dfaeSJed Brown     - Linear Elasticity
242*bcb2dfaeSJed Brown     - Hyperelasticity, Small Strain
243*bcb2dfaeSJed Brown     - Hyperelasticity, Finite Strain
244*bcb2dfaeSJed Brown
245*bcb2dfaeSJed Brown   * - Pressure
246*bcb2dfaeSJed Brown     - :math:`\lambda \operatorname{trace} \bm{\epsilon}`
247*bcb2dfaeSJed Brown     - :math:`\lambda \log \operatorname{trace} \bm{\epsilon}`
248*bcb2dfaeSJed Brown     - :math:`\lambda \log J`
249*bcb2dfaeSJed Brown
250*bcb2dfaeSJed Brown   * - Volumetric Strain
251*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{\epsilon}`
252*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{\epsilon}`
253*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{E}`
254*bcb2dfaeSJed Brown
255*bcb2dfaeSJed Brown   * - :math:`\operatorname{trace} \bm{E}^2`
256*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{\epsilon}^2`
257*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{\epsilon}^2`
258*bcb2dfaeSJed Brown     - :math:`\operatorname{trace} \bm{E}^2`
259*bcb2dfaeSJed Brown
260*bcb2dfaeSJed Brown   * - :math:`\lvert J \rvert`
261*bcb2dfaeSJed Brown     - :math:`1 + \operatorname{trace} \bm{\epsilon}`
262*bcb2dfaeSJed Brown     - :math:`1 + \operatorname{trace} \bm{\epsilon}`
263*bcb2dfaeSJed Brown     - :math:`\lvert J \rvert`
264*bcb2dfaeSJed Brown
265*bcb2dfaeSJed Brown   * - Strain Energy Density
266*bcb2dfaeSJed Brown     - :math:`\frac{\lambda}{2} (\operatorname{trace} \bm{\epsilon})^2 + \mu \bm{\epsilon} : \bm{\epsilon}`
267*bcb2dfaeSJed Brown     - :math:`\lambda (1 + \operatorname{trace} \bm{\epsilon}) (\log(1 + \operatorname{trace} \bm{\epsilon} ) - 1) + \mu \bm{\epsilon} : \bm{\epsilon}`
268*bcb2dfaeSJed Brown     - :math:`\frac{\lambda}{2}(\log J)^2 + \mu \operatorname{trace} \bm{E} - \mu \log J`
269*bcb2dfaeSJed Brown```
270*bcb2dfaeSJed Brown
271*bcb2dfaeSJed Brown[cubit]: https://cubit.sandia.gov/
272*bcb2dfaeSJed Brown[this repository]: https://github.com/jeremylt/ceedSampleMeshes
273