Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
Linear Elasticity Assembly (DG)

// Author: Francesco Rosnati franc.nosp@m.esco.nosp@m..rosn.nosp@m.ati@.nosp@m.polim.nosp@m.i.it

This tutorial describes the symmetric interior penalty discontinuous Galerkin (SIPG) formulation of linear elasticity and its cellwise assembly in Vulpes. The same formulation is used by the two-dimensional and three-dimensional examples:

The formulation and assembly are developed once for \(d\in\{2,3\}\). The manufactured solutions and boundary data used to verify the two implementations are presented together in Section 4.

Reference: A. Cangiani, Z. Dong, E. H. Georgoulis, and P. Houston, hp-Version Discontinuous Galerkin Methods on Polygonal and Polyhedral Meshes, Springer, 2017. DOI: 10.1007/978-3-319-19800-2.

1) Linear elasticity and its SIPG formulation

Let \(\Omega\subset\mathbb R^d\), \(d\in\{2,3\}\), and let \(u:\Omega\to\mathbb R^d\) be the displacement. We solve

\[\begin{cases} -\nabla\cdot\sigma(u)=f & \text{in }\Omega,\\ u=g_D & \text{on }\partial\Omega, \end{cases} \]

with the isotropic linear elastic constitutive law

\[\sigma(u)=2\mu\,\varepsilon(u) +\lambda\,\operatorname{tr}(\varepsilon(u))I, \qquad \varepsilon(u)=\frac12(\nabla u+\nabla u^T). \]

Here \(\lambda\) and \(\mu\) are the Lamé parameters. No numerical values are needed in the formulation. All boundaries in the examples are treated as Dirichlet boundaries, possibly with nonzero \(g_D\).

Let \(\mathcal T_h\) be a mesh of polygonal ( \(d=2\)) or polyhedral ( \(d=3\)) elements and write \(\mathcal F_h^I\) and \(\mathcal F_h^D\) for its interior and boundary faces. For a uniform polynomial degree \(p\), the vector-valued DG space is

\[V_h^p=\bigl\{v_h\in[L^2(\Omega)]^d: v_h|_K\in[\mathbb P_p(K)]^d\quad \forall K\in\mathcal T_h\bigr\}. \]

Here \(\mathbb P_p(K)\) contains polynomials of **total degree at most \(p\)**; the corresponding modal basis in Vulpes is constructed from Legendre polynomials on each cell's bounding-box reference frame.

On an interior face \(F=\partial K^+\cap\partial K^-\), with outward unit normals \(n^+=-n^-\), define for a symmetric tensor \(T\) and vector \(w\):

\[\{\!\{T\}\!\}=\frac12(T^++T^-),\qquad [\![w]\!]=w^+\otimes_s n^+ +w^-\otimes_s n^-, \qquad a\otimes_s b=\frac12(a\otimes b+b\otimes a). \]

On a boundary face, set \(\{\!\{T\}\!\}=T\) and \([\![w]\!]=w\otimes_s n\). The two useful identities, valid for symmetric \(T\), are

\[T:(w\otimes_s n)=(Tn)\cdot w, \qquad (a\otimes_s b):(c\otimes_s d) =\frac12\bigl[(a\cdot c)(b\cdot d)+(a\cdot d)(b\cdot c)\bigr]. \]

Integrating the PDE by parts on each element gives

\[\sum_{K\in\mathcal T_h} \left(\int_K\sigma(u):\varepsilon(v)\,dx -\int_{\partial K}(\sigma(u)n)\cdot v\,ds\right) =\sum_{K\in\mathcal T_h}\int_K f\cdot v\,dx. \]

The volume integrand can be expanded as

\[\begin{aligned} \sigma(u):\varepsilon(v) &=\bigl(2\mu\varepsilon(u) +\lambda\operatorname{tr}(\varepsilon(u))I\bigr):\varepsilon(v)\\ &=2\mu\,\varepsilon(u):\varepsilon(v) +\lambda\,\operatorname{tr}(\varepsilon(u)) \operatorname{tr}(\varepsilon(v)). \end{aligned} \]

