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. 5b8962995SJeremy L ThompsonPETSc v3.17 or a development version of PETSc at commit 0e95d842 or later is required. 6bcb2dfaeSJed Brown 7bcb2dfaeSJed BrownThis code solves the steady-state static momentum balance equations using unstructured high-order finite/spectral element spatial discretizations. 8bcb2dfaeSJed 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. 9bcb2dfaeSJed BrownAll three of these formulations are for compressible materials. 10bcb2dfaeSJed Brown 11bcb2dfaeSJed BrownBuild by using: 12bcb2dfaeSJed Brown 13bcb2dfaeSJed Brown``` 14bcb2dfaeSJed Brownmake 15bcb2dfaeSJed Brown``` 16bcb2dfaeSJed Brown 17bcb2dfaeSJed Brownand run with: 18bcb2dfaeSJed Brown 19bcb2dfaeSJed Brown``` 20bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree [degree] -nu [nu] -E [E] [boundary options] -problem [problem type] -forcing [forcing] -ceed [ceed] 21bcb2dfaeSJed Brown``` 22bcb2dfaeSJed Brown 23bcb2dfaeSJed Brown## Runtime options 24bcb2dfaeSJed Brown 25bcb2dfaeSJed Brown% inclusion-solids-marker 26bcb2dfaeSJed Brown 27b425b72cSLeila GhaffariThe elasticity mini-app is controlled via command-line options, the following of which are mandatory. 28bcb2dfaeSJed Brown 2968e843eeSJed Brown:::{list-table} Mandatory Runtime Options 30bcb2dfaeSJed Brown:header-rows: 1 3168e843eeSJed Brown:widths: 3 7 32bcb2dfaeSJed Brown 33bcb2dfaeSJed Brown* - Option 34bcb2dfaeSJed Brown - Description 3568e843eeSJed Brown* - `-mesh [filename]` 36bcb2dfaeSJed Brown - Path to mesh file in any format supported by PETSc. 3768e843eeSJed Brown* - `-degree [int]` 38bcb2dfaeSJed Brown - Polynomial degree of the finite element basis 3968e843eeSJed Brown* - `-E [real]` 4068e843eeSJed Brown - [Young's modulus](https://en.wikipedia.org/wiki/Young%27s_modulus), $E > 0$ 4168e843eeSJed Brown* - `-nu [real]` 4268e843eeSJed Brown - [Poisson's ratio](https://en.wikipedia.org/wiki/Poisson%27s_ratio), $\nu < 0.5$ 4368e843eeSJed Brown* - `-bc_clamp [int list]` 4468e843eeSJed Brown - List of face sets on which to displace by `-bc_clamp_[facenumber]_translate [x,y,z]` 4568e843eeSJed Brown and/or `bc_clamp_[facenumber]_rotate [rx,ry,rz,c_0,c_1]`. Note: The default 4668e843eeSJed Brown for a clamped face is zero displacement. All displacement is with respect to 4768e843eeSJed Brown the initial configuration. 4868e843eeSJed Brown* - `-bc_traction [int list]` 4968e843eeSJed Brown - List of face sets on which to set traction boundary conditions with the 5068e843eeSJed Brown traction vector `-bc_traction_[facenumber] [tx,ty,tz]` 5168e843eeSJed Brown::: 52bcb2dfaeSJed Brown 53bcb2dfaeSJed Brown:::{note} 54bcb2dfaeSJed BrownThis solver can use any mesh format that PETSc's `DMPlex` can read (Exodus, Gmsh, Med, etc.). 55bcb2dfaeSJed 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]. 56bcb2dfaeSJed BrownNote that many mesh formats require PETSc to be configured appropriately; e.g., `--download-exodusii` for Exodus support. 57bcb2dfaeSJed Brown::: 58bcb2dfaeSJed Brown 59bcb2dfaeSJed BrownConsider the specific example of the mesh seen below: 60bcb2dfaeSJed Brown 61bcb2dfaeSJed Brown```{image} https://github.com/jeremylt/ceedSampleMeshes/raw/master/cylinderDiagram.png 62bcb2dfaeSJed Brown``` 63bcb2dfaeSJed Brown 64bcb2dfaeSJed BrownWith the sidesets defined in the figure, we provide here an example of a minimal set of command line options: 65bcb2dfaeSJed Brown 66bcb2dfaeSJed Brown``` 67bcb2dfaeSJed Brown./elasticity -mesh [.exo file] -degree 4 -E 1e6 -nu 0.3 -bc_clamp 998,999 -bc_clamp_998_translate 0,-0.5,1 68bcb2dfaeSJed Brown``` 69bcb2dfaeSJed Brown 70bcb2dfaeSJed 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$. 71bcb2dfaeSJed Brown 72bcb2dfaeSJed 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]`. 73bcb2dfaeSJed Brown 74bcb2dfaeSJed 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: 75bcb2dfaeSJed Brown 76bcb2dfaeSJed Brown``` 77bcb2dfaeSJed 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 78bcb2dfaeSJed Brown``` 79bcb2dfaeSJed Brown 80bcb2dfaeSJed Brown:::{note} 81bcb2dfaeSJed 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. 82bcb2dfaeSJed Brown::: 83bcb2dfaeSJed Brown 84bcb2dfaeSJed 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. 85bcb2dfaeSJed Brown 86bcb2dfaeSJed BrownThe command line options just shown are the minimum requirements to run the mini-app, but additional options may also be set as follows 87bcb2dfaeSJed Brown 8868e843eeSJed Brown:::{list-table} Additional Runtime Options 89bcb2dfaeSJed Brown:header-rows: 1 90bcb2dfaeSJed Brown 91bcb2dfaeSJed Brown* - Option 92bcb2dfaeSJed Brown - Description 93bcb2dfaeSJed Brown - Default value 94bcb2dfaeSJed Brown 9568e843eeSJed Brown* - `-ceed` 96bcb2dfaeSJed Brown - CEED resource specifier 9768e843eeSJed Brown - `/cpu/self` 98bcb2dfaeSJed Brown 9968e843eeSJed Brown* - `-qextra` 100bcb2dfaeSJed Brown - Number of extra quadrature points 10168e843eeSJed Brown - `0` 102bcb2dfaeSJed Brown 10368e843eeSJed Brown* - `-test` 104bcb2dfaeSJed Brown - Run in test mode 105bcb2dfaeSJed Brown - 106bcb2dfaeSJed Brown 10768e843eeSJed Brown* - `-problem` 10868e843eeSJed Brown - Problem to solve (`Linear`, `SS-NH`, `FSInitial-NH1`, etc.) 10968e843eeSJed Brown - `Linear` 110bcb2dfaeSJed Brown 11168e843eeSJed Brown* - `-forcing` 11268e843eeSJed Brown - Forcing term option (`none`, `constant`, or `mms`) 11368e843eeSJed Brown - `none` 114bcb2dfaeSJed Brown 11568e843eeSJed Brown* - `-forcing_vec` 116bcb2dfaeSJed Brown - Forcing vector 11768e843eeSJed Brown - `0,-1,0` 118bcb2dfaeSJed Brown 11968e843eeSJed Brown* - `-multigrid` 12068e843eeSJed Brown - Multigrid coarsening to use (`logarithmic`, `uniform` or `none`) 12168e843eeSJed Brown - `logarithmic` 122bcb2dfaeSJed Brown 12368e843eeSJed Brown* - `-nu_smoother [real]` 12468e843eeSJed Brown - Poisson's ratio for multigrid smoothers, $\nu < 0.5$ 125bcb2dfaeSJed Brown - 126bcb2dfaeSJed Brown 12768e843eeSJed Brown* - `-num_steps` 128bcb2dfaeSJed Brown - Number of load increments for continuation method 12968e843eeSJed Brown - `1` if `Linear` else `10` 130bcb2dfaeSJed Brown 13168e843eeSJed Brown* - `-view_soln` 132bcb2dfaeSJed Brown - Output solution at each load increment for viewing 133bcb2dfaeSJed Brown - 134bcb2dfaeSJed Brown 13568e843eeSJed Brown* - `-view_final_soln` 136bcb2dfaeSJed Brown - Output solution at final load increment for viewing 137bcb2dfaeSJed Brown - 138bcb2dfaeSJed Brown 13968e843eeSJed Brown* - `-snes_view` 14068e843eeSJed Brown - View PETSc `SNES` nonlinear solver configuration 141bcb2dfaeSJed Brown - 142bcb2dfaeSJed Brown 14368e843eeSJed Brown* - `-log_view` 144bcb2dfaeSJed Brown - View PETSc performance log 145bcb2dfaeSJed Brown - 146bcb2dfaeSJed Brown 14768e843eeSJed Brown* - `-output_dir` 148bcb2dfaeSJed Brown - Output directory 14968e843eeSJed Brown - `.` 150bcb2dfaeSJed Brown 15168e843eeSJed Brown* - `-help` 152bcb2dfaeSJed Brown - View comprehensive information about run-time options 153bcb2dfaeSJed Brown - 15468e843eeSJed Brown::: 155bcb2dfaeSJed Brown 156bcb2dfaeSJed BrownTo verify the convergence of the linear elasticity formulation on a given mesh with the method of manufactured solutions, run: 157bcb2dfaeSJed Brown 158bcb2dfaeSJed Brown``` 159bcb2dfaeSJed Brown./elasticity -mesh [mesh] -degree [degree] -nu [nu] -E [E] -forcing mms 160bcb2dfaeSJed Brown``` 161bcb2dfaeSJed Brown 162bcb2dfaeSJed BrownThis option attempts to recover a known solution from an analytically computed forcing term. 163bcb2dfaeSJed Brown 164bcb2dfaeSJed Brown### On algebraic solvers 165bcb2dfaeSJed Brown 166bcb2dfaeSJed BrownThis mini-app is configured to use the following Newton-Krylov-Multigrid method by default. 167bcb2dfaeSJed Brown 168bcb2dfaeSJed Brown- Newton-type methods for the nonlinear solve, with the hyperelasticity models globalized using load increments. 169bcb2dfaeSJed Brown- Preconditioned conjugate gradients to solve the symmetric positive definite linear systems arising at each Newton step. 170bcb2dfaeSJed Brown- Preconditioning via $p$-version multigrid coarsening to linear elements, with algebraic multigrid (PETSc's `GAMG`) for the coarse solve. 171bcb2dfaeSJed Brown The default smoother uses degree 3 Chebyshev with Jacobi preconditioning. 172bcb2dfaeSJed Brown (Lower degree is often faster, albeit less robust; try {code}`-outer_mg_levels_ksp_max_it 2`, for example.) 173bcb2dfaeSJed 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). 174bcb2dfaeSJed Brown 175bcb2dfaeSJed BrownMany related solvers can be implemented by composing PETSc command-line options. 176bcb2dfaeSJed Brown 177bcb2dfaeSJed Brown### Nondimensionalization 178bcb2dfaeSJed Brown 179bcb2dfaeSJed BrownQuantities such as the Young's modulus vary over many orders of magnitude, and thus can lead to poorly scaled equations. 180bcb2dfaeSJed BrownOne can nondimensionalize the model by choosing an alternate system of units, such that displacements and residuals are of reasonable scales. 181bcb2dfaeSJed Brown 18268e843eeSJed Brown:::{list-table} (Non)dimensionalization options 183bcb2dfaeSJed Brown:header-rows: 1 184bcb2dfaeSJed Brown 185bcb2dfaeSJed Brown* - Option 186bcb2dfaeSJed Brown - Description 187bcb2dfaeSJed Brown - Default value 188bcb2dfaeSJed Brown 189*1fbe68c1SLawrence Mitchell* - `-units_meter` 190bcb2dfaeSJed Brown - 1 meter in scaled length units 191*1fbe68c1SLawrence Mitchell - `1` 192bcb2dfaeSJed Brown 193*1fbe68c1SLawrence Mitchell* - `-units_second` 194bcb2dfaeSJed Brown - 1 second in scaled time units 195*1fbe68c1SLawrence Mitchell - `1` 196bcb2dfaeSJed Brown 197*1fbe68c1SLawrence Mitchell* - `-units_kilogram` 198bcb2dfaeSJed Brown - 1 kilogram in scaled mass units 199*1fbe68c1SLawrence Mitchell - `1` 20068e843eeSJed Brown::: 201bcb2dfaeSJed Brown 202bcb2dfaeSJed BrownFor example, consider a problem involving metals subject to gravity. 203bcb2dfaeSJed Brown 20468e843eeSJed Brown:::{list-table} Characteristic units for metals 205bcb2dfaeSJed Brown:header-rows: 1 206bcb2dfaeSJed Brown 207bcb2dfaeSJed Brown* - Quantity 208bcb2dfaeSJed Brown - Typical value in SI units 209bcb2dfaeSJed Brown 21068e843eeSJed Brown* - Displacement, $\bm u$ 21168e843eeSJed Brown - $1 \,\mathrm{cm} = 10^{-2} \,\mathrm m$ 212bcb2dfaeSJed Brown 21368e843eeSJed Brown* - Young's modulus, $E$ 21468e843eeSJed Brown - $10^{11} \,\mathrm{Pa} = 10^{11} \,\mathrm{kg}\, \mathrm{m}^{-1}\, \mathrm s^{-2}$ 215bcb2dfaeSJed Brown 21668e843eeSJed Brown* - Body force (gravity) on volume, $\int \rho \bm g$ 21768e843eeSJed Brown - $5 \cdot 10^4 \,\mathrm{kg}\, \mathrm m^{-2} \, \mathrm s^{-2} \cdot (\text{volume} \, \mathrm m^3)$ 21868e843eeSJed Brown::: 219bcb2dfaeSJed Brown 220bcb2dfaeSJed 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. 221bcb2dfaeSJed 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. 222bcb2dfaeSJed Brown 223bcb2dfaeSJed Brown### Diagnostic Quantities 224bcb2dfaeSJed Brown 225bcb2dfaeSJed BrownDiagnostic quantities for viewing are provided when the command line options for visualization output, {code}`-view_soln` or {code}`-view_final_soln` are used. 226bcb2dfaeSJed 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. 227bcb2dfaeSJed BrownThe table below summarizes the formulations of each of these quantities for each problem type. 228bcb2dfaeSJed Brown 22968e843eeSJed Brown:::{list-table} Diagnostic quantities 230bcb2dfaeSJed Brown :header-rows: 1 231bcb2dfaeSJed Brown 232bcb2dfaeSJed Brown * - Quantity 233bcb2dfaeSJed Brown - Linear Elasticity 234bcb2dfaeSJed Brown - Hyperelasticity, Small Strain 235bcb2dfaeSJed Brown - Hyperelasticity, Finite Strain 236bcb2dfaeSJed Brown 237bcb2dfaeSJed Brown * - Pressure 23868e843eeSJed Brown - $\lambda \operatorname{trace} \bm{\epsilon}$ 23968e843eeSJed Brown - $\lambda \log \operatorname{trace} \bm{\epsilon}$ 24068e843eeSJed Brown - $\lambda \log J$ 241bcb2dfaeSJed Brown 242bcb2dfaeSJed Brown * - Volumetric Strain 24368e843eeSJed Brown - $\operatorname{trace} \bm{\epsilon}$ 24468e843eeSJed Brown - $\operatorname{trace} \bm{\epsilon}$ 24568e843eeSJed Brown - $\operatorname{trace} \bm{E}$ 246bcb2dfaeSJed Brown 24768e843eeSJed Brown * - $\operatorname{trace} \bm{E}^2$ 24868e843eeSJed Brown - $\operatorname{trace} \bm{\epsilon}^2$ 24968e843eeSJed Brown - $\operatorname{trace} \bm{\epsilon}^2$ 25068e843eeSJed Brown - $\operatorname{trace} \bm{E}^2$ 251bcb2dfaeSJed Brown 25268e843eeSJed Brown * - $\lvert J \rvert$ 25368e843eeSJed Brown - $1 + \operatorname{trace} \bm{\epsilon}$ 25468e843eeSJed Brown - $1 + \operatorname{trace} \bm{\epsilon}$ 25568e843eeSJed Brown - $\lvert J \rvert$ 256bcb2dfaeSJed Brown 257bcb2dfaeSJed Brown * - Strain Energy Density 25868e843eeSJed Brown - $\frac{\lambda}{2} (\operatorname{trace} \bm{\epsilon})^2 + \mu \bm{\epsilon} : \bm{\epsilon}$ 25968e843eeSJed Brown - $\lambda (1 + \operatorname{trace} \bm{\epsilon}) (\log(1 + \operatorname{trace} \bm{\epsilon} ) - 1) + \mu \bm{\epsilon} : \bm{\epsilon}$ 26068e843eeSJed Brown - $\frac{\lambda}{2}(\log J)^2 + \mu \operatorname{trace} \bm{E} - \mu \log J$ 26168e843eeSJed Brown::: 262bcb2dfaeSJed Brown 263bcb2dfaeSJed Brown[cubit]: https://cubit.sandia.gov/ 264bcb2dfaeSJed Brown[this repository]: https://github.com/jeremylt/ceedSampleMeshes 265