HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Read in a vector field from file. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <mathfunctions.h>
#include <mpivars.h>
#include <hypar.h>
Go to the source code of this file.
Functions | |
static int | ReadArraywInterpSerial (int, int, int *, int *, int *, int, void *, void *, double *, double *, char *, int *) |
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.
Definition in file ReadArraywInterp.c.
|
static |
Read an array in a serial fashion: 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.
For multi-processor simulation, only rank 0 reads in the entire solution from the file, interpolates it to desired resolution, and then distributes the relevant portions to each of the processors. This involves memory allocation for the global domain on rank 0 as well as interpolation between two global arrays. Thus, do not use for large domains. T his approach is not very scalable either, if running with a very large number of processors (> 1000). Supports both binary and ASCII formats.
The name of the file being read is <fname_root>.inp
ASCII format:-
The input file should contain the ASCII data as follows:
x0_i (0 <= i < dim_global[0])
x1_i (0 <= i < dim_global[1])
...
x{ndims-1}_i (0 <= i < dim_global[ndims-1])
u0_p (0 <= p < N)
u1_p (0 <= p < N)
...
u{nvars-1}_p (0 <= p < N)
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,
N = dim_global[0]*dim_global[1]*...*dim_global[ndims-1] is the total number of points,
and p = i0 + dim_global[0]*( i1 + dim_global[1]*( i2 + dim_global[2]*( ... + dim_global[ndims-2]*i{ndims-1} ))) (see _ArrayIndexnD_)
with i0, i1, i2, etc representing grid indices along each spatial dimension, i.e.,
0 <= i0 < dim_global[0]-1
0 <= i1 < dim_global[1]-1
...
0 <= i{ndims-1} < dim_global[ndims=1]-1
Binary format:-
The input file should contain the binary data in as follows:
x0_i (0 <= i < dim_global[0])
x1_i (0 <= i < dim_global[1])
...
x{ndims-1}_i (0 <= i < dim_global[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_global[0]*dim_global[1]*...*dim_global[ndims-1] is the total number of points,
and p = i0 + dim_global[0]*( i1 + dim_global[1]*( i2 + dim_global[2]*( ... + dim_global[ndims-2]*i{ndims-1} ))) (see _ArrayIndexnD_)
with i0, i1, i2, etc representing grid indices along each spatial dimension, i.e.,
0 <= i0 < dim_global[0]-1
0 <= i1 < dim_global[1]-1
...
0 <= i{ndims-1} < dim_global[ndims=1]-1
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 being read |
fname_root | Filename root |
read_flag | Flag to indicate if the file was read |
Definition at line 159 of file ReadArraywInterp.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.