/[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 903 by gross, Fri Nov 17 01:59:49 2006 UTC revision 1062 by gross, Mon Mar 26 06:17:53 2007 UTC
# Line 26  Line 26 
26    
27    
28  #include "Mesh.h"  #include "Mesh.h"
29    #include "Assemble.h"
30  #include "vtkCellType.h"  /* copied from vtk source directory !!! */  #include "vtkCellType.h"  /* copied from vtk source directory !!! */
31    
32  /*  /*
# Line 201  void Finley_Mesh_saveVTK_MPIO(const char Line 202  void Finley_Mesh_saveVTK_MPIO(const char
202          isCellCentered[i_data]=FALSE;          isCellCentered[i_data]=FALSE;
203          break;          break;
204        case FINLEY_ELEMENTS:        case FINLEY_ELEMENTS:
205          case FINLEY_REDUCED_ELEMENTS:
206          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
207          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS)
208          {          {
# Line 214  void Finley_Mesh_saveVTK_MPIO(const char Line 216  void Finley_Mesh_saveVTK_MPIO(const char
216          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
217          break;          break;
218        case FINLEY_FACE_ELEMENTS:        case FINLEY_FACE_ELEMENTS:
219          case FINLEY_REDUCED_FACE_ELEMENTS:
220          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
221          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_FACE_ELEMENTS)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_FACE_ELEMENTS)
222          {          {
# Line 242  void Finley_Mesh_saveVTK_MPIO(const char Line 245  void Finley_Mesh_saveVTK_MPIO(const char
245          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
246          break;          break;
247        case FINLEY_CONTACT_ELEMENTS_1:        case FINLEY_CONTACT_ELEMENTS_1:
248          case FINLEY_REDUCED_CONTACT_ELEMENTS_1:
249          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
250          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)
251          {          {
# Line 256  void Finley_Mesh_saveVTK_MPIO(const char Line 260  void Finley_Mesh_saveVTK_MPIO(const char
260          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
261          break;          break;
262        case FINLEY_CONTACT_ELEMENTS_2:        case FINLEY_CONTACT_ELEMENTS_2:
263          case FINLEY_REDUCED_CONTACT_ELEMENTS_2:
264          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
265          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)
266          {          {
# Line 332  void Finley_Mesh_saveVTK_MPIO(const char Line 337  void Finley_Mesh_saveVTK_MPIO(const char
337    numInternalCells = elements->elementDistribution->numInternal;    numInternalCells = elements->elementDistribution->numInternal;
338    numBoundaryCells = elements->elementDistribution->numBoundary;    numBoundaryCells = elements->elementDistribution->numBoundary;
339    
340    if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM)    if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM || nodetype==FINLEY_REDUCED_NODES)
341    {    {
342      TypeId = elements->LinearReferenceElement->Type->TypeId;      TypeId = elements->LinearReferenceElement->Type->TypeId;
343    }    }
# Line 1013  void Finley_Mesh_saveVTK_MPIO(const char Line 1018  void Finley_Mesh_saveVTK_MPIO(const char
1018      {      {
1019        if (! isEmpty(data_pp[i_data]) && !isCellCentered[i_data])        if (! isEmpty(data_pp[i_data]) && !isCellCentered[i_data])
1020        {        {
1021          numPointsPerSample = elements->ReferenceElement->numQuadNodes;          if (Finley_Assemble_reducedIntegrationOrder(data_pp[i_data])) {
1022               numPointsPerSample=elements->ReferenceElementReducedOrder->numQuadNodes;
1023            } else {
1024               numPointsPerSample=elements->ReferenceElement->numQuadNodes;
1025            }
1026          rank = getDataPointRank(data_pp[i_data]);          rank = getDataPointRank(data_pp[i_data]);
1027          nComp = getDataPointSize(data_pp[i_data]);          nComp = getDataPointSize(data_pp[i_data]);
1028          nCompReqd=1;   // the number of components required by vtk          nCompReqd=1;   // the number of components required by vtk
# Line 1203  void Finley_Mesh_saveVTK_MPIO(const char Line 1212  void Finley_Mesh_saveVTK_MPIO(const char
1212    
1213  void Finley_Mesh_saveVTK(const char * filename_p, Finley_Mesh *mesh_p, const dim_t num_data,char* *names_p, escriptDataC* *data_pp)  void Finley_Mesh_saveVTK(const char * filename_p, Finley_Mesh *mesh_p, const dim_t num_data,char* *names_p, escriptDataC* *data_pp)
1214  {  {
1215      #define NCOMP_MAX 9
1216    char error_msg[LenErrorMsg_MAX];    char error_msg[LenErrorMsg_MAX];
1217      double sampleAvg[NCOMP_MAX];
1218    /* if there is no mesh we just return */    /* if there is no mesh we just return */
   if (mesh_p==NULL) return;  
1219    
1220    int i, j, k, numVTKNodesPerElement,i_data,m, count, n, rank,shape, numPoints, cellType, numCells,    int i, j, k, numVTKNodesPerElement,i_data,m, count, n, rank,shape, numPoints, cellType, numCells,
1221    nDim, numPointsPerSample, nComp, nCompReqd;    nDim, numPointsPerSample, nComp, nCompReqd, NN;
   
1222    index_t j2;    index_t j2;
1223      int nodetype=FINLEY_DEGREES_OF_FREEDOM;
1224      int elementtype=FINLEY_UNKNOWN;
1225    double* values, rtmp;    double* values, rtmp;
1226    char elemTypeStr[32];    char elemTypeStr[32];
1227      FILE * fileHandle_p = NULL;
1228      bool_t do_write, *isCellCentered=NULL,write_celldata=FALSE,write_pointdata=FALSE;
1229      Finley_ElementFile* elements=NULL;
1230      ElementTypeId TypeId;
1231    
1232    /* open the file and check handle */    /* open the file and check handle */
1233      if (mesh_p==NULL) return;
1234    
1235    FILE * fileHandle_p = fopen(filename_p, "w");    fileHandle_p = fopen(filename_p, "w");
1236    if (fileHandle_p==NULL)    if (fileHandle_p==NULL)
1237    {    {
1238      sprintf(error_msg, "saveVTK: File %s could not be opened for writing.", filename_p);      sprintf(error_msg, "saveVTK: File %s could not be opened for writing.", filename_p);
# Line 1224  void Finley_Mesh_saveVTK(const char * fi Line 1240  void Finley_Mesh_saveVTK(const char * fi
1240      return;      return;
1241    }    }
1242    /* find the mesh type to be written */    /* find the mesh type to be written */
1243    int nodetype=FINLEY_DEGREES_OF_FREEDOM;    isCellCentered=TMPMEMALLOC(num_data,bool_t);
1244    int elementtype=FINLEY_UNKNOWN;  
1245    bool_t isCellCentered[num_data],write_celldata=FALSE,write_pointdata=FALSE;  
1246      if (Finley_checkPtr(isCellCentered)) {
1247         fclose(fileHandle_p);
1248         return;
1249      }
1250    for (i_data=0;i_data<num_data;++i_data)    for (i_data=0;i_data<num_data;++i_data)
1251    {    {
1252      if (! isEmpty(data_pp[i_data]))      if (! isEmpty(data_pp[i_data]))
# Line 1243  void Finley_Mesh_saveVTK(const char * fi Line 1263  void Finley_Mesh_saveVTK(const char * fi
1263          {          {
1264            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1265            fclose(fileHandle_p);            fclose(fileHandle_p);
1266              TMPMEMFREE(isCellCentered);
1267            return;            return;
1268          }          }
1269          isCellCentered[i_data]=FALSE;          isCellCentered[i_data]=FALSE;
# Line 1257  void Finley_Mesh_saveVTK(const char * fi Line 1278  void Finley_Mesh_saveVTK(const char * fi
1278          {          {
1279            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1280            fclose(fileHandle_p);            fclose(fileHandle_p);
1281              TMPMEMFREE(isCellCentered);
1282            return;            return;
1283          }          }
1284          isCellCentered[i_data]=FALSE;          isCellCentered[i_data]=FALSE;
# Line 1271  void Finley_Mesh_saveVTK(const char * fi Line 1293  void Finley_Mesh_saveVTK(const char * fi
1293          {          {
1294            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1295            fclose(fileHandle_p);            fclose(fileHandle_p);
1296              TMPMEMFREE(isCellCentered);
1297            return;            return;
1298          }          }
1299          isCellCentered[i_data]=FALSE;          isCellCentered[i_data]=FALSE;
1300          break;          break;
1301        case FINLEY_ELEMENTS:        case FINLEY_ELEMENTS:
1302          case FINLEY_REDUCED_ELEMENTS:
1303          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
1304          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_ELEMENTS)
1305          {          {
# Line 1286  void Finley_Mesh_saveVTK(const char * fi Line 1310  void Finley_Mesh_saveVTK(const char * fi
1310            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1311            fclose(fileHandle_p);            fclose(fileHandle_p);
1312            return;            return;
1313              TMPMEMFREE(isCellCentered);
1314          }          }
1315          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
1316          break;          break;
1317        case FINLEY_FACE_ELEMENTS:        case FINLEY_FACE_ELEMENTS:
1318          case FINLEY_REDUCED_FACE_ELEMENTS:
1319          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
1320          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_FACE_ELEMENTS)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_FACE_ELEMENTS)
1321          {          {
# Line 1299  void Finley_Mesh_saveVTK(const char * fi Line 1325  void Finley_Mesh_saveVTK(const char * fi
1325          {          {
1326            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1327            fclose(fileHandle_p);            fclose(fileHandle_p);
1328              TMPMEMFREE(isCellCentered);
1329            return;            return;
1330          }          }
1331          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
# Line 1313  void Finley_Mesh_saveVTK(const char * fi Line 1340  void Finley_Mesh_saveVTK(const char * fi
1340          {          {
1341            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1342            fclose(fileHandle_p);            fclose(fileHandle_p);
1343              TMPMEMFREE(isCellCentered);
1344            return;            return;
1345          }          }
1346          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
1347          break;          break;
1348        case FINLEY_CONTACT_ELEMENTS_1:        case FINLEY_CONTACT_ELEMENTS_1:
1349          case FINLEY_REDUCED_CONTACT_ELEMENTS_1:
1350          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
1351          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)
1352          {          {
# Line 1327  void Finley_Mesh_saveVTK(const char * fi Line 1356  void Finley_Mesh_saveVTK(const char * fi
1356          {          {
1357            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1358            fclose(fileHandle_p);            fclose(fileHandle_p);
1359              TMPMEMFREE(isCellCentered);
1360            return;            return;
1361          }          }
1362          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
1363          break;          break;
1364        case FINLEY_CONTACT_ELEMENTS_2:        case FINLEY_CONTACT_ELEMENTS_2:
1365          case FINLEY_REDUCED_CONTACT_ELEMENTS_2:
1366          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;          nodetype = (nodetype == FINLEY_REDUCED_DEGREES_OF_FREEDOM) ? FINLEY_REDUCED_DEGREES_OF_FREEDOM : FINLEY_DEGREES_OF_FREEDOM;
1367          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)          if (elementtype==FINLEY_UNKNOWN || elementtype==FINLEY_CONTACT_ELEMENTS_1)
1368          {          {
# Line 1341  void Finley_Mesh_saveVTK(const char * fi Line 1372  void Finley_Mesh_saveVTK(const char * fi
1372          {          {
1373            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");            Finley_setError(TYPE_ERROR,"saveVTK: cannot write given data in single file.");
1374            fclose(fileHandle_p);            fclose(fileHandle_p);
1375              TMPMEMFREE(isCellCentered);
1376            return;            return;
1377          }          }
1378          isCellCentered[i_data]=TRUE;          isCellCentered[i_data]=TRUE;
# Line 1349  void Finley_Mesh_saveVTK(const char * fi Line 1381  void Finley_Mesh_saveVTK(const char * fi
1381          sprintf(error_msg,"saveVTK: Finley does not know anything about function space type %d",getFunctionSpaceType(data_pp[i_data]));          sprintf(error_msg,"saveVTK: Finley does not know anything about function space type %d",getFunctionSpaceType(data_pp[i_data]));
1382          Finley_setError(TYPE_ERROR,error_msg);          Finley_setError(TYPE_ERROR,error_msg);
1383          fclose(fileHandle_p);          fclose(fileHandle_p);
1384            TMPMEMFREE(isCellCentered);
1385          return;          return;
1386        }        }
1387        if (isCellCentered[i_data])        if (isCellCentered[i_data])
# Line 1372  void Finley_Mesh_saveVTK(const char * fi Line 1405  void Finley_Mesh_saveVTK(const char * fi
1405      numPoints = mesh_p->Nodes->numNodes;      numPoints = mesh_p->Nodes->numNodes;
1406    }    }
1407    if (elementtype==FINLEY_UNKNOWN) elementtype=FINLEY_ELEMENTS;    if (elementtype==FINLEY_UNKNOWN) elementtype=FINLEY_ELEMENTS;
   Finley_ElementFile* elements=NULL;  
