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>
Go to the source code of this file.
Macros | |
#define | _MINIMUM_GHOSTS_ 1 |
Typedefs | |
typedef MPIVariables | MPIContext |
Functions | |
int | FirstDerivativeSecondOrderCentralNoGhosts (double *Df, double *f, int dir, int bias, int ndims, int *dim, int ghosts, int nvars, void *m) |
Second order finite-difference approximation to first derivative.
Definition in file FirstDerivativeSecondOrderNoGhosts.c.
#define _MINIMUM_GHOSTS_ 1 |
Minimum number of ghost points required.
Definition at line 19 of file FirstDerivativeSecondOrderNoGhosts.c.
typedef MPIVariables MPIContext |
Definition at line 13 of file FirstDerivativeSecondOrderNoGhosts.c.
int FirstDerivativeSecondOrderCentralNoGhosts | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
int | ndims, | ||
int * | dim, | ||
int | ghosts, | ||
int | nvars, | ||
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) |
ndims | Number of spatial/coordinate dimensions |
dim | Local dimensions |
ghosts | Number of ghost points |
nvars | Number of vector components at each grid points |
m | MPI object of type MPIContext |
Definition at line 42 of file FirstDerivativeSecondOrderNoGhosts.c.