version 0.6.0
Loading...
Searching...
No Matches

Scheme submodules More...

Modules

module  mod_finite_differences_scheme_fifth_o1
 Finite Difference Schemes for the third derivative at order 3.
 
module  mod_finite_differences_scheme_fifth_o2
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_first_o1
 Finite Difference Schemes for the first derivative at order 1.
 
module  mod_finite_differences_scheme_first_o2
 Finite Difference Schemes for the first derivative at order 2.
 
module  mod_finite_differences_scheme_first_o3
 Finite Difference Schemes for first derivative at order 3.
 
module  mod_finite_differences_scheme_first_o4
 Finite Difference Schemes for the first derivative at order 4.
 
module  mod_finite_differences_scheme_first_o5
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_first_o6
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_fourth_o1
 Finite Difference Schemes for fourth derivative at order 1.
 
module  mod_finite_differences_scheme_fourth_o2
 Finite Difference Schemes for the third derivative at order 3.
 
module  mod_finite_differences_scheme_fourth_o3
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_second_o1
 Finite Difference Schemes for second derivative at order 1.
 
module  mod_finite_differences_scheme_second_o2
 Finite Difference Schemes for second derivative at order 2.
 
module  mod_finite_differences_scheme_second_o3
 Finite Difference Schemes for second derivative at order 3.
 
module  mod_finite_differences_scheme_second_o4
 Finite Difference Schemes for second derivative at order 4.
 
module  mod_finite_differences_scheme_second_o5
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_sixth_o1
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_third_o1
 Finite Difference Schemes for second derivative at order 1.
 
module  mod_finite_differences_scheme_third_o2
 Finite Difference Schemes for third derivative at order 2.
 
module  mod_finite_differences_scheme_third_o3
 Finite Difference Schemes for the third derivative at order 3.
 
module  mod_finite_differences_scheme_third_o4
 Finite Difference Schemes for the first derivative at order 5.
 
module  mod_finite_differences_scheme_zero
 Finite Difference Schemes for the zero'th derivative (the value)
 
module  mod_finite_differences_weno_scheme_first_o2z
 Finite Difference Weno Scheme for first derivative at order 2Z.
 
module  mod_finite_differences_weno_scheme_first_o3
 Finite Difference Weno Scheme for first derivative at order 3.
 
module  mod_finite_differences_weno_scheme_first_o3z
 Finite Difference Weno Scheme for first derivative at order 3Z.
 
module  mod_finite_differences_weno_scheme_first_o5
 Finite Difference Weno Scheme for first derivative at order 5.
 
module  mod_finite_differences_weno_scheme_first_o5z
 Finite Difference Weno Scheme for first derivative at order 5Z.
 

Detailed Description

All the instances of schemes are (and has to be) created with the procedure fd_initialize()

Usage

Use an existing scheme

Schemes are used to directly or indirectly build FD schemes:

Write your own scheme

Todo
MCO: correct this depracated documentation If you have a particular numerical scheme that you want to implement, you should follow the main scheme_builder_non_uniform interface. To do so, simply write a function that simply:
  1. define the fd_scheme's boundaries (thanks to the fd_scheme%declare_stencil member routine)
  2. fill the fd_scheme%stencilweight array
  3. returns the fd_scheme
Example
We propose here a special example that shows the capacity of FD schemes to touch a wide range of applications. We write the specific scheme for computing a Gaussian weighted mean depending on distances from the central point:
function fd_scheme_gaussian_mean( steps ) result(scheme)
use mod_finite_differences
double precision, dimension(:), intent(in) :: steps
type(t_fd_scheme) :: scheme
double precision :: sigma
double precision :: dist
integer :: sindex, eindex, i
! We assume the steps array to be even
sindex = -size(steps)/2
eindex = size(steps)/2
call scheme%declare_stencil( sindex, eindex )
sigma = 0.25d0*sum(steps)
do i=sindex,eindex
! Compute the distance from the point to the center element
if( i==0 ) then
dist = 0d0
else
dist = sum( steps(min(i,0)+eindex+1:max(i,0)+eindex) )
end if
scheme%stencil%weight(i) = exp(-0.5d0*(dist/sigma)**2)
end do
! Normalize the weights
scheme%stencil%weight(sindex:eindex) = scheme%stencil%weight(sindex:eindex) / sum(scheme%stencil%weight(sindex:eindex))
end function fd_scheme_gaussian_mean
Then, you can easily use your scheme - as long as it is defined in a Fortran module - with the FD computer
result = fd_compute( fd_scheme_gaussian_mean, dx(index-2:index+1), field(index-2:index+2) )
See unit_testing/discretization/node_level_schemes/finite_differences/fd_scheme/finite_differences.f90 for a detailed example.

List of available finite difference schemes

Note
For clarity, the definitions in the table below are simplified, please refer to the code for the actual value (especialy on non uniform grids).
Derivative Order Type Name Definition
First 1 Backward t_fd_scheme_first_o1_backward \( \frac{\phi_{i}-\phi_{i-1}}{\Delta x} \)
First 1 Forward t_fd_scheme_first_o1_forward \( \frac{\phi_{i-1}-\phi_{i}}{\Delta x} \)
First 2 Backward t_fd_scheme_first_o2_backward \( \frac{\phi_{i-2}-4\phi_{i-1}+3\phi_{i}}{2 \Delta x} \)
First 2 Centered fd_scheme_first_o2_centered \( \frac{\phi_{i+1}-\phi_{i-1}}{2 \Delta x} \)
First 2 Forward t_fd_scheme_first_o2_forward \( \frac{-\phi_{i+2}+4\phi_{i+1}-3\phi_{i}}{2 \Delta x} \)
Second 2 Centered fd_scheme_second_o2_centered \( \frac{\phi_{i+1}-2\phi_{i}+\phi_{i-1}}{\Delta x^2} \)