Memory allocation functions.
More...
|
void | FreeArray1D (void *v) |
|
void | FreeArray2D (void **m) |
|
void | FreeArray3D (void ***m) |
|
void | FreeArray4D (void ****m) |
|
char * | Array1D (int nx, size_t dsize) |
|
char ** | Array2D (int nx, int ny, size_t dsize) |
|
char *** | Array3D (int nx, int ny, int nz, size_t dsize) |
|
char **** | Array4D (int nx, int ny, int nz, int nv, size_t dsize) |
|
double *** | ArrayBox (long int nrl, long int nrh, long int ncl, long int nch, long int ndl, long int ndh) |
|
void | FreeArrayBox (double ***t, long nrl, long ncl, long ndl) |
|
double *** | ArrayMap (int nx, int ny, int nz, double *uptr) |
|
void | FreeArrayMap (double ***t) |
|
double *** | ArrayBoxMap (int nrl, int nrh, int ncl, int nch, int ndl, int ndh, double *uptr) |
|
void | FreeArrayBoxMap (double ***t, int nrl, int nrh, int ncl, int nch, int ndl, int ndh) |
|
Provides essential functions for allocating and deallocating multi-dimensional arrays. The functions Array1D(), Array2D(), Array3D(), Array4D() can be used to allocate storage for 1-D, 2-D, 3-D and 4-D arrays of any data type with indices starting at 0.
The function ArrayBox() can be used to allocate memory for a double precision array with specified index range.
The functions ArrayMap() can be used to convert a one-dimensional array into a 3D array.
- Author
- A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
- Date
- Sep 18, 2012
char* Array1D |
( |
int |
nx, |
|
|
size_t |
dsize |
|
) |
| |
Allocate memory for a 1-D array of any basic data type starting at 0.
- Parameters
-
[in] | nx | number of elements to be allocated |
[in] | dsize | data-type of the array to be allocated |
- Returns
- A pointer of type (char *) to the allocated memory area.
char** Array2D |
( |
int |
nx, |
|
|
int |
ny, |
|
|
size_t |
dsize |
|
) |
| |
Allocate memory for a 2-D array of any basic data type.
- Parameters
-
[in] | nx | number of elements in the 2nd dimension |
[in] | ny | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
- Returns
- A pointer of type (char **) to the allocated memory area with index range [0...nx-1][0...ny-1]
char*** Array3D |
( |
int |
nx, |
|
|
int |
ny, |
|
|
int |
nz, |
|
|
size_t |
dsize |
|
) |
| |
Allocate memory for a 3-D array of any basic data type.
- Parameters
-
[in] | nx | number of elements in the 3rd dimension |
[in] | ny | number of elements in the 2nd dimension |
[in] | nz | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
- Returns
- A pointer of type (char ***) to the allocated memory area with index range [0...nx-1][0...ny-1][0...nz-1]
char**** Array4D |
( |
int |
nx, |
|
|
int |
ny, |
|
|
int |
nz, |
|
|
int |
nv, |
|
|
size_t |
dsize |
|
) |
| |
Allocate memory for a 4-D array of any basic data type.
- Parameters
-
[in] | nx | number of elements in the 4th dimension |
[in] | ny | number of elements in the 3rd dimension |
[in] | nz | number of elements in the 2nd dimension |
[in] | nv | number of elements in the 1st dimension |
[in] | dsize | data-type of the array to be allocated |
- Returns
- A pointer of type (char ****) to the allocated memory area with index range [0...nx-1][0...ny-1][0...nz-1][0...nv-1]
double*** ArrayBox |
( |
long int |
nrl, |
|
|
long int |
nrh, |
|
|
long int |
ncl, |
|
|
long int |
nch, |
|
|
long int |
ndl, |
|
|
long int |
ndh |
|
) |
| |
Allocate memory for a 3-D array in double precision with given subscript range [low...high] for each direction. Useful for staggered arrays which do not start at [0].
- Parameters
-
[in] | nrl | lower bound index for the 3rd dimension |
[in] | nrh | upper bound index for the 3rd dimension |
[in] | ncl | lower bound index for the 2nd dimension |
[in] | nch | upper bound index for the 2nd dimension |
[in] | ndl | lower bound index for the 1st dimension |
[in] | ndh | upper bound index for the 1st dimension |
- Returns
- A pointer of type (double ***) to the allocated memory area with index range [nrl...nhl][ncl...nch][ndl...ndh].
double*** ArrayBoxMap |
( |
int |
nrl, |
|
|
int |
nrh, |
|
|
int |
ncl, |
|
|
int |
nch, |
|
|
int |
ndl, |
|
|
int |
ndh, |
|
|
double * |
uptr |
|
) |
| |
Convert a one-dimensional array into a 3D array with given subscript range [low...high] for each direction.
double*** ArrayMap |
( |
int |
nx, |
|
|
int |
ny, |
|
|
int |
nz, |
|
|
double * |
uptr |
|
) |
| |
Convert a one dimensional array with (nx*ny*nz) elements into a 3D array with index range [0..nx-1][0..ny-1][0..nz-1]. This function is similar, conceptually, to Array3D() except that the memory area is already allocated.
- Parameters
-
[in] | uptr | pointer to 1D array |
[in] | nx | number of elements in the 3rd dimension |
[in] | ny | number of elements in the 2nd dimensions |
[in] | nz | number of elements in the 1st dimensions |
- Returns
- A pointer to the 3D array.
void FreeArray1D |
( |
void * |
v | ) |
|
Free memory allocated by the pointer *v.
void FreeArray2D |
( |
void ** |
m | ) |
|
Free memory allocated by the double pointer **v.
void FreeArray3D |
( |
void *** |
m | ) |
|
Free memory allocated by the pointer ***v.
void FreeArray4D |
( |
void **** |
m | ) |
|
Free memory allocated by the pointer ****v.
void FreeArrayBox |
( |
double *** |
t, |
|
|
long |
nrl, |
|
|
long |
ncl, |
|
|
long |
ndl |
|
) |
| |
Free memory allocated by the ArrayBox function.
- Parameters
-
[in] | t | pointer to an allocated memory area |
[in] | nrl | starting index of the array for the 3rd dimension |
[in] | ncl | starting index of the array for the 2nd dimension |
[in] | ndl | starting index of the array for the 1st dimension |
void FreeArrayBoxMap |
( |
double *** |
t, |
|
|
int |
nrl, |
|
|
int |
nrh, |
|
|
int |
ncl, |
|
|
int |
nch, |
|
|
int |
ndl, |
|
|
int |
ndh |
|
) |
| |
void FreeArrayMap |
( |
double *** |
t | ) |
|