Choral
Functions/Subroutines
poisson_2d.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

program poisson_2d
  SOLVES THE POISSON PROBLEM with homogeneous Neumann boundary conditions More...
 
real(rp) function f (x)
 Right hand side 'f'. More...
 
real(rp) function u (x)
 Exact solution 'u'. More...
 
real(rp) function, dimension(3) grad_u (x)
 Gradient of the exact solution. More...
 

Function/Subroutine Documentation

◆ f()

real(rp) function poisson_2d::f ( real(rp), dimension(3), intent(in)  x)

Right hand side 'f'.

Definition at line 248 of file poisson_2d.f90.

◆ grad_u()

real(rp) function, dimension(3) poisson_2d::grad_u ( real(rp), dimension(3), intent(in)  x)

Gradient of the exact solution.

Definition at line 273 of file poisson_2d.f90.

◆ poisson_2d()

program poisson_2d ( )

SOLVES THE POISSON PROBLEM with homogeneous Neumann boundary conditions

\(~~~~~~~~~ -\Delta u + u = f ~~~\) on \(~~~ \Omega= [0,1]^2 \)

\(~~~~~~~~~~ \nabla u.n = 0 ~~~\) on \(~~~\Gamma = \partial \Omega ~~~\)


VARIATIONAL FORMULATION (Numerical probelm)

  • The finite element space is \( X_h\subset \Hu\).
  • Find \(u\in X_h\) such that \( ~~~~\forall ~v \in X_h, ~~~~ \)

    \[ \int_\Omega \nabla u\cdot\nabla v \,\dx ~+~ \int_\Omega u\, v \,\dx ~=~ \int_\Omega f \, v \,\dx \]


NUMERICAL RESOLUTION

The basis functions are \( (v_i)_{1\le i\le N} \) (basis of \(X_h\)).

  • Computation of the stiffness matrix

    \[ S =[s_{i,\,j}]_{1\le i,\,j\le N}, \quad \quad s_{i,\,j} = \int_\Omega \nabla v_i\cdot\nabla v_j \,\dx \]

  • Computation of the mass matrix

    \[ M =[s_{i,\,j}]_{1\le i,\,j\le N}, \quad \quad m_{i,\,j} = \int_\Omega v_i\, v_j \,\dx \]

  • Computation of the right hand side for the volumoc source term \( f \)

    \[ F = (f_i)_{1\le i\le N}, \quad \quad f_i = \int_\Omega f \, v_i \,\dx \]

  • Resolution of the (symmetric positive definite) system

    \[ (M+S) U_h = F \]



POST TREATMENT

  • Computation of the numerical error between the exact solution \(u\) and the numerical solution \(u_h\),

    \[ \int_\Omega |u-u_h|^2 \dx~,\quad\quad \int_\Omega |\nabla u-\nabla u_h|^2 \dx \]

  • Graphical display of the numerical solution with gmsh

Charles PIERRE, September 2020

Definition at line 62 of file poisson_2d.f90.

Here is the call graph for this function:

◆ u()

real(rp) function poisson_2d::u ( real(rp), dimension(3), intent(in)  x)

Exact solution 'u'.

Definition at line 261 of file poisson_2d.f90.