This example is to show the rate of convergence of the lowest order Weak Galerkin finite element approximation of the Poisson equation on the unit square:
$$- \Delta u = f \; \hbox{in } (0,1)^2$$for the following boundary conditions
References:
Subroutines:
- PoissonWG
- squarePoissonWG
- femPoisson
- PoissonWGfemrate
The method is implemented in PoissonWG
subroutine and can be tested in squarePoissonWG
. Together with other elements (P1, P2, P3, Q1), femPoisson
provides a concise interface to solve Poisson equation. The P2 element is tested in PoissonWGfemrate
. This doc is based on PoissonWGfemrate
.
The basis and the local matrices can be found in Progamming of Weak Galerkin Methods
%% Setting
[node,elem] = squaremesh([0,1,0,1],0.25);
mesh = struct('node',node,'elem',elem);
option.L0 = 2;
option.maxIt = 4;
option.printlevel = 1;
option.elemType = 'WG';
% Mixed boundary condition
pde = sincosdata;
mesh.bdFlag = setboundary(node,elem,'Dirichlet','~(x==0)','Neumann','x==0');
femPoisson(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.
option.plotflag = 0;
pde = sincosNeumanndata;
mesh.bdFlag = setboundary(node,elem,'Neumann');
femPoisson(mesh,pde,option);
option.plotflag = 0;
pde = sincosRobindata;
mesh.bdFlag = setboundary(node,elem,'Robin');
femPoisson(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.