The SIPG formulation replaces the element-boundary traction terms with consistency and stabilization terms. Define the full face penalty \(\gamma_F\) as in Section 3. Find \(u_h\in V_h^p\) such that

\[a_h(u_h,v_h)=\ell_h(v_h)\qquad\forall v_h\in V_h^p, \]

where

\[\begin{aligned} a_h(u,v)={}&\sum_{K\in\mathcal T_h}\int_K \sigma(u):\varepsilon(v)\,dx\\ &-\sum_{F\in\mathcal F_h^I}\int_F \{\!\{\sigma(u)\}\!\}:[\![v]\!]\,ds -\sum_{F\in\mathcal F_h^I}\int_F \{\!\{\sigma(v)\}\!\}:[\![u]\!]\,ds\\ &+\sum_{F\in\mathcal F_h^I}\int_F \gamma_F[\![u]\!]:[\![v]\!]\,ds\\ &-\sum_{F\in\mathcal F_h^D}\int_F (\sigma(u)n)\cdot v\,ds -\sum_{F\in\mathcal F_h^D}\int_F (\sigma(v)n)\cdot u\,ds\\ &+\sum_{F\in\mathcal F_h^D}\int_F \gamma_F(u\otimes_s n):(v\otimes_s n)\,ds, \end{aligned} \]

and

\[\begin{aligned} \ell_h(v)={}&\sum_{K\in\mathcal T_h}\int_K f\cdot v\,dx\\ &-\sum_{F\in\mathcal F_h^D}\int_F (\sigma(v)n)\cdot g_D\,ds +\sum_{F\in\mathcal F_h^D}\int_F \gamma_F(g_D\otimes_s n):(v\otimes_s n)\,ds. \end{aligned} \]

This is the symmetric interior penalty method: the two consistency terms are transposes of each other. The nonhomogeneous Dirichlet data appear only in the right-hand side; setting \(g_D=0\) removes those boundary RHS terms.

Symmetric-jump algebra

Starting from \((a\otimes b):(c\otimes d)=(a\cdot c)(b\cdot d)\),

\[\begin{aligned} (a\otimes_s b):(c\otimes_s d) &=\frac14(a\otimes b+b\otimes a):(c\otimes d+d\otimes c)\\ &=\frac14\bigl[(a\cdot c)(b\cdot d)+(a\cdot d)(b\cdot c) +(b\cdot c)(a\cdot d)+(b\cdot d)(a\cdot c)\bigr]\\ &=\frac12\bigl[(a\cdot c)(b\cdot d)+(a\cdot d)(b\cdot c)\bigr]. \end{aligned} \]

In particular, for unit \(n\),

\[(a\otimes_s n):(b\otimes_s n) =\frac12\bigl[a\cdot b+(a\cdot n)(b\cdot n)\bigr]. \]

This factor \(1/2\) is essential for the penalty expressions in the code.

2) Cellwise derivation and matrix blocks

Vulpes iterates over each cell \(K\) and its faces. On an interior face shared with a neighbor \(K'\), let \(u=u|_K\), \(u'=u|_{K'}\), and similarly for \(v\), with \(n\) the outward normal of \(K\). Then \(n'=-n\) and

\[[\![w]\!]=(w-w')\otimes_s n, \qquad \{\!\{\sigma(w)\}\!\} =\frac12\bigl(\sigma(w)+\sigma(w')\bigr). \]

Consistency terms

Expanding the interior-face integrand gives

