PLUTO  4.0
 All Data Structures Files Functions Variables Enumerations Macros Pages
Functions
write_vtk.c File Reference

Write VTK data. More...

#include "pluto.h"

Functions

void WriteVTK_Header (FILE *fvtk, Grid *grid)
 
void WriteVTK_Vector (FILE *fvtk, Data_Arr V, char *var_name, Grid *grid)
 
void WriteVTK_Scalar (FILE *fvtk, double ***V, char *var_name, Grid *grid)
 

Detailed Description

Collection of basic functions to write VTK files using the simple legacy format. Files can be written in serial or parallel mode and consists of the basic five parts :

  1. File version and identifier
  2. Header consisting of a string
  3. File format
  4. Dataset structure: describes the gometry and topology of the dataset.
  5. Dataset attributes. This section is used to write the actual binary data as a vector or scalar data.

The mesh topology and the variable datasets are written using single precision (4 bytes) binary format. VTK file are usually written following big endian order. Therefore, we swap endianity only if local architecture has little endian ordering.

The WriteVTK_Header() function provides the basic functionality for steps 1, 2, 3 and 4. Only processor 0 does the actual writing. For cartesian/cylindrical geometries the grid topology is "RECTILINEAR_GRIDS" whereas for polar/spherical we employ "STRUCTURED_GRID" to provide a convenient mapping to a cartesian mesh.
Note for 2D datasets: in order to produce a strictly 2D dataset we always set the third coordinate (x3) to zero. For this reason, in 2D pherical cordinates we swap the role of the "y" and "z" coordinates.

The WriteVTK_Vector() is fully parallel and is used to write data with the vector attribute (by default these include velocity and magnetic fields).

The WriteVTK_Scalar() is fully parallel and is used to write data with the scalar attribute (by default these include density, pressure, tracer and user-defined variables).

Reference

http://www.vtk.org/VTK/img/file-formats.pdf

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 18, 2012

Function Documentation

void WriteVTK_Header ( FILE *  fvtk,
Grid grid 
)

Write VTK header in parallel or serial mode. In parallel mode only processor 0 does the actual writing (see al_io.c/AL_Write_header).

Parameters
[in]fvtkpointer to file
[in]gridpointer to an array of Grid structures
Todo:
Write the grid using several processors.
void WriteVTK_Scalar ( FILE *  fvtk,
double ***  V,
char *  var_name,
Grid grid 
)

Write VTK scalar field.

Parameters
[in]fvtkpointer to file
[in]Vpointer to 3D data array
[in]var_namethe variable name appearing in the VTK file
[in]gridpointer to an array of Grid structures
void WriteVTK_Vector ( FILE *  fvtk,
Data_Arr  V,
char *  var_name,
Grid grid 
)

Write VTK vector field data. For generality purposes, vectors are written always with 3 components, even when there're only 2 being used.

The following Maple script has been used to find vector components from cyl/sph to cartesian:

restart;
with(linalg);
Acyl := matrix (3,3,[ cos(phi), sin(phi), 0,
-sin(phi), cos(phi), 0,
0 , 0 , 1]);
Asph := matrix (3,3,[ sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta),
cos(theta)*cos(phi), cos(theta)*sin(phi), -sin(theta),
-sin(phi) , cos(phi) , 0]);
Bcyl := simplify(inverse(Acyl));
Bsph := simplify(inverse(Asph));
Parameters
[in]fvtkpointer to file
[in]Va 4D array [nv][k][j][i] containing the vector components (nv) defined at cell centers (k,j,i). The index nv = 0 marks the vector first component.
[in]var_namethe variable name appearing in the VTK file
[in]gridpointer to an array of Grid structures