Linear elasticity#
Author: Jørgen S. Dokken
SPDX-License-Identifier: MIT
We solve the equations of linear elasticity
with a manufactured displacement, which is localised around a point \(x_0\):
The displacement is discontinuous across the interfaces between cells, and the problem is
discretised with the symmetric interior penalty method [ABCM02] with the
stress \(\sigma(u)\) in place of \(\nabla u\), and with the Dirichlet condition imposed with Nitsche’s
method [Nit71]. The penalty parameter is scaled by \(2\mu + \lambda\).
Vector valued problems are only implemented for the
SubmeshApproach.
from mpi4py import MPI
from petsc4py import PETSc
import dolfinx
import numpy as np
import ufl
from dolfinx_padapt.adaptivity import solve_adaptive
from dolfinx_padapt.approaches import SubmeshApproach
from dolfinx_padapt.forms import Parameters
from dolfinx_padapt.models import ElasticityProblem
from dolfinx_padapt.plotting import Animation, plot_convergence
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 12, 12)
x0 = (0.35, 0.6)
def u_exact(x):
bump = ufl.exp(-60 * ((x[0] - x0[0]) ** 2 + (x[1] - x0[1]) ** 2))
return bump * ufl.as_vector((1, x0[0] - x[0]))
problem = ElasticityProblem(mesh, u_exact, mu=1.0, lmbda=10.0)
Error indicator#
The error indicator is the one of the other demos, with the stress in place of the gradient [HSchotzauW07]:
The adaptive loop#
The error is measured in the broken \(H^1\)-seminorm. We plot the magnitude of the displacement and the degree of each cell at every iteration.
params = Parameters(pmin=1, pmax=5)
approach = SubmeshApproach(problem, params)
degrees = approach.degrees
with Animation(mesh.comm, "elasticity.gif") as animation:
history = solve_adaptive(approach, max_iterations=12, tol=1e-4, callback=animation)
it dofs error eta update solve estim. values, degrees
0 1728 7.319e-01 3.083e+01 0.019 0.010 0.001 L2=0.02880792734, H1=0.7318584636, {1: 288}
1 1782 6.346e-01 2.233e+01 0.019 0.009 0.001 L2=0.02335412498, H1=0.6346373385, {1: 279, 2: 9}
2 1998 2.874e-01 9.308e+00 0.019 0.011 0.001 L2=0.006942178326, H1=0.2874381309, {1: 247, 2: 38, 3: 3}
3 2198 1.916e-01 5.247e+00 0.019 0.013 0.001 L2=0.003923147074, H1=0.1916474418, {1: 231, 2: 41, 3: 16}
4 2502 7.575e-02 2.494e+00 0.019 0.017 0.001 L2=0.001274120696, H1=0.07575229198, {1: 211, 2: 38, 3: 39}
5 2854 5.387e-02 1.330e+00 0.018 0.022 0.001 L2=0.001047847266, H1=0.05386600789, {1: 202, 2: 21, 3: 56, 4: 9}
6 3272 3.362e-02 6.583e-01 0.019 0.030 0.001 L2=0.0006272204921, H1=0.03361728728, {1: 184, 2: 24, 3: 52, 4: 28}
7 3544 2.766e-02 4.301e-01 0.018 0.034 0.001 L2=0.0004933949412, H1=0.02766253021, {1: 173, 2: 23, 3: 53, 4: 39}
8 3698 1.501e-02 3.478e-01 0.019 0.039 0.001 L2=0.000242732111, H1=0.01501153073, {1: 171, 2: 21, 3: 46, 4: 50}
9 4260 6.272e-03 1.751e-01 0.018 0.051 0.001 L2=9.646602617e-05, H1=0.006271657446, {1: 163, 2: 13, 3: 39, 4: 60, 5: 13}
10 4900 3.898e-03 8.017e-02 0.018 0.069 0.001 L2=7.13412301e-05, H1=0.00389763071, {1: 150, 2: 15, 3: 29, 4: 59, 5: 35}
11 5454 2.670e-03 4.692e-02 0.019 0.092 0.001 L2=5.15708978e-05, H1=0.002669678901, {1: 142, 2: 13, 3: 24, 4: 51, 5: 58}
Comparison with a uniform degree#
uniform = []
for k in range(params.pmin, params.pmax + 1):
degrees.set_degrees(np.full(degrees.num_owned_cells, k, dtype=np.int32))
result = solve_adaptive(approach, max_iterations=1)[0]
PETSc.Sys.Print(f"P{k}: {result.num_dofs} dofs, H1 error {result.error:.3e}")
uniform.append(result)
P1: 1728 dofs, H1 error 7.319e-01
P2: 3456 dofs, H1 error 1.637e-01
P3: 5760 dofs, H1 error 2.728e-02
P4: 8640 dofs, H1 error 4.012e-03
P5: 12096 dofs, H1 error 5.385e-04
if mesh.comm.rank == 0:
plot_convergence(
{"adaptive": history, "uniform degree": uniform},
"elasticity_convergence.png",
ylabel=r"$\Vert\nabla(u_h - u_{ex})\Vert_{L^2(\Omega)}$",
)

Douglas N. Arnold, Franco Brezzi, Bernardo Cockburn, and L. Donatella Marini. Unified analysis of discontinuous Galerkin methods for elliptic problems. SIAM Journal on Numerical Analysis, 39(5):1749–1779, 2002. doi:10.1137/S0036142901384162.
Paul Houston, Dominik Schötzau, and Thomas P. Wihler. Energy norm a posteriori error estimation of hp-adaptive discontinuous Galerkin methods for elliptic problems. Mathematical Models and Methods in Applied Sciences, 17(1):33–62, 2007. doi:10.1142/S0218202507001826.
Joachim Nitsche. Über ein Variationsprinzip zur Lösung von Dirichlet-Problemen bei Verwendung von Teilräumen, die keinen Randbedingungen unterworfen sind. Abhandlungen aus dem Mathematischen Seminar der Universität Hamburg, 36(1):9–15, 1971. doi:10.1007/BF02995904.