[cig-commits] r6562 - in long/3D/Gale/trunk: . src/Underworld/plugins/Output/DumpSwarm src/Underworld/plugins/Output/VTKOutput

walter at geodynamics.org walter at geodynamics.org
Fri Apr 13 01:42:08 PDT 2007


Author: walter
Date: 2007-04-13 01:42:07 -0700 (Fri, 13 Apr 2007)
New Revision: 6562

Modified:
   long/3D/Gale/trunk/
   long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c
   long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c
Log:
 r1794 at earth:  boo | 2007-04-13 01:40:30 -0700
 Make VTKOutput and DumpSwarm just use file IO and not StGermain streams, because streams were not working for a user.  This also fixes some numbering problems in fields and pressure vtk output



Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
   - 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1792
   + 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1794

Modified: long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c	2007-04-13 04:56:16 UTC (rev 6561)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/DumpSwarm/DumpSwarm.c	2007-04-13 08:42:07 UTC (rev 6562)
@@ -108,7 +108,7 @@
         Name filename;
         int myRank;
         MPI_Comm comm;
-        Stream*           stream;
+        FILE*           fp;
 
         Rheology_Index      rheology_I; 
         Rheology_Index      rheologyCount;
@@ -134,11 +134,10 @@
                                                         MT_VERTEX));
 	MPI_Comm_rank( comm, (int*)&myRank );
 
-        stream = Journal_Register( MPIStream_Type, Swarm_Type );
         Stg_asprintf( &filename, "%s/particles.%d.%05d.%s",
                       context->outputPath, myRank,
                       context->timeStep, format );
-        Stream_RedirectFile( stream, filename );
+        fp=fopen(filename,"w");
         
         /* Loop over all of the particles */
         for ( lParticle_I = 0 ; lParticle_I < num_particles ;
@@ -185,21 +184,21 @@
 
           /* Print out a hash of the rheology names. */
           
-          Journal_Printf(stream,"%d%s ",rheology_hash,separator);
+          fprintf(fp,"%d%s ",rheology_hash,separator);
               
           /* First print out only the coordinates. */
           if (context->dim == 2) {
-            Journal_Printf(stream,"%lf%s %lf%s 0.0%s ",(double)coord[0],
-                           separator,(double)coord[1],separator,separator);
+            fprintf(fp,"%lf%s %lf%s 0.0%s ",(double)coord[0],
+                    separator,(double)coord[1],separator,separator);
           } else {
-            Journal_Printf(stream,"%lf%s %lf%s %lf%s ",
+            fprintf(fp,"%lf%s %lf%s %lf%s ",
                            (double)coord[0],separator,
                            (double)coord[1],separator,
                            (double)coord[2],separator);
           }
           /* Then print out the data */
-          Journal_Printf(stream,"%lf%s %lf\n",yielding,separator,viscosity);
+          fprintf(fp,"%lf%s %lf\n",yielding,separator,viscosity);
         }
-        Stream_CloseFile( stream );
+        fclose(fp);
         Memory_Free( filename );
 }

Modified: long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c
===================================================================
--- long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c	2007-04-13 04:56:16 UTC (rev 6561)
+++ long/3D/Gale/trunk/src/Underworld/plugins/Output/VTKOutput/VTKOutput.c	2007-04-13 08:42:07 UTC (rev 6562)
@@ -121,21 +121,21 @@
 	MaterialPoint*          materialparticle;
 
         Rheology_Register*      rheology_register;
-
-        Name filename;
-        Stream*           stream;
-
         Rheology_Index      rheology_I; 
         Rheology_Index      rheologyCount;
         YieldRheology*      rheology; 
 
-        stream = Journal_Register( MPIStream_Type, Swarm_Type );
+        FILE *fp;
+        Name filename;
+
         Stg_asprintf( &filename, "%s/particles.%d.%05d.vtk", outputPath,
                       myRank, timeStep);
-        Stream_RedirectFile( stream, filename );
+
+        fp=fopen(filename,"w");
         
         /* Write a header */
-        Journal_Printf(stream,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS %d float\n",(num_particles-1)/stepping+1);
+        fprintf(fp,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS %d float\n",
+                (num_particles-1)/stepping+1);
 
         /* We need three iterations, because the values are written
            separately from the coordinates. */
@@ -163,11 +163,11 @@
               if(iteration==0)
                 {
                   if (dim == 2) {
-                    Journal_Printf(stream,"%lf %lf 0.0 ",(double)coord[0],
-                                   (double)coord[1]);
+                    fprintf(fp,"%lf %lf 0.0 ",(double)coord[0],
+                            (double)coord[1]);
                   } else {
-                    Journal_Printf(stream,"%lf %lf %lf ", (double)coord[0],
-                                   (double)coord[1], (double)coord[2]);
+                    fprintf(fp,"%lf %lf %lf ", (double)coord[0],
+                            (double)coord[1], (double)coord[2]);
                   }
                 }
               else
@@ -194,42 +194,42 @@
                       }
                   }
                   if(iteration==1)