\[\begin{aligned} &-\{\!\{\sigma(u)\}\!\}:[\![v]\!] -\{\!\{\sigma(v)\}\!\}:[\![u]\!]\\ ={}&-\frac12\bigl(\sigma(u)+\sigma(u')\bigr)n\cdot(v-v') -\frac12\bigl(\sigma(v)+\sigma(v')\bigr)n\cdot(u-u')\\ ={}&-\frac12\sigma(u)n\cdot v +\frac12\sigma(u)n\cdot v' -\frac12\sigma(u')n\cdot v +\frac12\sigma(u')n\cdot v'\\ &-\frac12\sigma(v)n\cdot u +\frac12\sigma(v)n\cdot u' -\frac12\sigma(v')n\cdot u +\frac12\sigma(v')n\cdot u'. \end{aligned} \]

The terms associated with the trial or test stress evaluated on \(K'\) are accounted for when the neighbor is processed. For the current cell, the self-block terms and their transposes are

\[C_K=-\frac12\sigma(u)n\cdot v -\frac12\sigma(v)n\cdot u, \]

and the neighbor-coupling terms and their transposes are

\[N_K=+\frac12\sigma(u)n\cdot v' +\frac12\sigma(v)n\cdot u'. \]

It is sufficient to integrate one of the two paired terms and insert its transpose into the global matrix. On a Dirichlet face the self-block factor is \(-1\) rather than \(-1/2\); there is no neighbor block.

For implementation, expand a traction against an arbitrary vector \(t\):

\[\begin{aligned} (\sigma(w)n)\cdot t &=\bigl(2\mu\varepsilon(w) +\lambda\operatorname{tr}(\varepsilon(w))I\bigr)n\cdot t\\ &=2\mu\,\varepsilon(w):(t\otimes n) +\lambda\operatorname{tr}(\varepsilon(w))(t\cdot n). \end{aligned} \]

As \(\varepsilon(w)\) is symmetric, the ordinary outer product \(t\otimes n\) may be used in this contraction.

Stabilization terms

On an interior face,

\[\begin{aligned} \gamma_F[\![u]\!]:[\![v]\!] &=\gamma_F((u-u')\otimes_s n):((v-v')\otimes_s n)\\ &=\frac{\gamma_F}{2}\bigl[ (u-u')\cdot(v-v') +((u-u')\cdot n)((v-v')\cdot n)\bigr]\\ &=\frac{\gamma_F}{2}\bigl[ u\cdot v-u\cdot v'-u'\cdot v+u'\cdot v'\\ &\hspace{5em}+(u\cdot n)(v\cdot n)-(u\cdot n)(v'\cdot n)\\ &\hspace{5em}-(u'\cdot n)(v\cdot n)+(u'\cdot n)(v'\cdot n) \bigr]. \end{aligned} \]

The terms with trial function from \(K\) are

\[\underbrace{\frac{\gamma_F}{2} \bigl[u\cdot v+(u\cdot n)(v\cdot n)\bigr]}_{S_K} \; -\; \underbrace{\frac{\gamma_F}{2} \bigl[u\cdot v'+(u\cdot n)(v'\cdot n)\bigr]}_{-S_{n,K}}. \]

The other two terms arise when the loop reaches \(K'\). As a result, unlike the consistency coupling, the code inserts \(S_n\) without a separate transpose: the neighbor-cell pass supplies the opposite off-diagonal block.

On a Dirichlet face, the stabilization contribution to the bilinear form is

\[\frac{\gamma_F}{2} \bigl[u\cdot v+(u\cdot n)(v\cdot n)\bigr], \]

while the corresponding RHS contribution is

\[\frac{\gamma_F}{2} \bigl[g_D\cdot v+(g_D\cdot n)(v\cdot n)\bigr]. \]

The remaining Dirichlet RHS term is \(-(\sigma(v)n)\cdot g_D\).

Equivalently, before separating the bilinear form and right-hand side, the Dirichlet-face contribution is

\[\begin{aligned} &-\sigma(u):(v\otimes_s n) -\sigma(v):((u-g_D)\otimes_s n) +\gamma_F((u-g_D)\otimes_s n):(v\otimes_s n)\\ ={}&-(\sigma(u)n)\cdot v-(\sigma(v)n)\cdot u +\eta_F\bigl[u\cdot v+(u\cdot n)(v\cdot n)\bigr]\\ &+(\sigma(v)n)\cdot g_D -\eta_F\bigl[g_D\cdot v+(g_D\cdot n)(v\cdot n)\bigr]. \end{aligned} \]

Moving the last line to the right-hand side reverses its signs, yielding the Dirichlet terms of \(\ell_h\) in Section 1.

3) Code notation and assembly

The 2D and 3D drivers use fe::FeSpaceModalLegendreDQ<Dim> with vector-valued trial and test functions. Both assemble the volume and face contributions using assemble::WeakFormIntegratorSimplexify. The weak forms are summarized below; full expression definitions and insertion loops are available in the linked source files.

Penalty coefficient

Let \(h_K=\operatorname{diam}(K)\) be the cell diameter. Both drivers use \(C_\gamma=10\) and the diameter-based penalty helper used by Laplacian. The full coefficient multiplying the symmetric tensor-jump contraction is

\[\gamma_F=(\lambda+2\mu) C_\gamma p^2 \begin{cases} \displaystyle\max\left\{\frac1{h_{K^+}},\frac1{h_{K^-}}\right\}, & F\in\mathcal F_h^I,\\ \displaystyle\frac1{h_K}, & F\in\mathcal F_h^D. \end{cases} \]

The expanded vector form uses \(\eta_F=\gamma_F/2\), corresponding to gamma_half in the drivers:

constexpr double C_gamma = 10.0;
constexpr double half_penalty_scale =
0.5 * C_gamma * (lambda_value + 2.0 * mu_value);
auto gamma_half =
assemble::dg::createPenaltyExpression<Dim>(p, half_penalty_scale);

createPenaltyExpression divides by the cell diameter and takes the maximum of the adjacent-cell penalties on interior faces. For \(\lambda=\mu=1\), the expanded boundary coefficient is \(\eta_F=15p^2/h_K\). The material multiplier and symmetric-jump factor \(1/2\) are both retained. C_gamma is a source constant, not a JSON or CLI parameter.

Weak-form terms

Write \(n\) for the current cell's outward normal and \(v'\) for the test function on its neighbor (fe::neigh(v)). The face coefficient is \(b_F=-\tfrac12\) on interior faces and \(b_F=-1\) on Dirichlet faces.

Vulpes term Mathematical integrand Integration
wf_stiff \(2\mu\,\varepsilon(u):\varepsilon(v)+\lambda\,\operatorname{tr}(\varepsilon(u))\operatorname{tr}(\varepsilon(v))\) Cell volume
wf_IT \(b_F\,(\sigma(u)n)\cdot v\) All faces, current-cell block
wf_ITn \(\tfrac12(\sigma(u)n)\cdot v'\) Interior faces, neighbor block
wf_S \(\eta_F[u\cdot v+(u\cdot n)(v\cdot n)]\) All faces, current-cell block
wf_Sn \(-\eta_F[u\cdot v'+(u\cdot n)(v'\cdot n)]\) Interior faces, neighbor block
wf_F \(f\cdot v\) Cell volume (RHS)
wf_F_dirichlet (3D) \(\eta_F[g_D\cdot v+(g_D\cdot n)(v\cdot n)]-(\sigma(v)n)\cdot g_D\) Dirichlet faces (RHS)

The consistency terms use fe::symgrad, fe::trsymgrad, fe::outer, and fe::inner. The stabilization terms use dot products of vector fields and normal components. The 3D boundary term is restricted to Dirichlet faces; it vanishes for the homogeneous boundary data in the 2D example.

Assembled algebraic operators

The matrix contributions from Section 2 are assembled as

\[A=A_V+A_{IT}+A_{IT}^T+A_{ITn}+A_{ITn}^T+A_S+A_{Sn}, \qquad AU=F. \]

Here \(A_V\) comes from wf_stiff; \(A_{IT}\) and \(A_{ITn}\) are the current-cell and neighbor consistency contributions; and \(A_S\) and \(A_{Sn}\) are the corresponding penalty contributions. Vulpes inserts each consistency block together with its transpose. For neighbor blocks, the transpose insertion also exchanges current-cell and neighbor DoF indices. The neighbor penalty block needs no separate transpose insertion, since the reverse block is assembled when the neighboring cell is visited.

Both drivers solve the resulting linear system using direct LU and retain a separate stabilization matrix S_matrix for the error computations in Section 6. They are serial convergence examples, not distributed-mesh MPI examples.

4) Manufactured solutions: 2D and 3D

