differential equations – Is there a FreeFEM++ code for the Modified Weak Galerkin Finite Element Method to solve the Poisson Problem?

I wrote a FreeFEM++ code to solve the Poisson Problem -∆u=f in Ω u=g on ∂Ω using the Modified Weak Galerkin Finite Element Method based on the paper:

[1] “A modified weak Galerkin finite element method”. X. Wang, N.S. Malluwawadu, F. Gao, T.C. McMillan.

www.sciencedirect.com/science/article/pii/S0377042714002131 3.

I modified a FreeFEM++ code to solve this problem according to the Discontinuous Galerkin FEM to fit the Modified Weak Galerkin FEM but the results are not the same as in the paper. I am wondering what’s wrong with my code. I would appreciate any help

int nref = 6;

real [int] L2errorm ( nref ); // initialize the L2 error d array

for ( int n = 0; n < nref; n++) {

int Nn = 2^(n + 1) ; // space discretization

real h = 1.0/Nn;

mesh Th = square (Nn,Nn); // mesh generation of a square

fespace Vh(Th,P1); // piecewise linear continuous finite element.

Vh uh,vh;

Vh uex = sin(pix) * sin (piy); // exact solution

func f = 2.0 * sin(pi*x) (pi^2) * sin (piy); // corresponding RHS

func g = 0;

varf a(uh,vh, solver=sparsesolver) =

int2d(Th)(dx(uh)*dx(vh)+dy(uh)*dy(vh) )

  • intalledges(Th)( h^-1 * jump(uh)*jump(vh)/nTonEdge )

  • on(1,2,3,4,uh = g); // bilinear form

matrix A = a(Vh, Vh); // build the matrix

varf L(unused, vh) = int2d (Th)(f*vh); // linear form

Vh F; F[] = L(0, Vh); // build the right hand side vector

uh[] = A^-1 * F [];

L2errorm [n] = sqrt ( int2d (Th)((uh – uex )^2));

}

for ( int n = 0; n < nref; n ++){

int Nn = 2^(n + 1);

cout << ” N ” << ” = ” << Nn << endl;

cout << ” L2errorm ” << n << ” = ” << L2errorm [n] << endl;}

for ( int n = 1; n < nref; n ++) {

int Nn = 2^(n + 1);

cout << ” N ” << ” = ” << Nn << endl;

cout <<” convergence rate d = ” << log ( L2errorm [n – 1]/ L2errorm [n])/log (2.) << endl; }

Read more here: Source link