1408    switch(elementtype)    switch(elementtype)
1409    {    {
1410    case FINLEY_ELEMENTS:    case FINLEY_ELEMENTS:
# Line 1392  void Finley_Mesh_saveVTK(const char * fi Line 1424  void Finley_Mesh_saveVTK(const char * fi
1424    {    {
1425      Finley_setError(SYSTEM_ERROR,"saveVTK: undefined element file");      Finley_setError(SYSTEM_ERROR,"saveVTK: undefined element file");
1426      fclose(fileHandle_p);      fclose(fileHandle_p);
1427        TMPMEMFREE(isCellCentered);
1428      return;      return;
1429    }    }
1430    /* map finley element type to VTK element type */    /* map finley element type to VTK element type */
1431    numCells = elements->numElements;    numCells = elements->numElements;
   ElementTypeId TypeId;  
1432    if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM)    if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM)
1433    {    {
1434      TypeId = elements->LinearReferenceElement->Type->TypeId;      TypeId = elements->LinearReferenceElement->Type->TypeId;
# Line 1505  void Finley_Mesh_saveVTK(const char * fi Line 1537  void Finley_Mesh_saveVTK(const char * fi
1537      sprintf(error_msg, "saveVTK: Element type %s is not supported by VTK",elements->ReferenceElement->Type->Name);      sprintf(error_msg, "saveVTK: Element type %s is not supported by VTK",elements->ReferenceElement->Type->Name);
1538      Finley_setError(VALUE_ERROR,error_msg);      Finley_setError(VALUE_ERROR,error_msg);
1539      fclose(fileHandle_p);      fclose(fileHandle_p);
1540        TMPMEMFREE(isCellCentered);
1541      return;      return;
1542    }    }
1543    /* xml header */    /* xml header */
# Line 1563  void Finley_Mesh_saveVTK(const char * fi Line 1596  void Finley_Mesh_saveVTK(const char * fi
1596    
1597    /* write out the DataArray element for the connectivity */    /* write out the DataArray element for the connectivity */
1598    
1599    int NN = elements->ReferenceElement->Type->numNodes;    NN = elements->ReferenceElement->Type->numNodes;
1600    fprintf(fileHandle_p, "<Cells>\n");    fprintf(fileHandle_p, "<Cells>\n");
1601    fprintf(fileHandle_p, "<DataArray Name=\"connectivity\" type=\"Int32\" format=\"ascii\">\n");    fprintf(fileHandle_p, "<DataArray Name=\"connectivity\" type=\"Int32\" format=\"ascii\">\n");
1602    
# Line 1675  void Finley_Mesh_saveVTK(const char * fi Line 1708  void Finley_Mesh_saveVTK(const char * fi
1708            sprintf(error_msg, "saveVTK: data %s: Vtk can't handle objects with rank greater than 2.",names_p[i_data]);            sprintf(error_msg, "saveVTK: data %s: Vtk can't handle objects with rank greater than 2.",names_p[i_data]);
1709            Finley_setError(VALUE_ERROR,error_msg);            Finley_setError(VALUE_ERROR,error_msg);
1710            fclose(fileHandle_p);            fclose(fileHandle_p);
1711              TMPMEMFREE(isCellCentered);
1712            return;            return;
1713          }          }
1714        }        }
# Line 1685  void Finley_Mesh_saveVTK(const char * fi Line 1719  void Finley_Mesh_saveVTK(const char * fi
1719      {      {
1720        if (! isEmpty(data_pp[i_data]) && isCellCentered[i_data])        if (! isEmpty(data_pp[i_data]) && isCellCentered[i_data])
1721        {        {
1722          numPointsPerSample = elements->ReferenceElement->numQuadNodes;          if (Finley_Assemble_reducedIntegrationOrder(data_pp[i_data])) {
1723               numPointsPerSample=elements->ReferenceElementReducedOrder->numQuadNodes;
1724            } else {
1725               numPointsPerSample=elements->ReferenceElement->numQuadNodes;
1726            }
1727          rank = getDataPointRank(data_pp[i_data]);          rank = getDataPointRank(data_pp[i_data]);
1728          nComp = getDataPointSize(data_pp[i_data]);          nComp = getDataPointSize(data_pp[i_data]);
1729          nCompReqd=1;   /* the number of components required by vtk */          nCompReqd=1;   /* the number of components required by vtk */
# Line 1701  void Finley_Mesh_saveVTK(const char * fi Line 1739  void Finley_Mesh_saveVTK(const char * fi
1739            {            {
1740              Finley_setError(VALUE_ERROR, "saveVTK: rank 1 object must have less then 4 components");              Finley_setError(VALUE_ERROR, "saveVTK: rank 1 object must have less then 4 components");
1741              fclose(fileHandle_p);              fclose(fileHandle_p);
1742                TMPMEMFREE(isCellCentered);
1743              return;              return;
1744            }            }
1745            nCompReqd = 3;            nCompReqd = 3;
# Line 1712  void Finley_Mesh_saveVTK(const char * fi Line 1751  void Finley_Mesh_saveVTK(const char * fi
1751            {            {
1752              Finley_setError(VALUE_ERROR, "saveVTK: rank 2 object must have less then 4x4 components and must have a square shape");              Finley_setError(VALUE_ERROR, "saveVTK: rank 2 object must have less then 4x4 components and must have a square shape");
1753              fclose(fileHandle_p);              fclose(fileHandle_p);
1754                TMPMEMFREE(isCellCentered);
1755              return;              return;
1756            }            }
1757            nCompReqd = 9;            nCompReqd = 9;
1758          }          }
1759          fprintf(fileHandle_p, "<DataArray Name=\"%s\" type=\"Float64\" 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);
1760    
         double sampleAvg[nComp];  
1761          for (i=0; i<numCells; i++)          for (i=0; i<numCells; i++)
1762          {          {
1763            values = getSampleData(data_pp[i_data], i);            values = getSampleData(data_pp[i_data], i);
1764            /* averaging over the number of points in the sample */            /* averaging over the number of points in the sample */
1765            for (k=0; k<nComp; k++)            for (k=0; k<MIN(nComp,NCOMP_MAX); k++)
1766            {            {
1767              if (isExpanded(data_pp[i_data])) {              if (isExpanded(data_pp[i_data])) {
1768                 rtmp = 0.;                 rtmp = 0.;
# Line 1814  void Finley_Mesh_saveVTK(const char * fi Line 1853  void Finley_Mesh_saveVTK(const char * fi
1853            sprintf(error_msg, "saveVTK: data %s: Vtk can't handle objects with rank greater than 2.",names_p[i_data]);            sprintf(error_msg, "saveVTK: data %s: Vtk can't handle objects with rank greater than 2.",names_p[i_data]);
1854            Finley_setError(VALUE_ERROR,error_msg);            Finley_setError(VALUE_ERROR,error_msg);
1855            fclose(fileHandle_p);            fclose(fileHandle_p);
1856              TMPMEMFREE(isCellCentered);
1857            return;            return;
1858          }          }
1859        }        }
# Line 1824  void Finley_Mesh_saveVTK(const char * fi Line 1864  void Finley_Mesh_saveVTK(const char * fi
1864      {      {
1865        if (! isEmpty(data_pp[i_data]) && !isCellCentered[i_data])        if (! isEmpty(data_pp[i_data]) && !isCellCentered[i_data])
1866        {        {
1867          numPointsPerSample = elements->ReferenceElement->numQuadNodes;          if (Finley_Assemble_reducedIntegrationOrder(data_pp[i_data])) {
1868               numPointsPerSample=elements->ReferenceElementReducedOrder->numQuadNodes;
1869            } else {
1870               numPointsPerSample=elements->ReferenceElement->numQuadNodes;
1871            }
1872          rank = getDataPointRank(data_pp[i_data]);          rank = getDataPointRank(data_pp[i_data]);
1873          nComp = getDataPointSize(data_pp[i_data]);          nComp = getDataPointSize(data_pp[i_data]);
1874          nCompReqd=1;   /* the number of components required by vtk */          nCompReqd=1;   /* the number of components required by vtk */
# Line 1840  void Finley_Mesh_saveVTK(const char * fi Line 1884  void Finley_Mesh_saveVTK(const char * fi
1884            {            {
1885              Finley_setError(VALUE_ERROR, "saveVTK: rank 1 object must have less then 4 components");              Finley_setError(VALUE_ERROR, "saveVTK: rank 1 object must have less then 4 components");
1886              fclose(fileHandle_p);              fclose(fileHandle_p);
1887                TMPMEMFREE(isCellCentered);
1888              return;              return;
1889            }            }
1890            nCompReqd = 3;            nCompReqd = 3;
# Line 1851  void Finley_Mesh_saveVTK(const char * fi Line 1896  void Finley_Mesh_saveVTK(const char * fi
1896            {            {
1897              Finley_setError(VALUE_ERROR, "saveVTK: rank 2 object must have less then 4x4 components and must have a square shape");              Finley_setError(VALUE_ERROR, "saveVTK: rank 2 object must have less then 4x4 components and must have a square shape");
1898              fclose(fileHandle_p);              fclose(fileHandle_p);
1899                TMPMEMFREE(isCellCentered);
1900              return;              return;
1901            }            }
1902            nCompReqd = 9;            nCompReqd = 9;
# Line 1860  void Finley_Mesh_saveVTK(const char * fi Line 1906  void Finley_Mesh_saveVTK(const char * fi
1906          /* if the number of required components is more than the number          /* if the number of required components is more than the number
1907          * of actual components, pad with zeros          * of actual components, pad with zeros
1908          */          */
1909          bool_t do_write=TRUE;          do_write=TRUE;
1910          for (i=0; i<mesh_p->Nodes->numNodes; i++)          for (i=0; i<mesh_p->Nodes->numNodes; i++)
1911          {          {
1912            if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM)            if (nodetype==FINLEY_REDUCED_DEGREES_OF_FREEDOM)
# Line 1944  void Finley_Mesh_saveVTK(const char * fi Line 1990  void Finley_Mesh_saveVTK(const char * fi
1990    fprintf(fileHandle_p, "</VTKFile>\n");    fprintf(fileHandle_p, "</VTKFile>\n");
1991    /* close the file */    /* close the file */
1992    fclose(fileHandle_p);    fclose(fileHandle_p);
1993      TMPMEMFREE(isCellCentered);
1994    return;    return;
1995  }  }
1996  #endif  #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26