Both drivers use \(\Omega=(0,1)^d\) and prescribe \(g_D=u_{\mathrm{ex}}|_{\partial\Omega}\) with \(f=-\nabla\cdot\sigma(u_{\mathrm{ex}})\). The dimensions differ only in the chosen manufactured data, not in the SIPG formulation or assembly machinery.

2D 3D
Dirichlet datum Homogeneous ( \(g_D=0\)) Nonhomogeneous ( \(g_D=u_{\mathrm{ex}}\))
Force Divergence-free exact displacement, hence independent of \(\lambda\) Force depends on \(\lambda+2\mu\)
Boundary RHS No additional contribution Adds wf_F_dirichlet

2D. With \(x=(x,y)\), the exact displacement is

\[u_{\mathrm{ex}}(x,y)= \begin{pmatrix} -\sin^2(\pi x)\sin(2\pi y)\\ \sin^2(\pi y)\sin(2\pi x) \end{pmatrix}. \]

It satisfies \(\nabla\cdot u_{\mathrm{ex}}=0\) and vanishes on \(\partial\Omega\). Therefore, for constant Lamé parameters,

\[\begin{aligned} f=-\nabla\cdot\sigma(u_{\mathrm{ex}}) &=-\mu\Delta u_{\mathrm{ex}}\\ &=2\mu\pi^2 \begin{pmatrix} (2\cos(2\pi x)-1)\sin(2\pi y)\\ \sin(2\pi x)(1-2\cos(2\pi y)) \end{pmatrix}. \end{aligned} \]

