53 #define RECTILINEAR_GRID 14
54 #define STRUCTURED_GRID 35
57 #if GEOMETRY == CARTESIAN || GEOMETRY == CYLINDRICAL
58 #define VTK_FORMAT RECTILINEAR_GRID
60 #define VTK_FORMAT STRUCTURED_GRID
65 #define VTK_TIME_INFO NO
75 #define VTK_HEADER_WRITE_STRING(header) \
76 AL_Write_header (header, strlen(header), MPI_CHAR, SZ_Float_Vect);
77 #define VTK_HEADER_WRITE_FLTARR(arr, nelem) \
78 AL_Write_header (arr, nelem, MPI_FLOAT, SZ_Float_Vect);
79 #define VTK_HEADER_WRITE_DBLARR(arr, nelem) \
80 AL_Write_header (arr, nelem, MPI_DOUBLE, SZ_Float_Vect);
82 #define VTK_HEADER_WRITE_STRING(header) \
83 fprintf (fvtk,header);
84 #define VTK_HEADER_WRITE_FLTARR(arr,nelem) \
85 fwrite(arr, sizeof(float), nelem, fvtk);
86 #define VTK_HEADER_WRITE_DBLARR(arr,nelem) \
87 fwrite(arr, sizeof(double), nelem, fvtk);
108 static float ***node_coord, *xnode, *ynode, *znode;
122 if (node_coord == NULL){
123 node_coord =
ARRAY_3D(nx2 + JOFFSET, nx1 + IOFFSET, 3,
float);
125 #if VTK_FORMAT == RECTILINEAR_GRID
126 xnode =
ARRAY_1D(nx1 + IOFFSET,
float);
127 ynode =
ARRAY_1D(nx2 + JOFFSET,
float);
128 znode =
ARRAY_1D(nx3 + KOFFSET,
float);
130 for (i = 0; i < nx1 + IOFFSET; i++){
131 x1 = (float)(grid[
IDIR].xl_glob[i+
IBEG]);
135 for (j = 0; j < nx2 + JOFFSET; j++){
136 x2 = (float)(grid[
JDIR].xl_glob[j+
JBEG]);
140 for (k = 0; k < nx3 + KOFFSET; k++){
141 x3 = (float)(grid[
KDIR].xl_glob[k+
KBEG]);
157 sprintf(header,
"# vtk DataFile Version 2.0\n");
158 sprintf(header+strlen(header),
"PLUTO %s VTK Data\n",
PLUTO_VERSION);
159 sprintf(header+strlen(header),
"BINARY\n");
160 #if VTK_FORMAT == RECTILINEAR_GRID
161 sprintf(header+strlen(header),
"DATASET %s\n",
"RECTILINEAR_GRID");
162 #elif VTK_FORMAT == STRUCTURED_GRID
163 sprintf(header+strlen(header),
"DATASET %s\n",
"STRUCTURED_GRID");
170 #if VTK_TIME_INFO == YES
171 sprintf (header,
"FIELD FieldData 1\n");
172 sprintf (header+strlen(header),
"TIME 1 1 double\n");
181 sprintf(header,
"DIMENSIONS %d %d %d\n",
182 nx1 + IOFFSET, nx2 + JOFFSET, nx3 + KOFFSET);
185 #if VTK_FORMAT == RECTILINEAR_GRID
189 sprintf(header,
"X_COORDINATES %d float\n", nx1 + IOFFSET);
193 sprintf(header,
"\nY_COORDINATES %d float\n", nx2 + JOFFSET);
197 sprintf(header,
"\nZ_COORDINATES %d float\n", nx3 + KOFFSET);
201 sprintf (header,
"\nCELL_DATA %d\n", nx1*nx2*nx3);
204 #elif VTK_FORMAT == STRUCTURED_GRID
206 sprintf(header,
"POINTS %d float\n", (nx1+IOFFSET)*(nx2+JOFFSET)*(nx3+KOFFSET));
214 for (k = 0; k < nx3 + KOFFSET; k++){
215 for (j = 0; j < nx2 + JOFFSET; j++){
216 for (i = 0; i < nx1 + IOFFSET; i++){
222 node_coord[j][i][0] = x1;
223 node_coord[
j][
i][1] = x2;
224 node_coord[
j][
i][2] = x3;
225 #elif GEOMETRY == POLAR
226 node_coord[
j][
i][0] = x1*cos(x2);
227 node_coord[
j][
i][1] = x1*sin(x2);
228 node_coord[
j][
i][2] = x3;
229 #elif GEOMETRY == SPHERICAL
231 node_coord[
j][
i][0] = x1*sin(x2);
232 node_coord[
j][
i][1] = x1*cos(x2);
233 node_coord[
j][
i][2] = 0.0;
234 #elif DIMENSIONS == 3
235 node_coord[
j][
i][0] = x1*sin(x2)*cos(x3);
236 node_coord[
j][
i][1] = x1*sin(x2)*sin(x3);
237 node_coord[
j][
i][2] = x1*cos(x2);
250 sprintf (header,
"\nCELL_DATA %d\n", nx1*nx2*nx3);
255 #undef STRUCTERED_GRID
256 #undef RECTILINEAR_GRID
260 char *var_name,
Grid *grid)
293 int vel_field, mag_field;
296 double v[3], x1, x2, x3;
306 v[0] = v[1] = v[2] = 0.0;
309 vel_field = (strcmp(var_name,
"vx1") == 0);
310 mag_field = (strcmp(var_name,
"bx1") == 0);
311 if (vel_field || mag_field) {
314 v[1] = V[1][
k][
j][
i]; x2 = grid[
JDIR].
x[
j]; ,
315 v[2] = V[2][
k][
j][
i]; x3 = grid[
KDIR].
x[
k];)
318 vect3D[
k][
j][
i].
v1 = (float)v[0]*unit;
319 vect3D[
k][
j][
i].
v2 = (float)v[1]*unit;
320 vect3D[
k][
j][
i].
v3 = (float)v[2]*unit;
331 sprintf (header,
"\nVECTORS %dD_Velocity_Field float\n",
DIMENSIONS);
333 sprintf (header,
"\nVECTORS %dD_Magnetic_Field float\n",
DIMENSIONS);
342 char *var_name,
Grid *grid)
357 sprintf (header,
"\nSCALARS %s float\n", var_name);
358 sprintf (header,
"%sLOOKUP_TABLE default\n",header);
361 MPI_Barrier (MPI_COMM_WORLD);
364 fprintf (fvtk,
"%s",header);
int AL_Write_header(void *vbuffer, int nelem, AL_Datatype type, int sz_ptr)
#define VTK_HEADER_WRITE_STRING(header)
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
#define VTK_HEADER_WRITE_FLTARR(arr, nelem)
int gend
Global end index for the global array.
#define ARRAY_3D(nx, ny, nz, type)
float *** Convert_dbl2flt(double ***Vdbl, double unit, int swap_endian)
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
#define VTK_HEADER_WRITE_DBLARR(arr, nelem)
int nghost
Number of ghost zones.
double * xl_glob
Cell left interface.
void WriteVTK_Scalar(FILE *fvtk, double ***V, double unit, char *var_name, Grid *grid)
void VectorCartesianComponents(double *v, double x1, double x2, double x3)
#define ARRAY_1D(nx, type)
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
double g_time
The current integration time.
long int KBEG
Lower grid index of the computational domain in the the X3 direction for the local processor...
void WriteVTK_Vector(FILE *fvtk, Data_Arr V, double unit, char *var_name, Grid *grid)
long int JBEG
Lower grid index of the computational domain in the the X2 direction for the local processor...
void WriteBinaryArray(void *V, size_t dsize, int sz, FILE *fl, int istag)
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
void WriteVTK_Header(FILE *fvtk, Grid *grid)