|
HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Write a vector field and its grid to a binary file. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <basic.h>#include <arrayfunctions.h>Go to the source code of this file.
Functions | |
| 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.
Definition in file WriteBinary.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.