Introduction to Trefftz-DG
We give a short introduction to Trefftz-DG methods for the model problem of the Laplace equation.
Harmonic polynomials
For an element \(K\) in out mesh \(\Th\) we define the local Trefftz space as
For the Laplace problem the Trefftz space is given by harmonic polynomials, e.g. for polynomials of order 3 in two dimensions the space is given by
The local degrees of freedom are reduced from the dimension of the full polynomials, given by \(\big(\begin{smallmatrix}p+n\\p\end{smallmatrix}\big)\), to
Numerical treatment
The IP-DG method for the Laplace equation is given by
where \(h\) is the mesh size, \(p\) is the polynomial degree and \(\alpha>0\).
For a given mesh we construct the Trefftz finite element space as
in NGSolve this is done by
mesh = Mesh(unit_square.GenerateMesh(maxh=.5))
trefftzfespace(mesh,order=p,eq="laplace",dgjumps=True)
We will compare the approximation properties of the Trefftz space with the space of (all) piecewise polynomials. In NGSolve
L2(mesh,order=p,dgjumps=True)
The numerical results for the Trefftz space are plotted in solid lines, while the results for the full polynomial space are the dashed lines. We show the convergence rates with respect to polynomial degree \(p\) and mesh size \(h\). In the Figure on the left we show the error compared to the global number of degrees of freedom for varying \(p\). In the Figure on the right we show the error with respect to \(h\).
The Trefftz space shows optimal rate of convergence, using fewer degrees of freedom. As an exact solution we used
from ngsolve.webgui import Draw
mesh = Mesh(unit_square.GenerateMesh(maxh=0.3))
fes = trefftzfespace(mesh,order=5,eq="laplace",dgjumps=True)
(a,f) = lap_problem(fes)
gfu = GridFunction(fes)
gfu.vec.data = a.mat.Inverse(inverse='sparsecholesky') * f.vec
Draw(gfu)
BaseWebGuiScene
How to get started?
If you want to see more implementations using Trefftz-DG methods or use an already implemented Trefftz space, have a look at the notebooks and the documentation.
If you are looking to implement a (polynomial) Trefftz space, a good starting point is to have a look at trefftzspace.hpp. For Trefftz spaces based on plane waves check out planewavefe.hpp.
Before undertaking the implementation of a new Trefftz space in C++, or especially if your PDE does not have a easy-to-construct Trefftz space, consider checking out the embedded Trefftz method.
If you are implementing a new method using NGSTrefftz consider contributing.