3D. With \(x=(x,y,z)\), the exact displacement is

\[u_{\mathrm{ex}}(x,y,z)= \begin{pmatrix} \cos(\pi x)\sin(\pi y)\sin(\pi z)\\ \sin(\pi x)\cos(\pi y)\sin(\pi z)\\ \sin(\pi x)\sin(\pi y)\cos(\pi z) \end{pmatrix}. \]

Its trace is nonzero on parts of the boundary, so the weak imposition of \(g_D\) is essential. The corresponding manufactured force is

\[f=3\pi^2(\lambda+2\mu)u_{\mathrm{ex}}. \]

The C++ functions exactDisplacement(), bodyForce(), and exactGradientRow() are defined in each driver. The numeric Lamé constants used by each executable are declared at the top of its source file; the mathematical formulation above does not depend on that choice. If the material constants are changed in the example, the manufactured forcing must remain consistent with them (the 2D bodyForce() currently evaluates a specialized constant-coefficient expression).

5) Running the elasticity convergence examples

The executables are elasticity_2d_main and elasticity_3d_main and their parameter files are:

examples/assembly/elasticity/elasticity_2d_parameters.json
examples/assembly/elasticity/elasticity_3d_parameters.json

The following four JSON keys are recognized: order (polynomial degree), n_lvls (number of mesh levels), mesh_kind, and output_path (directory for convergence CSV output). The sample files contain descriptive _comment keys, which are not interpreted as parameters.

The available mesh types are:

Dimension mesh_kind Mesh family
2D sqr Structured quadrilaterals
2D tria Structured triangles
2D poly_meshes Imported polygonal meshes (Mesh_P_8.vtk through Mesh_P_2048.vtk; maximum 9 levels)
3D hexa Structured hexahedra
3D tet Structured tetrahedra
3D voro_cubes Imported Voronoi polyhedra (Mesh_cube_poly_64.vtu through Mesh_cube_poly_4096.vtu; maximum 7 levels)

For structured meshes, each refinement starts at two subdivisions per coordinate direction and increases the number of subdivisions approximately by \(2^{1/d}\) per level. For imported meshes, the driver loads a predefined coarse-to-fine family from test/data/mesh/.

From the Vulpes repository root, after building the two targets with your usual CMake configuration:

cmake --build build --target elasticity_2d_main elasticity_3d_main
cd build
./elasticity_2d_main ../examples/assembly/elasticity/elasticity_2d_parameters.json
./elasticity_3d_main ../examples/assembly/elasticity/elasticity_3d_parameters.json

The drivers accept positional parameters instead of a JSON file, in the order order n_lvls mesh_kind [output_path]. For example:

./elasticity_2d_main 2 4 poly_meshes output/elasticity
./elasticity_3d_main 2 3 voro_cubes output/elasticity

To save the terminal convergence table, redirect the log:

