HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Definitions for the functions computing the first derivative. More...
Go to the source code of this file.
Macros | |
#define | _FIRST_ORDER_ "1" |
#define | _SECOND_ORDER_CENTRAL_ "2" |
#define | _FOURTH_ORDER_CENTRAL_ "4" |
Functions | |
int | FirstDerivativeFirstOrder (double *, double *, int, int, void *, void *) |
int | FirstDerivativeSecondOrderCentral (double *, double *, int, int, void *, void *) |
int | FirstDerivativeFourthOrderCentral (double *, double *, int, int, void *, void *) |
int | FirstDerivativeSecondOrderCentralNoGhosts (double *, double *, int, int, int, int *, int, int, void *) |
int | gpuFirstDerivativeFourthOrderCentral (double *, double *, int, int, void *, void *) |
Definitions for the functions computing the first derivative.
Definition in file firstderivative.h.
#define _FIRST_ORDER_ "1" |
First order scheme
Definition at line 10 of file firstderivative.h.
#define _SECOND_ORDER_CENTRAL_ "2" |
Second order central scheme
Definition at line 12 of file firstderivative.h.
#define _FOURTH_ORDER_CENTRAL_ "4" |
Fourth order central scheme
Definition at line 14 of file firstderivative.h.
int FirstDerivativeFirstOrder | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
void * | s, | ||
void * | m | ||
) |
First order approximation to the first derivative (note: not divided by grid spacing)
Computes the first-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} f_{i+1} - f_i & {\rm bias} = 1 \\ f_i - f_{i-1} & {\rm bias} = -1 \end{array}\right. \end{equation}
where \(i\) is the grid index along 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 37 of file FirstDerivativeFirstOrder.c.
int FirstDerivativeSecondOrderCentral | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
void * | s, | ||
void * | m | ||
) |
Second order approximation to the first derivative (note: not divided by grid spacing)
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.
int FirstDerivativeFourthOrderCentral | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
void * | s, | ||
void * | m | ||
) |
Fourth order approximation to the first derivative (note: not divided by grid spacing)
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.
int FirstDerivativeSecondOrderCentralNoGhosts | ( | double * | Df, |
double * | f, | ||
int | dir, | ||
int | bias, | ||
int | ndims, | ||
int * | dim, | ||
int | ghosts, | ||
int | nvars, | ||
void * | m | ||
) |
Second order approximation to the first derivative (note: not divided by grid spacing)
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.
int gpuFirstDerivativeFourthOrderCentral | ( | double * | , |
double * | , | ||
int | , | ||
int | , | ||
void * | , | ||
void * | |||
) |
Fourth order approximation to the first derivative (note: not divided by grid spacing)