HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Second order finite-difference approximation to 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 | FirstDerivativeSecondOrderCentral (double *Df, double *f, int dir, int bias, void *s, void *m) |
Second order finite-difference approximation to first derivative.
Definition in file FirstDerivativeSecondOrder.c.
typedef MPIVariables MPIContext |
Definition at line 14 of file FirstDerivativeSecondOrder.c.
typedef HyPar SolverContext |
Definition at line 15 of file FirstDerivativeSecondOrder.c.
int FirstDerivativeSecondOrderCentral | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
void * | s, | ||
void * | m | ||
) |
Computes the second-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}{2}\left(-3f_i+4f_{i+1}-f_{i+2}\right) & i = -g \\ \frac{1}{2}\left( f_{i+1} - f_{i-1} \right) & -g+1 \leq i \leq N+g-2 \\ \frac{1}{2}\left( f_{i-2} -4f_{i-1}+3f_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 FirstDerivativeSecondOrder.c.