./elasticity_2d_main 2 4 sqr output/elasticity > elasticity_2d.log
./elasticity_3d_main 2 3 hexa output/elasticity > elasticity_3d.log

A JSON path is not searched for automatically. To inspect the supported arguments, run either executable with --help.

6) Error measures and convergence output

Let \(e=u_h-u_{\mathrm{ex}}\), evaluated element by element. Both drivers compute four errors:

** \(L^2\) error:**

\[\|e\|_{L^2(\Omega)}= \left(\sum_{K\in\mathcal T_h}\int_K |e|^2\,dx\right)^{1/2}. \]

**Broken \(H^1\) seminorm:**

\[|e|_{H^1(\mathcal T_h)}= \left(\sum_{K\in\mathcal T_h}\int_K \nabla e:\nabla e\,dx\right)^{1/2}. \]

Penalty-jump error: with the same diameter-based \(\gamma_F\) used in the operator,

\[\begin{aligned} J_h(e)^2={}&\sum_{F\in\mathcal F_h^I}\int_F \gamma_F[\![e]\!]:[\![e]\!]\,ds\\ &+\sum_{F\in\mathcal F_h^D}\int_F \gamma_F(e\otimes_s n):(e\otimes_s n)\,ds. \end{aligned} \]

Elastic DG error:

\[\|e\|_{\mathrm{DG,el}}^2= \sum_{K\in\mathcal T_h}\int_K \Bigl(2\mu\,\varepsilon(e):\varepsilon(e) +\lambda(\nabla\cdot e)^2\Bigr)\,dx+J_h(e)^2. \]

The volume errors are integrated from the difference between the discrete solution and the exact field (or its gradient). The penalty jump is evaluated using an assembled stabilization matrix \(S\), not from a broken-gradient approximation.

For homogeneous boundary data (the 2D example), the exact displacement is continuous and zero on the boundary, giving

\[J_h(e)^2=U^T S U. \]

For nonhomogeneous boundary data (the 3D example), \(U^TSU\) alone would penalize \(u_h\) rather than \(u_h-g_D\) on boundary faces. The driver therefore computes the exact boundary correction:

\[\begin{aligned} J_h(e)^2={}&U^T S U-2U^Tb_D+c_D,\\ (b_D)_i={}&\sum_{F\in\mathcal F_h^D}\int_F \eta_F\bigl[g_D\cdot\phi_i+(g_D\cdot n)(\phi_i\cdot n)\bigr] \,ds,\\ c_D={}&\sum_{F\in\mathcal F_h^D}\int_F \eta_F\bigl[|g_D|^2+(g_D\cdot n)^2\bigr] \,ds, \end{aligned} \]

where \(\phi_i\) is a vector-valued DG basis function and \(\eta_F=\gamma_F/2\). In the implementation, \(b_D\) is boundary_cross_vec, while \(c_D\) is computed by integrateExactBoundaryPenalty(). All three terms use the same diameter-based penalty. In particular, the independent integration of \(c_D\) uses half_penalty_scale * p * p / cell.diameter() on each boundary face, so the correction measures \(u_h-g_D\) with the same coefficient as the assembled stabilization and boundary cross term.

For sufficiently regular solutions and appropriate meshes, the expected convergence orders are \(p+1\) for the \(L^2\) error and \(p\) for the energy-type DG error. The broken \(H^1\) and penalty-jump measures provide additional information on the contributions to the total error. Convergence must be validated separately for each mesh family with the chosen penalty constant; diameter scaling does not by itself guarantee stability on arbitrarily degenerate polygonal or polyhedral meshes.

At each level the code prints the mesh diameter \(h\) (the maximum cell diameter), cell count, and

L2
H1_broken
jump_penalty
elastic_DG

It also prints estimated orders of convergence between consecutive levels and saves CSV files in output_path:

convergence_2d_p{order}_{mesh_kind}.csv
convergence_3d_p{order}_{mesh_kind}.csv

The CSV contains h and each measure with its associated order_... column; for the \(L^2\) measure the CSV header is L2_integral, whereas the per-level terminal output labels it L2. The present elasticity convergence drivers write these CSV tables but do not export VTU solution fields. ParaView visualization requires additional output code and is not part of these runs.