HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Fourth order finite-difference approximation to the first derivative. More...
#include <stdio.h>
#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <firstderivative.h>
#include <mpivars.h>
#include <hypar.h>
Go to the source code of this file.
Typedefs | |
typedef MPIVariables | MPIContext |
typedef HyPar | SolverContext |
Functions | |
int | FirstDerivativeFourthOrderCentral (double *Df, double *f, int dir, int bias, void *s, void *m) |
Fourth order finite-difference approximation to the first derivative.
Definition in file FirstDerivativeFourthOrder.c.
typedef MPIVariables MPIContext |
Definition at line 14 of file FirstDerivativeFourthOrder.c.
typedef HyPar SolverContext |
Definition at line 15 of file FirstDerivativeFourthOrder.c.
int FirstDerivativeFourthOrderCentral | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
void * | s, | ||
void * | m | ||
) |
Computes the fourth-order finite-difference approximation to the first derivative (Note: not divided by the grid spacing):
\begin{equation} \left(\partial f\right)_i = \left\{ \begin{array}{ll} \frac{1}{12}\left(-25f_i+48f_{i+1}-36f_{i+2}+16f_{i+3}-3f_{i+4}\right) & i=-g \\ \frac{1}{12}\left(-3f_{i-1}-10f_i+18f_{i+1}-6f_{i+2}+f_{i+3}\right) & i = -g+1 \\ \frac{1}{2}\left( f_{i-2}-8f_{i-1}+8f_{i+1}-f_{i+2} \right) & -g+2 \leq i \leq N+g-3 \\ \frac{1}{12}\left( -f_{i-3}+6f_{i-2}-18f_{i-1}+10f_i+3f_{i+1}\right) & i = N+g-2 \\ \frac{1}{12}\left( 3f_{i-4}-16f_{i-3}+36f_{i-2}-48f_{i-1}+25f_i \right) & i = N+g-1 \end{array}\right. \end{equation}
where \(i\) is the grid index along the spatial dimension of the derivative, \(g\) is the number of ghost points, and \(N\) is the number of grid points (not including the ghost points) in the spatial dimension of the derivative.
Notes:
Df | Array to hold the computed first derivative (with ghost points) |
f | Array containing the grid point function values whose first derivative is to be computed (with ghost points) |
dir | The spatial dimension along which the derivative is computed |
bias | Forward or backward differencing for non-central finite-difference schemes (-1: backward, 1: forward) |
s | Solver object of type SolverContext |
m | MPI object of type MPIContext |
Definition at line 36 of file FirstDerivativeFourthOrder.c.