HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Function declarations for file I/O functions. More...
Go to the source code of this file.
Functions | |
int | ReadArray (int, int, int *, int *, int, void *, void *, double *, double *, char *, int *) |
int | ReadArraywInterp (int, int, int *, int *, int *, int, void *, void *, double *, double *, char *, int *) |
int | WriteArray (int, int, int *, int *, int, double *, double *, void *, void *, char *) |
int | WriteBinary (int, int, int *, double *, double *, char *, int *) |
int | WriteText (int, int, int *, double *, double *, char *, int *) |
int | WriteTecplot2D (int, int, int *, double *, double *, char *, int *) |
int | WriteTecplot3D (int, int, int *, double *, double *, char *, int *) |
Function declarations for file I/O functions.
Definition in file io.h.
int ReadArray | ( | int | ndims, |
int | nvars, | ||
int * | dim_global, | ||
int * | dim_local, | ||
int | ghosts, | ||
void * | s, | ||
void * | m, | ||
double * | x, | ||
double * | u, | ||
char * | fname_root, | ||
int * | read_flag | ||
) |
Read in a vector field from file: wrapper function that calls the appropriate function depending on input mode (HyPar::input_mode).
The mode and type of input are specified through HyPar::input_mode and HyPar::ip_file_type. A vector field is read from file and stored in an array.
ndims | Number of spatial dimensions |
nvars | Number of variables per grid point |
dim_global | Integer array of size ndims with global grid size in each dimension |
dim_local | Integer array of size ndims with local grid size in each dimension |
ghosts | Number of ghost points |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
x | Grid associated with the array (can be NULL) |
u | Array to hold the vector field |
fname_root | Filename root |
read_flag | Flag to indicate if the file was read |
Definition at line 25 of file ReadArray.c.
int ReadArraywInterp | ( | int | ndims, |
int | nvars, | ||
int * | dim_global, | ||
int * | dim_local, | ||
int * | dim_global_src, | ||
int | ghosts, | ||
void * | s, | ||
void * | m, | ||
double * | x, | ||
double * | u, | ||
char * | fname_root, | ||
int * | read_flag | ||
) |
Read in a vector field from file: This version allows reading data with different dimensions than the array being read in. The data is read in and stored in a new global array with the appropriate size, and the array to be read is filled by interpolation. Currently, the dimensions of the array to be read and the those of the actual data can only differ by factors that are integer powers of 2.
This is a wrapper function that calls the appropriate function depending on input mode (HyPar::input_mode).
The mode and type of input are specified through HyPar::input_mode and HyPar::ip_file_type. A vector field is read from file and stored in an array.
ndims | Number of spatial dimensions |
nvars | Number of variables per grid point |
dim_global | Integer array of size ndims with global size in each dimension |
dim_local | Integer array of size ndims with local size in each dimension |
dim_global_src | Integer array of size ndims with global size of the data in each dimension |
ghosts | Number of ghost points |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
x | Grid associated with the array (can be NULL) |
u | Array to hold the vector field |
fname_root | Filename root |
read_flag | Flag to indicate if the file was read |
Definition at line 28 of file ReadArraywInterp.c.
int WriteArray | ( | int | ndims, |
int | nvars, | ||
int * | dim_global, | ||
int * | dim_local, | ||
int | ghosts, | ||
double * | x, | ||
double * | u, | ||
void * | s, | ||
void * | m, | ||
char * | fname_root | ||
) |
Write out a vector field, stored as an array, to file: wrapper function that calls the appropriate function depending on output mode (HyPar::output_mode). The output file format is determined by HyPar::op_file_format
ndims | Number of spatial dimensions |
nvars | Number of variables per grid point |
dim_global | Integer array of size ndims with global grid size in each dimension |
dim_local | Integer array of size ndims with local grid size in each dimension |
ghosts | Number of ghost points |
x | Array of spatial coordinates (i.e. the grid) |
u | Vector field to write |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
fname_root | Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. |
Definition at line 27 of file WriteArray.c.
int WriteBinary | ( | int | ndims, |
int | nvars, | ||
int * | dim, | ||
double * | x, | ||
double * | u, | ||
char * | f, | ||
int * | index | ||
) |
Write a vector field and its grid to a binary file. The data is written in the following format:
{
ndims
nvars
dim[0] dim[1] dim[2] ... dim[ndims-1]
x0_i (0 <= i < dim[0])
x1_i (0 <= i < dim[1])
...
x{ndims-1}_i (0 <= i < dim[ndims-1])
[u0,u1,...,u{nvars-1}]_p (0 <= p < N) (with no commas)
}
where
x0, x1, ..., x{ndims-1} represent the spatial dimensions (for a 3D problem, x0 = x, x1 = y, x2 = z),
u0, u1, ..., u{nvars-1} are each component of the vector u at a grid point,
N = dim[0]*dim[1]*...*dim[ndims-1] is the total number of points,
and p = i0 + dim[0]*( i1 + dim[1]*( i2 + dim[2]*( ... + dim[ndims-2] * i{ndims-1} ))) (see _ArrayIndexnD_)
with i0, i1, i2, etc representing grid indices along each spatial dimension, i.e.,
0 <= i0 < dim[0]-1
0 <= i1 < dim[1]-1
...
0 <= i{ndims-1} < dim[ndims=1]-1
ndims | Number of spatial dimensions |
nvars | Number of variables at each grid point |
dim | Integer array with the number of grid points in each spatial dimension as its entries |
x | Array of spatial coordinates representing a Cartesian grid (no ghost points) |
u | Array containing the vector field to write (no ghost points) |
f | Filename |
index | Preallocated integer array of size ndims |
Definition at line 34 of file WriteBinary.c.
int WriteText | ( | int | ndims, |
int | nvars, | ||
int * | dim, | ||
double * | x, | ||
double * | u, | ||
char * | f, | ||
int * | index | ||
) |
Write a vector field and its associated grid to a text file. The data is written to the text file in the following format:
Each line of the file contains
i0 i1 ... i{ndims-1} x0[i0] x1[i1] ... x{ndims-1}[i{ndims-1}] u0[p] u1[p] ... u{nvars-1}[p]
where
(i0,i1,...,i{ndims-1}) represents a ndims-dimensional grid index,
x0, x1, ..., x{ndims-1} are the spatial dimensions (e.g. in 3D, ndims = 3, x0 = x, x1 = y, x2 = z)
u0, u1, ..., u{nvars-1} are the components of the vector field u
p = i0 + dim[0] * (i1 + dim[1] * (i2 + dim[2] * ( ... + dim[ndims-2] * i{ndims-1} ))) (see _ArrayIndexnD_)
Thus, the number of lines is dim[0]*dim[1]*...*dim[ndims-1]
This is a plain text file, so it can be visualized using, say MATLAB, or any software that can read data from a plain text file. For 1D (ndims = 1), the data can be easily plotted in Gnuplot (for example).
ndims | Number of spatial dimensions |
nvars | Number of variables at each grid point |
dim | Integer array with the number of grid points in each spatial dimension as its entries |
x | Array of spatial coordinates representing a Cartesian grid (no ghost points) |
u | Array containing the vector field to write (no ghost points) |
f | Filename |
index | Preallocated integer array of size ndims |
Definition at line 27 of file WriteText.c.
int WriteTecplot2D | ( | int | ndims, |
int | nvars, | ||
int * | dim, | ||
double * | x, | ||
double * | u, | ||
char * | f, | ||
int * | index | ||
) |
Write a vector field and its associated grid to a 2D Tecplot file. This file can then be visualized using Tecplot (http://www.tecplot.org) (if available).
Note: It's essentially a text file, and apart from the first two lines with Tecplot specific headers, the data is written out in the same format as WriteText().
ndims | Number of spatial dimensions |
nvars | Number of variables at each grid point |
dim | Integer array with the number of grid points in each spatial dimension as its entries |
x | Array of spatial coordinates representing a Cartesian grid (no ghost points) |
u | Array containing the vector field to write (no ghost points) |
f | Filename |
index | Preallocated integer array of size ndims |
Definition at line 19 of file WriteTecplot2D.c.
int WriteTecplot3D | ( | int | ndims, |
int | nvars, | ||
int * | dim, | ||
double * | x, | ||
double * | u, | ||
char * | f, | ||
int * | index | ||
) |
Write a vector field and its associated grid to a 3D Tecplot file. This file can then be visualized using Tecplot (http://www.tecplot.org) (if available)
Note: It's essentially a text file, and apart from the first two lines with Tecplot specific headers, the data is written out in the same format as WriteText().
ndims | Number of spatial dimensions |
nvars | Number of variables at each grid point |
dim | Integer array with the number of grid points in each spatial dimension as its entries |
x | Array of spatial coordinates representing a Cartesian grid (no ghost points) |
u | Array containing the vector field to write (no ghost points) |
f | Filename |
index | Preallocated integer array of size ndims |
Definition at line 19 of file WriteTecplot3D.c.