This repository contains a Finite Element Solver for the Poisson equation - Δ u = f on Ω = [0,1]×[0,1], a unit square consisting of Nx elements in the x direction, Ny elements in the y-direction. The elements are four-noded quadrilateral elements.
To run the example: python3 problem.py
.
Following is a list describing the contents of each file:
- assembly.py: Contains assembly routines for the Stiffness matrix, the right hand side and integration of a single finite element function.
- dolfin_reference.py: A dolfin implementation of the problem, used for verification of the solution in test_solutions.py.
- functionspace.py: Contains the implementation of a minimal version of the function space for first order Lagrange elements on quadrilaterals, corresponding to having dofs at each vertex.
- mesh.py: Contains the implementation of the UnitSquareMesh
- plotting.py: Contains several plotting routines for visualising the solution.
- problem.py: Contains the example where f=4(-y2+y) sin(π x).
- test_solution.py: Compares ∫ u dx obtained with this finite element solver with a FEniCS implementation. This is done for meshes of different sizes and different source terms. Runtime: ~ 3 minutes.
This finite element solver uses the numpy, sympy, scipy and matplotlib library. To run the comparasion of results with dolfin, you can use the FEniCS docker image, running
docker run --rm -ti -v $(pwd):/home/fenics/shared/ -w /home/fenics/shared/ quay.io/fenicsproject/stable:latest
Running problem.py
produces the following figures: