[cig-commits] r7734 - in long/3D/Gale/trunk: .
src/Underworld/plugins/Output/VTKOutput
walter at geodynamics.org
walter at geodynamics.org
Fri Jul 20 23:08:19 PDT 2007
Author: walter
Date: 2007-07-20 23:08:19 -0700 (Fri, 20 Jul 2007)
New Revision: 7734
Modified:
long/3D/Gale/trunk/
long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c
Log:
r1889 at earth: boo | 2007-07-20 23:03:39 -0700
Make particles use xml vtk format
Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
- 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1888
+ 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1889
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-21 06:08:14 UTC (rev 7733)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c 2007-07-21 06:08:19 UTC (rev 7734)
@@ -118,7 +118,7 @@
int stepping, char *outputPath,
int timeStep, int dim, int myRank) {
double *coord;
- int iteration;
+ int iteration, i;
Particle_Index num_particles = picswarm->particleLocalCount;
Particle_Index lParticle_I;
@@ -134,14 +134,19 @@
FILE *fp;
Name filename;
- Stg_asprintf( &filename, "%s/particles.%d.%05d.vtk", outputPath,
+ Stg_asprintf( &filename, "%s/particles.%d.%05d.vtu", outputPath,
myRank, timeStep);
fp=fopen(filename,"w");
/* Write a header */
- fprintf(fp,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS %d float\n",
+ fprintf(fp,"<?xml version=\"1.0\"?>\n");
+ fprintf(fp,"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n");
+ fprintf(fp," <UnstructuredGrid>\n");
+ fprintf(fp," <Piece NumberOfPoints=\"%d\" NumberOfCells=\"1\">\n",
(num_particles-1)/stepping+1);
+ fprintf(fp," <Points>\n");
+ fprintf(fp," <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n");
/* We need many iterations, because the values are written
separately from the coordinates. */
@@ -149,7 +154,7 @@
{
/* Loop over all of the particles */
for ( lParticle_I = 0 ; lParticle_I < num_particles ;
- ++lParticle_I ){
+ lParticle_I+=stepping ){
double yielding, viscosity, density, alpha, diffusivity;
SymmetricTensor stress;
BuoyancyForceTerm_MaterialExt* materialExt;
@@ -264,26 +269,51 @@
switch(iteration)
{
case 0:
- fprintf(fp,"\nPOINT_DATA %d\nSCALARS Viscosity float 1\nLOOKUP_TABLE default\n",
- (num_particles-1)/stepping+1);
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," </Points>\n");
+ fprintf(fp," <PointData Scalars=\"Viscosity\" Tensors=\"Stress\">\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Viscosity\" format=\"ascii\">\n");
break;
case 1:
- fprintf(fp,"\nSCALARS Yielding_fraction float 1\nLOOKUP_TABLE default\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Yielding_fraction\" format=\"ascii\">\n");
break;
case 2:
- fprintf(fp,"\nTENSORS Stress float\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Stress\" format=\"ascii\" NumberOfComponents=\"9\">\n");
break;
case 3:
- fprintf(fp,"\nSCALARS Density float 1\nLOOKUP_TABLE default\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Density\" format=\"ascii\">\n");
break;
case 4:
- fprintf(fp,"\nSCALARS Alpha float 1\nLOOKUP_TABLE default\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Alpha\" format=\"ascii\">\n");
break;
case 5:
- fprintf(fp,"\nSCALARS Thermal_Diffusivity float 1\nLOOKUP_TABLE default\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Float32\" Name=\"Thermal_Diffusivity\" format=\"ascii\">\n");
break;
case 6:
- fprintf(fp,"\n");
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," </PointData>\n");
+ fprintf(fp," <CellData>\n");
+ fprintf(fp," </CellData>\n");
+ fprintf(fp," <Cells>\n");
+ fprintf(fp," <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n");
+ for(i=0;i<(num_particles-1)/stepping+1;++i)
+ fprintf(fp,"%d ",i);
+ fprintf(fp,"\n </DataArray>\n");
+ fprintf(fp," <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
+ fprintf(fp," %d\n",(num_particles-1)/stepping+1);
+ fprintf(fp," </DataArray>\n");
+ fprintf(fp," <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
+ fprintf(fp," 2\n");
+ fprintf(fp," </DataArray>\n");
+ fprintf(fp," </Cells>\n");
+ fprintf(fp," </Piece>\n");
+ fprintf(fp," </UnstructuredGrid>\n");
+ fprintf(fp,"</VTKFile>\n");
}
}
fclose(fp);
More information about the cig-commits
mailing list