### System equivalent to 5 point finite difference stencil

222
views
0
5 months ago by
What kind of element and cell type for the finite element method in Fenics with Dirichlet boundary condition leads to an equivalent system of 5 point stencil with the Finite difference method for the Poisson equation ?

Consider the code below:
import numpy as np
from fenics import *

mesh = UnitSquareMesh.create(3, 3,CellType.Type_Option1)

V = FunctionSpace(mesh, 'Option 2', 1)
u = TrialFunction(V)
v = TestFunction(V)
matA = assemble(a)
​
with the different parameters(Option1 and Option 2) available as in Functionspace to get the same stiffness matrix as for the 5 point stencil using the finite difference method ?

The MIT matlab code here shows the possibility of obtaining such a matrix using Finite element methods. I would like to get this with Fenics. If I can obtain the same matrix with any of Fenics' capabilities as in the example MIT MATLAB code, that would be great as well.

Thank you.
Community: FEniCS Project

6
5 months ago by
The short answer is that to get the standard 5-point finite difference mesh for the Laplacian with Dirichlet boundary conditions by assembling a finite element in FEniCS, you can use

from fenics import *
n = 3
mesh = UnitSquareMesh(n, n)
V = FunctionSpace(mesh, 'Lagrange', 1)
u = TrialFunction(V)
v = TestFunction(V)
​