One submesh per degree#
Author: Jørgen S. Dokken
SPDX-License-Identifier: MIT
In this demo, we solve the Laplace eigenvalue problem on the PacMan domain from the adaptive mesh refinement demo of the DOLFINx tutorial. Instead of refining the mesh, we keep the mesh fixed and increase the polynomial degree of the cells with the largest error.
We seek \((u, \lambda)\), \(u\neq 0\), such that
where \(\Omega\) is the unit disk with the quadrant \(x>0, y<0\) removed. The first eigenvalue is \(\lambda = j_{2/3,1}^2\approx 11.3947\), where \(j_{2/3,1}\) is the first root of the Bessel function \(J_{2/3}\). The eigenfunction behaves like \(r^{2/3}\) at the re-entrant corner.
The space has a polynomial degree \(p_K\) on each cell \(K\). We represent it by one function space per degree \(i\), each defined on the submesh \(\Omega_i\) of the cells with degree \(i\). The spaces are coupled by the symmetric interior penalty (SIPG) method [Arn82, ABCM02], with Dirichlet conditions imposed by Nitsche’s method [Nit71].
The mesh#
The mesh is generated with GMSH, with second order (curved) cells, and graded towards the re-entrant corner.
from mpi4py import MPI
from petsc4py import PETSc
import numpy as np
from dolfinx_padapt import EigenvalueProblem, create_pacman
from dolfinx_padapt.adaptivity import mark_cells, solve_adaptive
from dolfinx_padapt.approaches import SubmeshApproach
from dolfinx_padapt.forms import Parameters
from dolfinx_padapt.plotting import Animation, plot_convergence
mesh = create_pacman(MPI.COMM_WORLD, h=0.3, h_corner=0.01)
num_cells = mesh.topology.index_map(mesh.topology.dim).size_global
PETSc.Sys.Print(f"Number of cells: {num_cells}, geometry order: {mesh.geometry.cmaps[0].degree}")
Number of cells: 181, geometry order: 2
The range of degrees#
All cells start with degree \(p_{min}=1\), and the degree is capped at \(p_{max}=6\). The range of degrees is a discretisation parameter, as it decides which spaces and forms are compiled.
params = Parameters(pmin=1, pmax=6)
Discretisation#
Let \(V_i\) be the discontinuous Lagrange space of degree \(i\) on \(\Omega_i\). On the facets between a cell of degree \(i\) and a cell of degree \(j\geq i\), the restriction “+” is the cell with the lowest degree, i.e. \(u_i\) on the “+” side and \(u_j\) on the “-” side. The bilinear form is
where \(\mathcal{F}_{ij}\) are the facets between the cells of degree \(i\) and \(j\), \([u] = u^+n^+ + u^-n^-\) and \(\{\nabla u\}=\frac{1}{2}(\nabla u^+ + \nabla u^-)\). The penalty parameter \(\sigma_{ij}=\alpha\max(i, j)^2\) scales with the square of the degree [ERiviere07].
Every integral \(\mathrm{d}x(i)\), \(\mathrm{d}s(i)\) and \(\mathrm{d}S(i, j)\) gets a unique tag.
All forms, for every combination of degrees, are compiled once with
dolfinx.fem.compile_form(), with the spaces defined on template domains.
This happens when we create the approach for the eigenvalue problem:
The approach owns the degree of each cell (dolfinx_padapt.degrees.DegreeField),
stored as cell tags, where the value of each tag is the polynomial degree of the cell.
degrees = approach.degrees
PETSc.Sys.Print(f"Degrees of the first cells on process 0: {degrees.ct.values[:10]}")
Degrees of the first cells on process 0: [1 1 1 1 1 1 1 1 1 1]
One iteration, step by step#
At every iteration, the approach extracts the submesh of each degree with
dolfinx.mesh.create_submesh(), creates the function spaces on them, and creates the forms
with dolfinx.fem.create_form(). The integration entities are given in the numbering of
the parent mesh, and the entity maps of the submeshes map them to the cells of each submesh.
The interior facets are computed once with dolfinx.fem.compute_integration_domains(),
and grouped by the degrees of their two cells.
A degree without cells has an empty submesh and space, so the forms are the same at every
iteration, and no process needs to know which degrees are used on the others.
approach.update()
for i, (submesh, _) in approach.submeshes.items():
n = submesh.topology.index_map(submesh.topology.dim).size_global
PETSc.Sys.Print(
f"Degree {i}: {n} cells, {approach.spaces[(i, 'u')].dofmap.index_map.size_global} dofs"
)
Degree 1: 181 cells, 543 dofs
Degree 2: 0 cells, 0 dofs
Degree 3: 0 cells, 0 dofs
Degree 4: 0 cells, 0 dofs
Degree 5: 0 cells, 0 dofs
Degree 6: 0 cells, 0 dofs
We assemble the blocked matrices and solve the eigenvalue problem with SLEPc, using a shift-and-invert spectral transform.
A, M = approach.assemble()
x = problem.solve(A, M)
approach.set_solution(x)
error, values = problem.errors(approach.errors())
PETSc.Sys.Print(f"lambda_h = {values['lambda']:.10f}, relative error {error:.2e}")
lambda_h = 11.7051853187, relative error 2.72e-02
Error indicator and marking#
We use the residual based error indicator of [Lar00] (as in the AMR demo of the DOLFINx tutorial), with the polynomial weights of the hp-DG indicator of [HSchotzauW07]:
The cells to enrich are chosen by maximum marking [BabuvskaR78],
\(\eta_K > \theta\max_{K'}\eta_{K'}\), with dolfinx.mesh.mark_maximum(), among the cells that
are not yet at the maximal degree.
eta = approach.estimate()
marked = mark_cells(eta, theta=0.5, degrees=degrees)
num_marked = mesh.comm.allreduce(len(marked), op=MPI.SUM)
PETSc.Sys.Print(f"Marked {num_marked} of {num_cells} cells")
Marked 25 of 181 cells
We reset the degrees, and run the full adaptive loop. We track the solution and the degrees in a GIF, with the solution on the left and the degree of each cell on the right.
with Animation(mesh.comm, "submesh.gif") as animation:
history = solve_adaptive(approach, max_iterations=15, callback=animation)
it dofs error eta update solve estim. values, degrees
0 543 2.724e-02 3.591e+00 0.016 0.007 0.001 lambda=11.70518532, {1: 181}
1 618 1.301e-02 1.848e+00 0.016 0.007 0.001 lambda=11.54301805, {1: 156, 2: 25}
2 712 6.576e-03 1.079e+00 0.016 0.007 0.001 lambda=11.4696747, {1: 130, 2: 47, 3: 4}
3 894 2.044e-03 5.722e-01 0.016 0.009 0.001 lambda=11.41803881, {1: 80, 2: 89, 3: 12}
4 1051 8.217e-04 3.691e-01 0.016 0.010 0.001 lambda=11.40411079, {1: 55, 2: 96, 3: 28, 4: 2}
5 1170 5.039e-04 2.696e-01 0.016 0.011 0.001 lambda=11.40048878, {1: 40, 2: 95, 3: 42, 4: 4}
6 1280 2.549e-04 2.032e-01 0.015 0.012 0.001 lambda=11.3976522, {1: 24, 2: 101, 3: 50, 4: 4, 5: 2}
7 1420 1.108e-04 1.474e-01 0.015 0.014 0.001 lambda=11.39600952, {1: 8, 2: 103, 3: 62, 4: 4, 5: 2, 6: 2}
8 1460 9.590e-05 1.329e-01 0.015 0.014 0.001 lambda=11.39584005, {1: 6, 2: 100, 3: 67, 4: 4, 6: 4}
9 1747 2.551e-05 7.497e-02 0.016 0.018 0.001 lambda=11.39503798, {2: 40, 3: 132, 4: 5, 6: 4}
10 1912 2.039e-05 6.442e-02 0.016 0.020 0.001 lambda=11.39497967, {2: 19, 3: 138, 4: 19, 5: 1, 6: 4}
11 2214 1.854e-05 5.976e-02 0.015 0.025 0.001 lambda=11.3949585, {2: 1, 3: 116, 4: 54, 5: 6, 6: 4}
12 2509 1.809e-05 5.842e-02 0.016 0.027 0.001 lambda=11.39495339, {3: 70, 4: 94, 5: 11, 6: 6}
13 2777 1.799e-05 5.810e-02 0.016 0.033 0.001 lambda=11.39495223, {3: 30, 4: 125, 5: 18, 6: 8}
14 3141 1.796e-05 5.799e-02 0.016 0.041 0.001 lambda=11.3949519, {3: 10, 4: 108, 5: 49, 6: 14}
The degree is first increased in the bulk of the domain, where the eigenfunction is smooth, while the cells at the corner singularity reach high degree only on the graded mesh.
Finally, we plot the convergence of the eigenvalue.
if mesh.comm.rank == 0:
plot_convergence(
{"submesh": history}, "submesh_convergence.png", ylabel=r"$|\lambda_h - \lambda| / \lambda$"
)

Douglas N. Arnold. An interior penalty finite element method with discontinuous elements. SIAM Journal on Numerical Analysis, 19(4):742–760, 1982. doi:10.1137/0719052.
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.
Ivo Babuška and Werner C. Rheinboldt. Error estimates for adaptive finite element computations. SIAM Journal on Numerical Analysis, 15(4):736–754, 1978. doi:10.1137/0715049.
Yekaterina Epshteyn and Béatrice Rivière. Estimation of penalty parameters for symmetric interior penalty Galerkin methods. Journal of Computational and Applied Mathematics, 206(2):843–872, 2007. doi:10.1016/j.cam.2006.08.029.
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.
Mats G. Larson. A posteriori and a priori error analysis for finite element approximations of self-adjoint elliptic eigenvalue problems. SIAM Journal on Numerical Analysis, 38(2):608–625, 2000. doi:10.1137/S0036142997320164.
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.