[cig-commits] r7739 - in long/3D/Gale/trunk: .
src/Underworld/plugins/Output/VTKOutput
walter at geodynamics.org
walter at geodynamics.org
Tue Jul 24 11:20:10 PDT 2007
Author: walter
Date: 2007-07-24 11:20:08 -0700 (Tue, 24 Jul 2007)
New Revision: 7739
Modified:
long/3D/Gale/trunk/
long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c
Log:
r1897 at earth: boo | 2007-07-23 11:35:00 -0700
Make the pressure and field vtk output use the xml format
Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
- 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1896
+ 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1897
Modified: long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c 2007-07-24 18:20:00 UTC (rev 7738)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c 2007-07-24 18:20:08 UTC (rev 7739)
@@ -324,6 +324,9 @@
void VTKOutput_print_coords(FILE *fp, FeMesh *feMesh, int nDims, int n) {
Node_LocalIndex lNode_I;
+
+ fprintf(fp," <Points>\n");
+ fprintf(fp," <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n");
for ( lNode_I = 0; lNode_I < FeMesh_GetNodeLocalSize(feMesh);
lNode_I++ ) {
double *coord = Mesh_GetVertex(feMesh, lNode_I);
@@ -333,7 +336,7 @@
fprintf(fp, "%.15g %.15g %.15g\n", coord[0],
coord[1], coord[2]);
}
- fprintf(fp,"POINT_DATA %d\n",n);
+ fprintf(fp," </DataArray>\n </Points>\n");
}
@@ -352,10 +355,10 @@
/* Open the file */
- Stg_asprintf( &pressure_filename, "%s/pressure.%d.%05d.vtk",
+ Stg_asprintf( &pressure_filename, "%s/pressure.%d.%05d.vts",
self->outputPath,myRank,
self->timeStep);
- Stg_asprintf( &field_filename, "%s/fields.%d.%05d.vtk", self->outputPath,
+ Stg_asprintf( &field_filename, "%s/fields.%d.%05d.vts", self->outputPath,
myRank, self->timeStep);
field_fp=fopen(field_filename,"w");
@@ -412,11 +415,21 @@
/* Now that we have the extents, write the header. */
- fprintf(field_fp,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET STRUCTURED_GRID\nDIMENSIONS %d %d %d\nPOINTS %d float\n",nx,ny,nz,n);
- fprintf(pressure_fp,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET STRUCTURED_GRID\nDIMENSIONS %d %d %d\nPOINTS %d float\n",pnx,pny,pnz,pn);
+ fprintf(field_fp,"<?xml version=\"1.0\"?>\n\
+<VTKFile type=\"StructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n\
+ <StructuredGrid WholeExtent=\"0 %d 0 %d 0 %d\">\n\
+ <Piece Extent=\"0 %d 0 %d 0 %d\">\n\
+ <CellData></CellData>\n",nx-1,ny-1,nz-1,nx-1,ny-1,nz-1);
+ fprintf(pressure_fp,"<?xml version=\"1.0\"?>\n\
+<VTKFile type=\"StructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n\
+ <StructuredGrid WholeExtent=\"0 %d 0 %d 0 %d\">\n\
+ <Piece Extent=\"0 %d 0 %d 0 %d\">\n\
+ <CellData></CellData>\n",pnx-1,pny-1,pnz-1,pnx-1,pny-1,pnz-1);
/* Write the coordinates */
VTKOutput_print_coords(field_fp, feVar->feMesh, nDims, n);
+ fprintf(field_fp," <PointData Scalars=\"StrainRateInvariantField\" Vectors=\"VelocityField\" Tensors=\"Stress\">\n");
+
header_printed=1;
}
@@ -424,6 +437,7 @@
appropriate file pointer to output for this variable. */
if(!strcmp(feVar->name,"PressureField")){
VTKOutput_print_coords(pressure_fp, feVar->feMesh, nDims, pn);
+ fprintf(pressure_fp," <PointData Scalars=\"Pressure\">\n");
fp=pressure_fp;
} else {
fp=field_fp;
@@ -433,24 +447,25 @@
dofAtEachNodeCount = feVar->fieldComponentCount;
- switch(dofAtEachNodeCount)
+ switch(dofAtEachNodeCount*nDims)
{
/* Scalars */
- case 1:
- fprintf(fp,"SCALARS %s float 1\nLOOKUP_TABLE default\n",
- feVar->name);
- break;
- /* Vectors */
case 2:
case 3:
- fprintf(fp,"VECTORS %s float\n",feVar->name);
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"%s\" format=\"ascii\">\n",feVar->name);
break;
- /* Rank 2 Tensors */
+ /* Vectors */
case 4:
- case 6:
case 9:
- fprintf(fp,"TENSORS %s float\n",feVar->name);
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"%s\" format=\"ascii\" NumberOfComponents=\"3\">\n",feVar->name);
break;
+ /* Rank 2 Tensors */
+ case 6:
+ case 8:
+ case 18:
+ case 27:
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"%s\" format=\"ascii\" NumberOfComponents=\"9\">\n",feVar->name);
+ break;
/* Unknown */
default:
printf("Bad number of degrees of freedom for variable %s: %d\n",
@@ -462,40 +477,55 @@
double variableValues[MAX_FIELD_COMPONENTS];
Dof_Index dof_I;
FeVariable_GetValueAtNode( feVar, lNode_I, variableValues );
- switch(dofAtEachNodeCount)
+ switch(dofAtEachNodeCount*nDims)
{
/* If writing scalars or 3D objects, then just write the
values. Otherwise, we have to fill in the 3D
components with zeros. */
- case 1:
+ case 2:
case 3:
case 9:
+ case 27:
for ( dof_I = 0; dof_I < dofAtEachNodeCount; dof_I++ ) {
fprintf(fp, "%.15g ", variableValues[dof_I] );
}
break;
- case 2:
+ case 4:
fprintf(fp, "%.15g %.15g 0", variableValues[0],
variableValues[1] );
break;
- case 4:
+ case 6:
+ /* Ordering is xx, yy, xy */
fprintf(fp, "%.15g %.15g 0 %.15g %.15g 0 0 0 0 ",
+ variableValues[0], variableValues[2],
+ variableValues[2], variableValues[1]);
+ break;
+ case 8:
+ fprintf(fp, "%.15g %.15g 0 %.15g %.15g 0 0 0 0 ",
variableValues[0], variableValues[1],
variableValues[2], variableValues[3]);
break;
- case 6:
+ case 18:
+ /* Ordering is xx, yy, zz, xy, xz, yz */
fprintf(fp, "%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g ",
- variableValues[0], variableValues[1],
- variableValues[2], variableValues[1],
- variableValues[3], variableValues[4],
- variableValues[2], variableValues[4],
- variableValues[5]);
+ variableValues[0], variableValues[3],
+ variableValues[4], variableValues[3],
+ variableValues[1], variableValues[5],
+ variableValues[4], variableValues[5],
+ variableValues[2]);
break;
}
fprintf(fp, "\n" );
}
+ fprintf(fp," </DataArray>\n");
}
}
+ fprintf(pressure_fp," </PointData>\n </Piece>\n\
+ </StructuredGrid>\n\
+</VTKFile>\n");
+ fprintf(field_fp," </PointData>\n </Piece>\n\
+ </StructuredGrid>\n\
+</VTKFile>\n");
fclose(pressure_fp);
Memory_Free( pressure_filename );
fclose(field_fp);
More information about the cig-commits
mailing list