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

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

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

revision 121 by jgs, Fri May 6 04:26:16 2005 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 22  void Finley_Mesh_saveVTK(const char * fi Line 22  void Finley_Mesh_saveVTK(const char * fi
22    if (mesh_p==NULL) return;    if (mesh_p==NULL) return;
23    Finley_ElementFile* elements=NULL;    Finley_ElementFile* elements=NULL;
24    char elemTypeStr[32];    char elemTypeStr[32];
25    int i, j, k, numVTKNodesPerElement, isCellCentered, nodetype;    int i, j, k, numVTKNodesPerElement, isCellCentered=FALSE, nodetype=FINLEY_DEGREES_OF_FREEDOM;
26    double* values, rtmp;    double* values, rtmp;
27    int nDim = mesh_p->Nodes->numDim;    int nDim = mesh_p->Nodes->numDim;
28    
# Line 348  void Finley_Mesh_saveVTK(const char * fi Line 348  void Finley_Mesh_saveVTK(const char * fi
348          "type=\"Int32\" "          "type=\"Int32\" "
349          "format=\"ascii\">\n");          "format=\"ascii\">\n");
350      int NN = elements->ReferenceElement->Type->numNodes;      int NN = elements->ReferenceElement->Type->numNodes;
351      int counter = 0;      if (VTK_QUADRATIC_HEXAHEDRON==cellType) {
352      for (i = 0; i < numCells; i++) {         for (i = 0; i < numCells; i++) {
353        fprintf(fileHandle_p, "%d ",           fprintf(fileHandle_p,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
354            mesh_p->Elements->Nodes[INDEX2(0, i, NN)]);                              mesh_p->Elements->Nodes[INDEX2(0, i, NN)],
355        counter++; /* counter for the number of connectivity points written */                              mesh_p->Elements->Nodes[INDEX2(1, i, NN)],
356        /* if the counter gets too big (i.e. the line gets too long),                              mesh_p->Elements->Nodes[INDEX2(2, i, NN)],
357         * then add a newline and reset */                              mesh_p->Elements->Nodes[INDEX2(3, i, NN)],
358        if (counter > 19) {                              mesh_p->Elements->Nodes[INDEX2(4, i, NN)],
359        fprintf(fileHandle_p, "\n");                              mesh_p->Elements->Nodes[INDEX2(5, i, NN)],
360        counter = 0;                              mesh_p->Elements->Nodes[INDEX2(6, i, NN)],
361        }                              mesh_p->Elements->Nodes[INDEX2(7, i, NN)],
362        for (j = 1; j < numVTKNodesPerElement; j++) {                              mesh_p->Elements->Nodes[INDEX2(8, i, NN)],
363      fprintf(fileHandle_p,"%d ", mesh_p->Elements->Nodes[INDEX2(j, i, NN)]);                              mesh_p->Elements->Nodes[INDEX2(9, i, NN)],
364      counter++;                              mesh_p->Elements->Nodes[INDEX2(10, i, NN)],
365      /* if the counter gets too big (i.e. the line gets too long),                              mesh_p->Elements->Nodes[INDEX2(11, i, NN)],
366       * then add a newline and reset */                              mesh_p->Elements->Nodes[INDEX2(16, i, NN)],
367      if (counter > 19) {                              mesh_p->Elements->Nodes[INDEX2(17, i, NN)],
368          fprintf(fileHandle_p, "\n");                              mesh_p->Elements->Nodes[INDEX2(18, i, NN)],
369          counter = 0;                              mesh_p->Elements->Nodes[INDEX2(19, i, NN)],
370      }                              mesh_p->Elements->Nodes[INDEX2(12, i, NN)],
371        }                              mesh_p->Elements->Nodes[INDEX2(13, i, NN)],
372                                mesh_p->Elements->Nodes[INDEX2(14, i, NN)],
373                                mesh_p->Elements->Nodes[INDEX2(15, i, NN)]);
374             fprintf(fileHandle_p, "\n");
375           }
376        } else {
377           for (i = 0; i < numCells; i++) {
378             for (j = 0; j < numVTKNodesPerElement; j++) fprintf(fileHandle_p,"%d ", mesh_p->Elements->Nodes[INDEX2(j, i, NN)]);
379             fprintf(fileHandle_p, "\n");
380           }
381      }      }
382      fprintf(fileHandle_p, "\n");      fprintf(fileHandle_p, "\n");
383      fprintf(fileHandle_p, "</DataArray>\n");      fprintf(fileHandle_p, "</DataArray>\n");
# Line 378  void Finley_Mesh_saveVTK(const char * fi Line 387  void Finley_Mesh_saveVTK(const char * fi
387          "Name=\"offsets\" "          "Name=\"offsets\" "
388          "type=\"Int32\" "          "type=\"Int32\" "
389          "format=\"ascii\">\n");          "format=\"ascii\">\n");
390      counter = 0;  /* counter for the number of offsets written to file */      int counter = 0;  /* counter for the number of offsets written to file */
391      for (i=numVTKNodesPerElement; i<=numCells*numVTKNodesPerElement; i+=numVTKNodesPerElement) {      for (i=numVTKNodesPerElement; i<=numCells*numVTKNodesPerElement; i+=numVTKNodesPerElement) {
392        fprintf(fileHandle_p, "%d ", i);        fprintf(fileHandle_p, "%d ", i);
393        counter++;        counter++;
# Line 432  void Finley_Mesh_saveVTK(const char * fi Line 441  void Finley_Mesh_saveVTK(const char * fi
441       * if the rank == 2:   --> tensor data       * if the rank == 2:   --> tensor data
442       */       */
443      char dataNameStr[31], dataTypeStr[63];      char dataNameStr[31], dataTypeStr[63];
444      int nCompReqd;   /* the number of components required by vtk */      int nCompReqd=1;   /* the number of components required by vtk */
445      if (rank == 0) {      if (rank == 0) {
446        strcpy(dataNameStr, "escript_scalar_data");        strcpy(dataNameStr, "escript_scalar_data");
447        sprintf(dataTypeStr, "Scalars=\"%s\"", dataNameStr);        sprintf(dataTypeStr, "Scalars=\"%s\"", dataNameStr);
# Line 617  void Finley_Mesh_saveVTK(const char * fi Line 626  void Finley_Mesh_saveVTK(const char * fi
626    
627  /*  /*
628   * $Log$   * $Log$
629     * Revision 1.6  2005/08/12 01:45:43  jgs
630     * erge of development branch dev-02 back to main trunk on 2005-08-12
631     *
632     * Revision 1.5.2.1  2005/08/10 06:14:37  gross
633     * QUADRATIC HEXAHEDRON elements fixed
634     *
635     * Revision 1.5  2005/07/08 04:07:55  jgs
636     * Merge of development branch back to main trunk on 2005-07-08
637     *
638   * Revision 1.4  2005/05/06 04:26:15  jgs   * Revision 1.4  2005/05/06 04:26:15  jgs
639   * Merge of development branch back to main trunk on 2005-05-06   * Merge of development branch back to main trunk on 2005-05-06
640   *   *
641     * Revision 1.1.2.7  2005/06/29 02:34:54  gross
642     * some changes towards 64 integers in finley
643     *
644   * Revision 1.1.2.6  2005/05/06 01:17:19  cochrane   * Revision 1.1.2.6  2005/05/06 01:17:19  cochrane
645   * Fixed incorrect reporting of number of components in PointData arrays for   * Fixed incorrect reporting of number of components in PointData arrays for
646   * vector data.   * vector data.

Legend:
Removed from v.121  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26