PLUTO
4.4-patch2
|
Provide basic functionality for reading input data files. More...
#include "pluto.h"
Macros | |
#define | ID_NZ_MAX 4 |
Functions | |
int | InputDataOpen (char *data_fname, char *grid_fname, char *endianity, long int offset, int vpos) |
void | InputDataClose (int indx) |
void | InputDataGridSize (int indx, int *size) |
double | InputDataInterpolate (int indx, double x1, double x2, double x3) |
void | InputDataReadSlice (int indx, int kslice) |
Collects a number of functions for opening, reading and interpolating initial conditions from user-supplied binary data file(s). The geometry and dimensions of the input grid can be different from the actual grid employed by PLUTO, as long as the coordinate geometry transformation has been implemented. The input grid and data files should employ the same format and conventions employed by PLUTO. Specifically:
InputDataOpen() initializes the inputData structure for a given input field (e.g. density) iby reading grid size and coordinates, geometry, precision, endianity, etc..
InputDataInterpolate() is used to interpolate the given field from the input coordinates to the desired coordinate location using bi- or tri-linear interpolation to fill the data array.
The input data is stored in a buffer by reading ID_NZ_MAX planes at a time to save computational memory. The value of ID_NZ_MAX can be changed from your personal definitions.h
. This task is performed in the InputDataReadSlice() function.
#define ID_NZ_MAX 4 |
Maximum size (in the 3rd dimension) of the input buffer.
void InputDataClose | ( | int | indx | ) |
Free memory and reset structure.
void InputDataGridSize | ( | int | indx, |
int * | size | ||
) |
Return the size of the input data array, from the grid file.
[in] | indx | input data array element (handle) |
[in] | size | an array of integer containing the array size [nx1,nx2,nx3] |
double InputDataInterpolate | ( | int | indx, |
double | x1, | ||
double | x2, | ||
double | x3 | ||
) |
Perform bi- or tri-linear interpolation on external dataset to compute vs[] at the given point {x1,x2,x3}.
[in] | indx | input data array element (handle) |
[in] | x1 | coordinate point at which at interpolates are desired |
[in] | x2 | coordinate point at which at interpolates are desired |
[in] | x3 | coordinate point at which at interpolates are desired |
The function performs the following tasks.
int InputDataOpen | ( | char * | data_fname, |
char * | grid_fname, | ||
char * | endianity, | ||
long int | offset, | ||
int | vpos | ||
) |
Initialize access to input data file by assigning values to grid-related information (geometry, number of points, etc...). This function should be called just once for input-data initialization.
[in] | data_fname | the name of the input binary data file |
[in] | grid_fname | the name of the corresponding grid file |
[in] | endianity | an input string ("little" or "big") giving the byte-order of how the input data file was originally written. If an empty string is supplied, no change is made. |
[in] | offset | an integer specifying the offset of the variable (in units of double or float) in the file. |
[in] | vpos | the variable position with respect to the cell center (CENTER / X1FACE / X2FACE / X3FACE). |
0. Find the 1st available (NULL pointer) element in the stack
id->geom
). Search for tag "GEOMETRY:" and read the word that follows.id->nx1
, id->x1
, etc... In the case of a staggered direction [i] refers to the left interface and we increment by 1 the number of points.id->Vin
id->swap_endian
)id->dsize
) by looking at the file extension (dbl
or flt
).id->offset
in bytes) and initialize id->klast
(last read plane) to -1 void InputDataReadSlice | ( | int | indx, |
int | kslice | ||
) |
Read ID_NZ_MAX slices from disk starting at the kslice vertical index.
[in] | indx | the structure index (file handle) |
[in] | kslice | the starting slice |