HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Contains function definitions for common mathematical functions for C++ code. More...
Go to the source code of this file.
Functions | |
void | FindInterval (double, double, double *, int, int *, int *) |
void | fillGhostCells (const int *const, const int, double *const, const int, const int, const int *const) |
void | TrilinearInterpCoeffs (double, double, double, double, double, double, double, double, double, double *) |
int | InterpolateGlobalnDVar (const int *const, double **const, const int *const, double *const, const int, const int, const int, const int *const) |
Contains function definitions for common mathematical functions for C++ code.
Definition in file mathfunctions_cpp.h.
void FindInterval | ( | double | a, |
double | b, | ||
double * | x, | ||
int | N, | ||
int * | imin, | ||
int * | imax | ||
) |
Function to calculate the grid points corresponding to a given interval
Given an interval \(\left[a,b\right], a\leq b\), find grid indices imin and imax, such that
\begin{align} imin &= \min\ i\ {\rm satisfying}\ x_i \geq a\\ imax &= \max\ i\ {\rm satisfying}\ x_i \leq b \end{align}
where \(\left\{x_i; 0\leq i < N , x_i < x_{i+1} \forall i \right\}\) represents a 1-dimensional grid.
Note: This function handles 1-dimensional intervals and grids only.
a | Lower bound of interval |
b | Upper bound of interval |
x | Array of spatial coordinates representing a grid |
N | Number of grid points / size of x |
imin | Lowest grid index within [a,b] |
imax | Highest grid index within [a,b] |
Definition at line 19 of file FindInterval.c.
void fillGhostCells | ( | const int *const | a_dim, |
const int | a_ngpt, | ||
double *const | a_u, | ||
const int | a_nvars, | ||
const int | a_ndims, | ||
const int *const | a_periodic | ||
) |
Fill the ghost cells of a global n-dimensional array
Fill the ghost cells of a solution. Note that the solution array must be a global one (not one that is partitioned among MPI ranks). This is not a parallel operation (it will execute independently on multiple MPI ranks, if called by multiple processes).
For periodicity along any dimension, the ghost cells are filled appropriately from the other side of the domain. Otherwise, the interior data is extrapolated by a 4th order polynomial (assuming uniform grid spacing).
a_dim | grid dimensions of solution |
a_ngpt | number of ghost cells |
a_u | solution array |
a_nvars | number of vector components of the solution |
a_ndims | number of spatial dimensions |
a_periodic | periodic or not along each dimension |
Definition at line 17 of file FillGhostCells.c.
void TrilinearInterpCoeffs | ( | double | xmin, |
double | xmax, | ||
double | ymin, | ||
double | ymax, | ||
double | zmin, | ||
double | zmax, | ||
double | x, | ||
double | y, | ||
double | z, | ||
double * | coeffs | ||
) |
Function to compute trilinear interpolation coefficients
This function computes the coefficients for a trilinear interpolation at a given point (x,y,z) inside a cube defined by [xmin,xmax] X [ymin,ymax] X [zmin,zmax]. The coefficients are stored in an array of size 8 with each element corresponding to a corner of the cube in the following order:
coeffs[0] => xmin,ymin,zmin
coeffs[1] => xmax,ymin,zmin
coeffs[2] => xmin,ymax,zmin
coeffs[3] => xmax,ymax,zmin
coeffs[4] => xmin,ymin,zmax
coeffs[5] => xmax,ymin,zmax
coeffs[6] => xmin,ymax,zmax
coeffs[7] => xmax,ymax,zmax
xmin | x-coordinate of the lower-end |
xmax | x-coordinate of the higher-end |
ymin | y-coordinate of the lower-end |
ymax | y-coordinate of the higher-end |
zmin | z-coordinate of the lower-end |
zmax | z-coordinate of the higher-end |
x | x-coordinate of the point to interpolate at |
y | y-coordinate of the point to interpolate at |
z | z-coordinate of the point to interpolate at |
coeffs | array of size 8 (pre-allocated) to store the coefficients in |
Definition at line 22 of file TrilinearInterpolation.c.
int InterpolateGlobalnDVar | ( | const int *const | a_dim_dst, |
double **const | a_u_dst, | ||
const int *const | a_dim_src, | ||
double *const | a_u_src, | ||
const int | a_nvars, | ||
const int | a_ghosts, | ||
const int | a_ndims, | ||
const int *const | a_periodic | ||
) |
Interpolate an n-dimensional grid variable from one grid to another
Interpolate n-dimensional data from one grid to another of a desired resolution. Note that along each dimension, the ratio of the number of grid points in the source grid and that in the destination grid must be an integer power of 2 (negative or positive).
The source data must be global. It will get deallocated at the end of this function. It must have the appropriate number of ghost points.
The incoming pointer for destination data must be NULL. After this function is executed, it will point to a chunk of memory with the interpolated solution. This is the global solution. It will have the specified number of ghost points appropriately filled.
a_dim_dst | grid dimensions to interpolate to |
a_u_dst | pointer to array containing interpolated data |
a_dim_src | grid dimensions to interpolate from |
a_u_src | pointer to array containing data to interpolate from |
a_nvars | Number of vector components of the solution |
a_ghosts | Number of ghost points |
a_ndims | Number of spatial dimensions |
a_periodic | Is the domain periodic or not along each dimension |
Definition at line 317 of file InterpolateGlobalnDVar.c.