This example is to show the rate of convergence of the linear finite element approximation of the Poisson equation on the unit cube:
$$- \Delta u = f \; \hbox{in } (0,1)^3$$for the following boundary conditions
References:
Subroutines:
- Poisson3WG
- cubePoisson3WG
- femPoisson3
- Poisson3WGfemrate
The method is implemented in Poisson3
subroutine and tested in cubePoisson
. Together with other elements (P1, P2,Q1,WG), femPoisson3
provides a concise interface to solve Poisson equation. The P1 element is tested in Poisson3femrate
. This doc is based on Poisson3femrate
.
The basis and the local matrices can be found in Progamming of Weak Galerkin Methods
%% Setting
[node,elem] = cubemesh([0,1,0,1,0,1],0.5);
mesh = struct('node',node,'elem',elem);
option.L0 = 1;
option.maxIt = 4;
option.elemType = 'WG';
option.printlevel = 1;
option.plotflag = 1;
%% Non-empty Dirichlet boundary condition.
pde = sincosdata3;
mesh.bdFlag = setboundary3(node,elem,'Dirichlet','~(x==0)','Neumann','x==0');
femPoisson3(mesh,pde,option);
When pure Neumann boundary condition is posed, i.e., $-\Delta u =f$ in $\Omega$ and $\nabla u\cdot n=g_N$ on $\partial \Omega$, the data should be consisitent in the sense that $\int_{\Omega} f \, dx + \int_{\partial \Omega} g \, ds = 0$. The solution is unique up to a constant. A post-process is applied such that the constraint $\int_{\Omega}u_h dx = 0$ is imposed.
%% Pure Neumann boundary condition.
option.plotflag = 0;
mesh.bdFlag = setboundary3(node,elem,'Neumann');
femPoisson3(mesh,pde,option);
%% Pure Robin boundary condition.
pde = sincosRobindata3;
mesh.bdFlag = setboundary3(node,elem,'Robin');
femPoisson3(mesh,pde,option);
The optimal rate of convergence of the H1-norm (1st order) and L2-norm (2nd order) is observed. No superconvergence for $\|\nabla u_I - \nabla u_h\|$.
MGCG converges uniformly in all cases.