HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Contains macros and function definitions for common array operations. More...
Go to the source code of this file.
Macros | |
#define | _ArrayIndexnD_(N, index, imax, i, ghost) |
#define | _ArrayIndex1D_(N, imax, i, ghost, index) |
#define | _ArrayIndex1D2_(N, imax, i, ghost, index) |
#define | _ArrayIndex1D3_(N, imax, i, ghost, index) |
#define | _ArrayIndex1DWO_(N, imax, i, offset, ghost, index) |
#define | _ArrayIndex1DWO2_(N, imax, i, offset, ghost, index) |
#define | _ArrayIndex1DWO3_(N, imax, i, offset, ghost, index) |
#define | _ArrayIncrementIndex_(N, imax, i, done) |
#define | _ArrayIncrementIndexWithLBound_(N, imax, imin, i, done) |
#define | _ArraySetValue_(x, size, value) |
#define | _ArraySum1D_(x, a, size) |
#define | _ArrayScale1D_(x, a, size) |
#define | _ArraySubtract1D_(x, a, b, size) |
#define | _ArrayAdd1D_(x, a, b, size) |
#define | _ArrayMultiply1D_(x, a, b, size) |
#define | _ArrayMultiply3Add1D_(x, a, b, c, d, e, f, size) |
#define | _ArrayConvexCombination1D_(z, a, x, y, size) |
#define | _ArrayAYPX_(x, a, y, size) |
#define | _ArrayAXPY_(x, a, y, size) |
#define | _ArrayAXBY_(z, a, x, b, y, size) |
#define | _ArrayAXBYCZ_(w, a, x, b, y, c, z, size) |
#define | _ArrayScaledAXPY_(x, a, e, y, size) |
#define | _ArrayCopy1D_(x, y, size) |
#define | _ArrayCopy1D2_(x, y, size) |
#define | _ArrayCopy1D3_(x, y, size) |
#define | _ArrayScaleCopy1D_(x, a, y, size) |
#define | _ArrayAddCopy1D_(x, a, y, size) |
#define | _ArrayProduct1D_(x, size, p) |
#define | _ArrayBlockMultiply_(x, a, n, bs) |
#define | INLINE inline |
Functions | |
INLINE int | ArrayCopynD (int, const double *, double *, int *, int, int, int *, int) |
INLINE double | ArrayMaxnD (int, int, int *, int, int *, double *) |
INLINE double | ArraySumSquarenD (int, int, int *, int, int *, double *) |
INLINE double | ArraySumAbsnD (int, int, int *, int, int *, double *) |
INLINE void | ArrayCheckEqual (const char *, const double *, const double *, int, int) |
INLINE void | ArrayCheckEqual2 (const char *, const double *, const double *, int) |
INLINE int | ArrayCopynDComponent (int ndims, const double *x, double *y, int *dim, int g1, int g2, int *index, int nvars_from, int nvars_to, int var_from, int var_to) |
Contains macros and function definitions for common array operations.
Definition in file arrayfunctions.h.
#define _ArrayIndexnD_ | ( | N, | |
index, | |||
imax, | |||
i, | |||
ghost | |||
) |
Returns the N -dimensional index i[N] in an N -dimensional array of size imax[N] with ghost number of ghost points, given the 1-dimensional index in the corresponding 1-dimensional array stored in memory.
Definition at line 21 of file arrayfunctions.h.
#define _ArrayIndex1D_ | ( | N, | |
imax, | |||
i, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the N -dimensional index i[N] in an N -dimensional array of size imax[N] with ghost number of ghost points.
Definition at line 40 of file arrayfunctions.h.
#define _ArrayIndex1D2_ | ( | N, | |
imax, | |||
i, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the 2-dimensional index i[2] in an 2-dimensional array of size imax[2] with ghost number of ghost points. N is not used, but retained for uniformity.
Definition at line 56 of file arrayfunctions.h.
#define _ArrayIndex1D3_ | ( | N, | |
imax, | |||
i, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the 3-dimensional index i[3] in an 3-dimensional array of size imax[3] with ghost number of ghost points. N is not used, but retained for uniformity.
Definition at line 69 of file arrayfunctions.h.
#define _ArrayIndex1DWO_ | ( | N, | |
imax, | |||
i, | |||
offset, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the N -dimensional index i[N] + an offset[N] in an N -dimensional array of size imax[N] with ghost number of ghost points.
Definition at line 83 of file arrayfunctions.h.
#define _ArrayIndex1DWO2_ | ( | N, | |
imax, | |||
i, | |||
offset, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the 2-dimensional index i[2] + an offset[2] in an 2-dimensional array of size imax[2] with ghost number of ghost points. N is not used, but retained for uniformity.
Definition at line 100 of file arrayfunctions.h.
#define _ArrayIndex1DWO3_ | ( | N, | |
imax, | |||
i, | |||
offset, | |||
ghost, | |||
index | |||
) |
Returns 1-dimensional index in the corresponding 1-dimensional array stored in memory, given the 3-dimensional index i[3] + an offset[3] in an 3-dimensional array of size imax[3] with ghost number of ghost points. N is not used, but retained for uniformity.
Definition at line 114 of file arrayfunctions.h.
#define _ArrayIncrementIndex_ | ( | N, | |
imax, | |||
i, | |||
done | |||
) |
Increments an N -dimensional index i[N] by one. If it reaches the provided bounds imax[N], i.e., if i[c] = imax[c]-1 for all c = 0,...,N-1), then done = 1; else done = 0.
Definition at line 126 of file arrayfunctions.h.
#define _ArrayIncrementIndexWithLBound_ | ( | N, | |
imax, | |||
imin, | |||
i, | |||
done | |||
) |
Increments an N -dimensional index i[N] by one. If it reaches the provided bounds imax[N], i.e., if i[c] = imax[c]-1 for all c = 0,...,N-1), then done = 1; else done = 0. This is the same as ArrayIncrementIndex but with a specified lower bound imin instead of 0.
Definition at line 149 of file arrayfunctions.h.
#define _ArraySetValue_ | ( | x, | |
size, | |||
value | |||
) |
Set all elements of a 1-dimensional array x (any datatype) of length size to a scalar value
Definition at line 169 of file arrayfunctions.h.
#define _ArraySum1D_ | ( | x, | |
a, | |||
size | |||
) |
Compute the sum of all elements of a 1-dimensional array x of length size.
Definition at line 179 of file arrayfunctions.h.
#define _ArrayScale1D_ | ( | x, | |
a, | |||
size | |||
) |
Multiply all elements of a 1-dimensional array x of length size by a scalar value
Definition at line 190 of file arrayfunctions.h.
#define _ArraySubtract1D_ | ( | x, | |
a, | |||
b, | |||
size | |||
) |
Element-wise subtraction x = a - b, where x, a, and b are 1-dimensional arrays of length size
Definition at line 201 of file arrayfunctions.h.
#define _ArrayAdd1D_ | ( | x, | |
a, | |||
b, | |||
size | |||
) |
Element-wise addition x = a + b, where x, a, and b are 1-dimensional arrays of length size
Definition at line 212 of file arrayfunctions.h.
#define _ArrayMultiply1D_ | ( | x, | |
a, | |||
b, | |||
size | |||
) |
Element-wise multiplication x = a . b, where x, a, and b are 1-dimensional arrays of length size (a.k.a. dot product).
Definition at line 223 of file arrayfunctions.h.
#define _ArrayMultiply3Add1D_ | ( | x, | |
a, | |||
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
size | |||
) |
Element-wise x =a . b + c . d + e . f, where x, a, b, c, d, e, and f, are 1-dimensional arrays of length size.
Definition at line 234 of file arrayfunctions.h.
#define _ArrayConvexCombination1D_ | ( | z, | |
a, | |||
x, | |||
y, | |||
size | |||
) |
Element-wise convex combination z = a . x + (1-a) . y, where a, x, y, z are 1-dimensional arrays of length size.
Definition at line 245 of file arrayfunctions.h.
#define _ArrayAYPX_ | ( | x, | |
a, | |||
y, | |||
size | |||
) |
Element-wise AYPX y = a y + x, where a is a scalar, and x, y, z are 1-dimensional arrays of length size.
Definition at line 258 of file arrayfunctions.h.
#define _ArrayAXPY_ | ( | x, | |
a, | |||
y, | |||
size | |||
) |
Element-wise AXPY y = a x + y, where a is a scalar, and x, y, z are 1-dimensional arrays of length size.
Definition at line 271 of file arrayfunctions.h.
#define _ArrayAXBY_ | ( | z, | |
a, | |||
x, | |||
b, | |||
y, | |||
size | |||
) |
Element-wise AXPY z = a x + b y, where a , b are scalars, and x, y, z are 1-dimensional arrays of length size.
Definition at line 283 of file arrayfunctions.h.
#define _ArrayAXBYCZ_ | ( | w, | |
a, | |||
x, | |||
b, | |||
y, | |||
c, | |||
z, | |||
size | |||
) |
Element-wise AXPY w = a x + b y + c z, where a, b, c are scalars, and x, y, z, w are 1-dimensional arrays of length size.
Definition at line 295 of file arrayfunctions.h.
#define _ArrayScaledAXPY_ | ( | x, | |
a, | |||
e, | |||
y, | |||
size | |||
) |
Element-wise Scaled AXPY y = e * (y + a * x), where a, e are scalars, and x, y are 1-dimensional arrays of length size.
Definition at line 307 of file arrayfunctions.h.
#define _ArrayCopy1D_ | ( | x, | |
y, | |||
size | |||
) |
Element-wise copy y = x, where x, y are 1-dimensional arrays of length size.
Definition at line 319 of file arrayfunctions.h.
#define _ArrayCopy1D2_ | ( | x, | |
y, | |||
size | |||
) |
Element-wise copy y = x, where x, y are 1-dimensional arrays of length 2. size is not used but retained for uniformity.
Definition at line 331 of file arrayfunctions.h.
#define _ArrayCopy1D3_ | ( | x, | |
y, | |||
size | |||
) |
Element-wise copy y = x, where x, y are 1-dimensional arrays of length 3. size is not used but retained for uniformity.
Definition at line 343 of file arrayfunctions.h.
#define _ArrayScaleCopy1D_ | ( | x, | |
a, | |||
y, | |||
size | |||
) |
Element-wise scale and copy y = a * x, where is a scalar, and x, y are one-dimensional arrays of length size.
Definition at line 356 of file arrayfunctions.h.
#define _ArrayAddCopy1D_ | ( | x, | |
a, | |||
y, | |||
size | |||
) |
Element-wise add and copy y = a + x, where x,y are one-dimensional arrays of length size, and a is a scalar.
Definition at line 368 of file arrayfunctions.h.
#define _ArrayProduct1D_ | ( | x, | |
size, | |||
p | |||
) |
p is the product of all the elements of the one-dimensional array x of length size.
Definition at line 377 of file arrayfunctions.h.
#define _ArrayBlockMultiply_ | ( | x, | |
a, | |||
n, | |||
bs | |||
) |
Given two arrays: x of size n*bs, and a of size n, this macro implements: x[i][j] *= a[i] where i = 1,...,n, j = 1,...,bs, and x is stored as a 1D array in row-major format, i.e., x[i][j] = x[i*bs+j].
Definition at line 388 of file arrayfunctions.h.
#define INLINE inline |
Definition at line 399 of file arrayfunctions.h.
INLINE int ArrayCopynD | ( | int | ndims, |
const double * | x, | ||
double * | y, | ||
int * | dim, | ||
int | g1, | ||
int | g2, | ||
int * | index, | ||
int | nvars | ||
) |
Copy one n-D array to another n-D array (both of which are stored in memory as 1D arrays)
ndims | number of dimensions |
x | copy-from array |
y | copy-to array |
dim | integer array of size in each dimension |
g1 | number of ghost points in copy-from array x |
g2 | number of ghost points in copy-to array y |
index | pre-allocated (by the calling function) integer array of size ndims |
nvars | number of elements at one array location, can be > 1 for systems of equations) |
Definition at line 410 of file arrayfunctions.h.
INLINE double ArrayMaxnD | ( | int | nvars, |
int | ndims, | ||
int * | dim, | ||
int | ghosts, | ||
int * | index, | ||
double * | x | ||
) |
Returns the maximum magnitude element in an n-D array (useful for L_inf norm)
nvars | number of elements at one array location, can be > 1 for systems of equations |
ndims | number of dimensions |
dim | integer array containing the size of x in each dimension |
ghosts | number of ghost points in the array x |
index | pre-allocated (by the calling function) integer array of size ndims |
x | the array |
Definition at line 486 of file arrayfunctions.h.
INLINE double ArraySumSquarenD | ( | int | nvars, |
int | ndims, | ||
int * | dim, | ||
int | ghosts, | ||
int * | index, | ||
double * | x | ||
) |
Returns the sum-of-squares of the elements in an n-D array (useful for L_2 norm)
nvars | number of elements at one array location, can be > 1 for systems of equations |
ndims | number of dimensions |
dim | integer array of size in each dimension |
ghosts | number of ghost points in the array x |
index | pre-allocated (by the calling function) integer array of size ndims |
x | the array |
Definition at line 529 of file arrayfunctions.h.
INLINE double ArraySumAbsnD | ( | int | nvars, |
int | ndims, | ||
int * | dim, | ||
int | ghosts, | ||
int * | index, | ||
double * | x | ||
) |
Returns the sum-of-magnitudes of the elements in an n-D array (useful for L_1 norm)
nvars | number of elements at one array location, can be > 1 for systems of equations |
ndims | number of dimensions |
dim | integer array of size in each dimension |
ghosts | number of ghost points in the array x |
index | pre-allocated (by the calling function) integer array of size ndims |
x | the array |
Definition at line 510 of file arrayfunctions.h.
INLINE void ArrayCheckEqual | ( | const char * | msg, |
const double * | var_adj, | ||
const double * | var_sep, | ||
int | npoints, | ||
int | nvars | ||
) |
Definition at line 547 of file arrayfunctions.h.
INLINE void ArrayCheckEqual2 | ( | const char * | msg, |
const double * | var_adj, | ||
const double * | var_sep, | ||
int | npoints | ||
) |
Definition at line 566 of file arrayfunctions.h.
INLINE int ArrayCopynDComponent | ( | int | ndims, |
const double * | x, | ||
double * | y, | ||
int * | dim, | ||
int | g1, | ||
int | g2, | ||
int * | index, | ||
int | nvars_from, | ||
int | nvars_to, | ||
int | var_from, | ||
int | var_to | ||
) |
Copies a component of an n-D array to another n-D array of at least one component (both of which are stored in memory as 1D arrays); the two arrays must be of the same n-dimensional size (locally and globally)
ndims | number of dimensions |
x | copy-from array |
y | copy-to array |
dim | integer array of size in each dimension |
g1 | number of ghost points in copy-from array x |
g2 | number of ghost points in copy-to array y |
index | pre-allocated (by the calling function) integer array of size ndims |
nvars_from | number of components/variables in copy-from array |
nvars_to | number of components/variables in copy-from array |
var_from | component to copy from in x |
var_to | component to copy to in y |
Definition at line 444 of file arrayfunctions.h.