🟢 div-grad#

Here we demonstrate how to use phyem to solve the div-grad problems in different dimensions and different domains.

The general form of the div-grad problem is

\[-\mathrm{d} \mathrm{d}^{\ast} \varphi^n = f^n,\]

where \(\varphi^n\) and \(f^n\) are top forms.

2d periodic boundary conditions#

Here we demonstrate how to use phyem, the msepy implementation, to solve the two-dimensional div-grad problem.

In two-dimensions, the mixed formulation of the div-grad problem is

\[\begin{split}\begin{equation}\left\lbrace \begin{aligned} u ^1 &= \mathrm{d}^{\ast}\varphi^2 ,\\ - \mathrm{d} u^1 &= f^2. \end{aligned}\right. \end{equation}\end{split}\]

We use smooth manufactured solutions for this case. The exact solution for \(\varphi\) is

\[\varphi = - \sin(2\pi x) \sin(2\pi y).\]

Exact solutions of \(u^1\) and \(f^2\) then follow. We consider the domain to be \(\Omega = (x,y) \in [0,1]^2\) and it is fully periodic. We use the Multi-crazy domain and mesh for this test. The solver is given below.

div_grad_2d_periodic_manufactured_test(degree, K, c=0)[source]#
Parameters:
degreeint

The degree of the mimetic spectral elements.

Kint

In total we will use \(4 * K * K\) elements.

cfloat, default=0

The deformation factor of the Multi-crazy domain and mesh.

Returns:
phi_error: float

The \(L^2\)-error of solution \(\varphi_h^2\).

u_error: float

The \(L^2\)-error of solution \(u_h^1\).

Examples#

Below, we use mimetic spectral elements of degree 2 on a uniform mesh of \(4 * 4 * 4\) \((K=4)\) elements.

>>> errors4 = div_grad_2d_periodic_manufactured_test(2, 4)
>>> errors4[0]  
0.01...

We increase \(K\) to \(K=8\), we do

>>> errors8 = div_grad_2d_periodic_manufactured_test(2, 8)

We can compute the convergence rate of the \(L^2\)-error of solution \(\varphi_h^2\) by

>>> import numpy as np
>>> rate = (np.log10(errors4[0]) - np.log10(errors8[0])) / (np.log10(1/4) - np.log10(1/8))
>>> round(rate, 1)
2.0

The optimal convergence rate is obtained.

2d general boundary conditions#

Here we repeat the test, but with essential boundary \(\mathrm{tr}\ u^1\) on faces \(y=0\) and \(y=1\), and natural boundary condition \(\mathrm{tr}\left(\star \varphi^2\right)\) on faces \(x=0\) and \(x=1\).

The implementation is

div_grad_2d_general_bc_manufactured_test(degree, K, c=0.0)[source]#
Parameters:
degreeint

The degree of the mimetic spectral elements.

Kint

In total we will use \(4 * K * K\) elements.

cfloat, default=0

The deformation factor of the Crazy domain and mesh.

Returns:
phi_error: float

The \(L^2\)-error of solution \(\varphi_h^2\).

u_error: float

The \(L^2\)-error of solution \(u_h^1\).

Examples#

If we solve it with \(4\times4\) elements (note that here we use a different mesh compared to the periodic test) at polynomial degree 2,

>>> errors4 = div_grad_2d_general_bc_manufactured_test(2, 4)
>>> errors4[0]  
0.06...

We increase \(K\) to \(K=8\), we do

>>> errors8 = div_grad_2d_general_bc_manufactured_test(2, 8)

We can compute the convergence rate of the \(L^2\)-error of solution \(\varphi_h^2\) by

>>> import numpy as np
>>> rate = (np.log10(errors4[0]) - np.log10(errors8[0])) / (np.log10(1/4) - np.log10(1/8))
>>> round(rate, 1)
2.0

Again, the optimal convergence rate is obtained.


↩️ Back to Gallery🖼.