/[escript]/trunk/finley/src/Mesh_saveVTK.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_saveVTK.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 818 by dhawcroft, Sun Aug 27 11:10:34 2006 UTC revision 903 by gross, Fri Nov 17 01:59:49 2006 UTC
# Line 452  void Finley_Mesh_saveVTK_MPIO(const char Line 452  void Finley_Mesh_saveVTK_MPIO(const char
452              "<UnstructuredGrid>\n" \              "<UnstructuredGrid>\n" \
453              "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n" \              "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n" \
454              "<Points>\n" \              "<Points>\n" \
455              "<DataArray NumberOfComponents=\"%d\" type=\"Float32\" format=\"ascii\">\n"              "<DataArray NumberOfComponents=\"%d\" type=\"Float64\" format=\"ascii\">\n"
456              ,numPoints,numGlobalCells,MAX(3,nDim));              ,numPoints,numGlobalCells,MAX(3,nDim));
457    
458    
# Line 845  void Finley_Mesh_saveVTK_MPIO(const char Line 845  void Finley_Mesh_saveVTK_MPIO(const char
845          if( myRank == 0)          if( myRank == 0)
846          {          {
847            char header[250];            char header[250];
848            sprintf(header,"<DataArray Name=\"%s\" type=\"Float32\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);            sprintf(header,"<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);
849            MPI_File_iwrite_shared(fh,header,strlen(header),MPI_CHAR,&req);            MPI_File_iwrite_shared(fh,header,strlen(header),MPI_CHAR,&req);
850            MPI_Wait(&req,&status);            MPI_Wait(&req,&status);
851          }          }
# Line 866  void Finley_Mesh_saveVTK_MPIO(const char Line 866  void Finley_Mesh_saveVTK_MPIO(const char
866            // averaging over the number of points in the sample            // averaging over the number of points in the sample
867            for (n=0; n<nComp; n++)            for (n=0; n<nComp; n++)
868            {            {
869              rtmp = 0.;              if (isExpanded(data_pp[i_data])) {
870              for (j=0; j<numPointsPerSample; j++) rtmp += values[INDEX2(n,j,nComp)];                 rtmp = 0.;
871              sampleAvg[k] = rtmp/numPointsPerSample;                 for (j=0; j<numPointsPerSample; j++) rtmp += values[INDEX2(n,j,nComp)];
872                   sampleAvg[n] = rtmp/numPointsPerSample;
873                } else {
874                   sampleAvg[n] = values[n];
875                }
876            }            }
877            // if the number of required components is more than the number            // if the number of required components is more than the number
878            // of actual components, pad with zeros            // of actual components, pad with zeros
# Line 1042  void Finley_Mesh_saveVTK_MPIO(const char Line 1046  void Finley_Mesh_saveVTK_MPIO(const char
1046          if( myRank == 0)          if( myRank == 0)
1047          {          {
1048            char header[250];            char header[250];
1049            sprintf(header, "<DataArray Name=\"%s\" type=\"Float32\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);            sprintf(header, "<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);
1050            MPI_File_iwrite_shared(fh,header,strlen(header),MPI_CHAR,&req);            MPI_File_iwrite_shared(fh,header,strlen(header),MPI_CHAR,&req);
1051            MPI_Wait(&req,&status);            MPI_Wait(&req,&status);
1052          }          }
# Line 1523  void Finley_Mesh_saveVTK(const char * fi Line 1527  void Finley_Mesh_saveVTK(const char * fi
1527    * the reason for this if statement is explained in the long comment below    * the reason for this if statement is explained in the long comment below
1528    */    */
1529    nDim = mesh_p->Nodes->numDim;    nDim = mesh_p->Nodes->numDim;
1530    fprintf(fileHandle_p, "<DataArray NumberOfComponents=\"%d\" type=\"Float32\" format=\"ascii\">\n",MAX(3,nDim));    fprintf(fileHandle_p, "<DataArray NumberOfComponents=\"%d\" type=\"Float64\" format=\"ascii\">\n",MAX(3,nDim));
1531    /* vtk/mayavi doesn't like 2D data, it likes 3D data with a degenerate    /* vtk/mayavi doesn't like 2D data, it likes 3D data with a degenerate
1532    * third dimension to handle 2D data (like a sheet of paper).  So, if    * third dimension to handle 2D data (like a sheet of paper).  So, if
1533    * nDim is 2, we have to append zeros to the array to get this third    * nDim is 2, we have to append zeros to the array to get this third
# Line 1712  void Finley_Mesh_saveVTK(const char * fi Line 1716  void Finley_Mesh_saveVTK(const char * fi
1716            }            }
1717            nCompReqd = 9;            nCompReqd = 9;
1718          }          }
1719          fprintf(fileHandle_p, "<DataArray Name=\"%s\" type=\"Float32\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);          fprintf(fileHandle_p, "<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);
1720    
1721          double sampleAvg[nComp];          double sampleAvg[nComp];
1722          for (i=0; i<numCells; i++)          for (i=0; i<numCells; i++)
# Line 1721  void Finley_Mesh_saveVTK(const char * fi Line 1725  void Finley_Mesh_saveVTK(const char * fi
1725            /* averaging over the number of points in the sample */            /* averaging over the number of points in the sample */
1726            for (k=0; k<nComp; k++)            for (k=0; k<nComp; k++)
1727            {            {
1728              rtmp = 0.;              if (isExpanded(data_pp[i_data])) {
1729              for (j=0; j<numPointsPerSample; j++) rtmp += values[INDEX2(k,j,nComp)];                 rtmp = 0.;
1730              sampleAvg[k] = rtmp/numPointsPerSample;                 for (j=0; j<numPointsPerSample; j++) rtmp += values[INDEX2(k,j,nComp)];
1731                   sampleAvg[k] = rtmp/numPointsPerSample;
1732                } else {
1733                   sampleAvg[k] = values[k];
1734                }
1735    
1736            }            }
1737            /* if the number of required components is more than the number            /* if the number of required components is more than the number
1738            * of actual components, pad with zeros            * of actual components, pad with zeros
# Line 1846  void Finley_Mesh_saveVTK(const char * fi Line 1855  void Finley_Mesh_saveVTK(const char * fi
1855            }            }
1856            nCompReqd = 9;            nCompReqd = 9;
1857          }          }
1858          fprintf(fileHandle_p, "<DataArray Name=\"%s\" type=\"Float32\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);          fprintf(fileHandle_p, "<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n",names_p[i_data], nCompReqd);
1859          /* write out the data */          /* write out the data */
1860          /* if the number of required components is more than the number          /* if the number of required components is more than the number
1861          * of actual components, pad with zeros          * of actual components, pad with zeros

Legend:
Removed from v.818  
changed lines
  Added in v.903

  ViewVC Help
Powered by ViewVC 1.1.26