-                    Journal_Printf(stream,"%lf ",viscosity);
+                    fprintf(fp,"%lf ",viscosity);
                   if(iteration==2)
-                    Journal_Printf(stream,"%lf ",yielding);
+                    fprintf(fp,"%lf ",yielding);
                 }
             }
             switch(iteration)
               {
               case 0:
-                Journal_Printf(stream,"\nPOINT_DATA %d\nSCALARS Viscosity float 1\nLOOKUP_TABLE default\n",
+                fprintf(fp,"\nPOINT_DATA %d\nSCALARS Viscosity float 1\nLOOKUP_TABLE default\n",
                                (num_particles-1)/stepping+1);
                 break;
               case 1:
-                Journal_Printf(stream,"\nSCALARS Yielding_fraction float 1\nLOOKUP_TABLE default\n");
+                fprintf(fp,"\nSCALARS Yielding_fraction float 1\nLOOKUP_TABLE default\n");
                 break;
               case 2:
-                Journal_Printf(stream,"\n");
+                fprintf(fp,"\n");
               }
           }
-        Stream_CloseFile( stream );
+        fclose(fp);
         Memory_Free( filename );
 }
 
 /* Print out the coordinates of the mesh. */
 
-void VTKOutput_print_coords(Stream *stream, FeMesh *feMesh, int nDims, int n) {
+void VTKOutput_print_coords(FILE *fp, FeMesh *feMesh, int nDims, int n) {
   Node_LocalIndex    lNode_I;
   for ( lNode_I = 0; lNode_I < FeMesh_GetNodeLocalSize(feMesh);
         lNode_I++ ) {
     double *coord = Mesh_GetVertex(feMesh, lNode_I);
     if(nDims==2)
-      Journal_Printf( stream, "%.15g %.15g 0\n", coord[0], coord[1]);
+      fprintf(fp, "%.15g %.15g 0\n", coord[0], coord[1]);
     else
-      Journal_Printf( stream, "%.15g %.15g %.15g\n", coord[0],
+      fprintf(fp, "%.15g %.15g %.15g\n", coord[0],
                       coord[1], coord[2]);
   }
-  Journal_Printf(stream,"POINT_DATA %d\n",n);
+  fprintf(fp,"POINT_DATA %d\n",n);
 }
 
 
@@ -244,22 +244,18 @@
   int nDims, pn;
 
   Name field_filename, pressure_filename;
-  Stream* field_stream;
-  Stream* pressure_stream;
-  Stream* stream;
+  FILE *fp, *field_fp, *pressure_fp;
 
   /* Open the file */
 
-  field_stream = Journal_Register( MPIStream_Type, "fields" );
-  pressure_stream = Journal_Register( MPIStream_Type, "pressure" );
   Stg_asprintf( &pressure_filename, "%s/pressure.%d.%05d.vtk",
                 self->outputPath,myRank,
                 self->timeStep);
   Stg_asprintf( &field_filename, "%s/fields.%d.%05d.vtk", self->outputPath,
                 myRank, self->timeStep);
 
-  Stream_RedirectFile( field_stream, field_filename );
-  Stream_RedirectFile( pressure_stream, pressure_filename );
+  field_fp=fopen(field_filename,"w");
+  pressure_fp=fopen(pressure_filename,"w");
 
   /* First, output the coordinates.  We have to do a huge song and
      dance just to get the extents of the mesh. */
@@ -278,45 +274,52 @@
       if(!header_printed)
         {
           int nx, ny, nz, n, pnx, pny, pnz;
+          Mesh *mesh;
           Grid *grid;
-          Mesh *mesh;
+          CartesianGenerator *gen;
 
           mesh=(Mesh*)(feVar->feMesh);
-          grid=*(Grid**)ExtensionManager_Get
-            ( mesh->info, mesh, 
-              ExtensionManager_GetHandle( mesh->info, "vertexGrid" ) );
+          gen=((CartesianGenerator *)(mesh->generator));
+          grid=gen->vertGrid;
+          nDims=gen->nDims;
 
-          nx=grid->sizes[0];
-          ny=grid->sizes[1];
-          if(grid->nDims==3)
-            nz=grid->sizes[2];
+          nx=pnx=gen->range[0];
+          if(gen->origin[0]==0)
+            ++nx;
+
+          ny=pny=gen->range[1];
+          if(gen->origin[1]==0)
+            ++ny;
+
+          if(nDims==3)
+            {
+              nz=pnz=gen->range[2];
+              if(gen->origin[2]==0)
+                ++nz;
+            }
           else
-            nz=1;
-          n=grid->nPoints;
+            nz=pnz=1;
+          n=nx*ny*nz;
 
-          pnx=(nx==1 ? 1 : nx-1);
-          pny=(ny==1 ? 1 : ny-1);
-          pnz=(nz==1 ? 1 : nz-1);
           pn=pnx*pny*pnz;
           
           /* Now that we have the extents, write the header. */
 
-          Journal_Printf(field_stream,"# vtk DataFile Version 2.0\nGale\nASCII\nDATASET STRUCTURED_GRID\nDIMENSIONS %d %d %d\nPOINTS %d float\n",nx,ny,nz,n);
-          Journal_Printf(pressure_stream,"# 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,"# 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);
           
           /* Write the coordinates */
-          nDims=grid->nDims;
-          VTKOutput_print_coords(field_stream, feVar->feMesh, nDims, n);
+          VTKOutput_print_coords(field_fp, feVar->feMesh, nDims, n);
           header_printed=1;
         }
 
       /* Write the coordinates for the pressure, and set the
-         appropriate stream to output for this variable. */
+         appropriate file pointer to output for this variable. */
       if(!strcmp(feVar->name,"PressureField")){
-        VTKOutput_print_coords(pressure_stream, feVar->feMesh, nDims, pn);
-        stream=pressure_stream;
+        VTKOutput_print_coords(pressure_fp, feVar->feMesh, nDims, pn);
+        fp=pressure_fp;
       } else {
-        stream=field_stream;
+        fp=field_fp;
       }
       
       /* Finally, output the fields.  For now, just output every field */
@@ -327,19 +330,19 @@
         {
           /* Scalars */
         case 1:
-          Journal_Printf(stream,"SCALARS %s float 1\nLOOKUP_TABLE default\n",
+          fprintf(fp,"SCALARS %s float 1\nLOOKUP_TABLE default\n",
                          feVar->name);
           break;
           /* Vectors */
         case 2:
         case 3:
-          Journal_Printf(stream,"VECTORS %s float\n",feVar->name);
+          fprintf(fp,"VECTORS %s float\n",feVar->name);
           break;
           /* Rank 2 Tensors */
         case 4:
         case 6:
         case 9:
-          Journal_Printf(stream,"TENSORS %s float\n",feVar->name);
+          fprintf(fp,"TENSORS %s float\n",feVar->name);
           break;
           /* Unknown */
         default:
@@ -361,20 +364,20 @@
           case 3:
           case 9:
             for ( dof_I = 0; dof_I < dofAtEachNodeCount; dof_I++ ) {
-              Journal_Printf(stream, "%.15g ", variableValues[dof_I] );
+              fprintf(fp, "%.15g ", variableValues[dof_I] );
             }
             break;
           case 2:
-            Journal_Printf(stream, "%.15g %.15g 0", variableValues[0],
+            fprintf(fp, "%.15g %.15g 0", variableValues[0],
                            variableValues[1] );
             break;
           case 4:
-            Journal_Printf(stream, "%.15g %.15g 0 %.15g %.15g 0 0 0 0 ",
+            fprintf(fp, "%.15g %.15g 0 %.15g %.15g 0 0 0 0 ",
                            variableValues[0], variableValues[1],
                            variableValues[2], variableValues[3]);
             break;
           case 6:
-            Journal_Printf(stream, "%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g ",
+            fprintf(fp, "%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g ",
                            variableValues[0], variableValues[1],
                            variableValues[2], variableValues[1],
                            variableValues[3], variableValues[4],
@@ -382,13 +385,13 @@
                            variableValues[5]);
             break;
           }
-        Journal_Printf(stream, "\n" );
+        fprintf(fp, "\n" );
       }
     }
   }
-  Stream_CloseFile( pressure_stream );
+  fclose(pressure_fp);
   Memory_Free( pressure_filename );
-  Stream_CloseFile( field_stream );
+  fclose(field_fp);
   Memory_Free( field_filename );
 }
      



More information about the cig-commits mailing list