HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Write a vector field and its grid to a text 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 | WriteText (int ndims, int nvars, int *dim, double *x, double *u, char *f, int *index) |
Write a vector field and its grid to a text file.
Definition in file WriteText.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.