/[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 1942 by phornby, Wed Oct 29 03:29:35 2008 UTC revision 1985 by caltinay, Thu Nov 6 22:13:54 2008 UTC
# Line 54  void Finley_Mesh_saveVTK(const char * fi Line 54  void Finley_Mesh_saveVTK(const char * fi
54  {  {
55  #ifdef USE_VTK  #ifdef USE_VTK
56    char error_msg[LenErrorMsg_MAX], *txt_buffer=NULL, tmp_buffer[LEN_TMP_BUFFER];    char error_msg[LenErrorMsg_MAX], *txt_buffer=NULL, tmp_buffer[LEN_TMP_BUFFER];
57    double sampleAvg[NCOMP_MAX], *values, *QuadNodes;    double sampleAvg[NCOMP_MAX], *values, *QuadNodes=NULL;
58    size_t txt_buffer_in_use;    size_t txt_buffer_in_use;
59    dim_t len_txt_buffer,  max_len_names;    dim_t len_txt_buffer,  max_len_names;
60    FILE * fileHandle_p = NULL;    FILE * fileHandle_p = NULL;
61    int mpi_size, i, j, l, cellType;    int mpi_size, i, j, l, cellType=0;
62    dim_t i_data, hits, hits_old;    dim_t i_data, hits, hits_old;
63    dim_t nDim, globalNumPoints, numCells, globalNumCells, numVTKNodesPerElement;    dim_t nDim, globalNumPoints=0, numCells=0, globalNumCells=0, numVTKNodesPerElement=0;
64    dim_t myNumPoints, numPointsPerSample, rank, nComp, nCompReqd;    dim_t myNumPoints=0, numPointsPerSample, rank, nComp, nCompReqd;
65    dim_t shape, NN, numCellFactor, myNumCells, max_name_len;    dim_t shape, NN=0, numCellFactor=0, myNumCells=0, max_name_len;
66    bool_t *isCellCentered=NULL,write_celldata=FALSE,write_pointdata=FALSE, reduced_elements=FALSE;    bool_t *isCellCentered=NULL, write_celldata=FALSE, write_pointdata=FALSE, reduced_elements=FALSE;
67    bool_t set_scalar=FALSE,set_vector=FALSE, set_tensor=FALSE;    bool_t set_scalar=FALSE, set_vector=FALSE, set_tensor=FALSE;
68    index_t myFirstNode, myLastNode, *globalNodeIndex, k, *node_index, myFirstCell;    index_t myFirstNode=0, myLastNode=0, *globalNodeIndex=NULL;
69      index_t k, *node_index, myFirstCell=0;
70    #ifdef PASO_MPI    #ifdef PASO_MPI
71    int ierr;    int ierr;
72    /* int amode = MPI_MODE_CREATE | MPI_MODE_WRONLY |  MPI_MODE_SEQUENTIAL;  */    /* int amode = MPI_MODE_CREATE | MPI_MODE_WRONLY |  MPI_MODE_SEQUENTIAL;  */
# Line 78  void Finley_Mesh_saveVTK(const char * fi Line 79  void Finley_Mesh_saveVTK(const char * fi
79    Paso_MPI_rank my_mpi_rank;    Paso_MPI_rank my_mpi_rank;
80    int nodetype=FINLEY_NODES;    int nodetype=FINLEY_NODES;
81    int elementtype=FINLEY_UNKNOWN;    int elementtype=FINLEY_UNKNOWN;
   char elemTypeStr[32];  
82    Finley_NodeMapping *nodeMapping=NULL;    Finley_NodeMapping *nodeMapping=NULL;
83    Finley_ElementFile* elements=NULL;    Finley_ElementFile* elements=NULL;
84    ElementTypeId TypeId;    ElementTypeId TypeId=0;
85        
86    
87    /****************************************/    /****************************************/
# Line 94  void Finley_Mesh_saveVTK(const char * fi Line 94  void Finley_Mesh_saveVTK(const char * fi
94                      "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n" \                      "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n" \
95                      "<Points>\n" \                      "<Points>\n" \
96                      "<DataArray NumberOfComponents=\"%d\" type=\"Float64\" format=\"ascii\">\n";                      "<DataArray NumberOfComponents=\"%d\" type=\"Float64\" format=\"ascii\">\n";
97    char *tag_End_DataArray = "</DataArray>\n";    char* tag_End_DataArray = "</DataArray>\n";
98    char* tag_End_PointData =  "</PointData>\n";    char* tag_End_PointData = "</PointData>\n";
99    char* tag_End_CellData =  "</CellData>\n";    char* tag_End_CellData =  "</CellData>\n";
100    char *footer = "</Piece>\n</UnstructuredGrid>\n</VTKFile>\n";    char* footer = "</Piece>\n</UnstructuredGrid>\n</VTKFile>\n";
101    char* tags_End_Points_and_Start_Conn = "</DataArray>\n</Points>\n<Cells>\n<DataArray Name=\"connectivity\" type=\"Int32\" format=\"ascii\">\n" ;    char* tags_End_Points_and_Start_Conn = "</DataArray>\n</Points>\n<Cells>\n<DataArray Name=\"connectivity\" type=\"Int32\" format=\"ascii\">\n" ;
102    char* tags_End_Conn_and_Start_Offset = "</DataArray>\n<DataArray Name=\"offsets\" type=\"Int32\" format=\"ascii\">\n";    char* tags_End_Conn_and_Start_Offset = "</DataArray>\n<DataArray Name=\"offsets\" type=\"Int32\" format=\"ascii\">\n";
103    char* tags_End_Offset_and_Start_Type = "</DataArray>\n<DataArray Name=\"types\" type=\"UInt8\" format=\"ascii\">\n";    char* tags_End_Offset_and_Start_Type = "</DataArray>\n<DataArray Name=\"types\" type=\"UInt8\" format=\"ascii\">\n";
104    char* tag_Float_DataArray="<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n";    char* tag_Float_DataArray="<DataArray Name=\"%s\" type=\"Float64\" NumberOfComponents=\"%d\" format=\"ascii\">\n";
105    char *tags_End_Type_And_Cells = "</DataArray>\n</Cells>\n";    char* tags_End_Type_And_Cells = "</DataArray>\n</Cells>\n";
106    
107    int VTK_QUADRATIC_HEXAHEDRON_INDEX[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 12, 13, 14, 15 };    int VTK_QUADRATIC_HEXAHEDRON_INDEX[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 12, 13, 14, 15 };
108    
109    /* if there is no mesh we just return */    /* if there is no mesh we just return */
110    if (mesh_p==NULL) return;    if (mesh_p==NULL) return;
111    
# Line 316  void Finley_Mesh_saveVTK(const char * fi Line 317  void Finley_Mesh_saveVTK(const char * fi
317            numCellFactor=1;            numCellFactor=1;
318            cellType = VTK_VERTEX;            cellType = VTK_VERTEX;
319            numVTKNodesPerElement = 1;            numVTKNodesPerElement = 1;
           strcpy(elemTypeStr, "VTK_VERTEX");  
320            break;            break;
321                
322          case Line2:          case Line2:
# Line 329  void Finley_Mesh_saveVTK(const char * fi Line 329  void Finley_Mesh_saveVTK(const char * fi
329            numCellFactor=1;            numCellFactor=1;
330            cellType = VTK_LINE;            cellType = VTK_LINE;
331            numVTKNodesPerElement = 2;            numVTKNodesPerElement = 2;
           strcpy(elemTypeStr, "VTK_LINE");  
332            break;            break;
333                
334          case Tri3:          case Tri3:
# Line 338  void Finley_Mesh_saveVTK(const char * fi Line 337  void Finley_Mesh_saveVTK(const char * fi
337            numCellFactor=1;            numCellFactor=1;
338            cellType = VTK_TRIANGLE;            cellType = VTK_TRIANGLE;
339            numVTKNodesPerElement = 3;            numVTKNodesPerElement = 3;
           strcpy(elemTypeStr, "VTK_TRIANGLE");  
340            break;            break;
341                
342          case Rec4:          case Rec4:
# Line 348  void Finley_Mesh_saveVTK(const char * fi Line 346  void Finley_Mesh_saveVTK(const char * fi
346            numCellFactor=1;            numCellFactor=1;
347            cellType = VTK_QUAD;            cellType = VTK_QUAD;
348            numVTKNodesPerElement = 4;            numVTKNodesPerElement = 4;
           strcpy(elemTypeStr, "VTK_QUAD");  
349            break;            break;
350    
351          case Rec9:          case Rec9:
352            numCellFactor=4;            numCellFactor=4;
353            cellType = VTK_QUAD;            cellType = VTK_QUAD;
354            numVTKNodesPerElement = 4;            numVTKNodesPerElement = 4;
           strcpy(elemTypeStr, "VTK_QUAD");  
355            break;            break;
356                
357          case Tet4:          case Tet4:
358            numCellFactor=1;            numCellFactor=1;
359            cellType = VTK_TETRA;            cellType = VTK_TETRA;
360            numVTKNodesPerElement = 4;            numVTKNodesPerElement = 4;
           strcpy(elemTypeStr, "VTK_TETRA");  
361            break;            break;
362                
363          case Hex8:          case Hex8:
364            numCellFactor=1;            numCellFactor=1;
365            cellType = VTK_HEXAHEDRON;            cellType = VTK_HEXAHEDRON;
366            numVTKNodesPerElement = 8;            numVTKNodesPerElement = 8;
           strcpy(elemTypeStr, "VTK_HEXAHEDRON");  
367            break;            break;
368                
369          case Line3:          case Line3:
# Line 381  void Finley_Mesh_saveVTK(const char * fi Line 375  void Finley_Mesh_saveVTK(const char * fi
375            numCellFactor=1;            numCellFactor=1;
376            cellType = VTK_QUADRATIC_EDGE;            cellType = VTK_QUADRATIC_EDGE;
377            numVTKNodesPerElement = 3;            numVTKNodesPerElement = 3;
           strcpy(elemTypeStr, "VTK_QUADRATIC_EDGE");  
378            break;            break;
379                
380          case Tri6:          case Tri6:
# Line 391  void Finley_Mesh_saveVTK(const char * fi Line 384  void Finley_Mesh_saveVTK(const char * fi
384            numCellFactor=1;            numCellFactor=1;
385            cellType = VTK_QUADRATIC_TRIANGLE;            cellType = VTK_QUADRATIC_TRIANGLE;
386            numVTKNodesPerElement = 6;            numVTKNodesPerElement = 6;
           strcpy(elemTypeStr, "VTK_QUADRATIC_TRIANGLE");  
387            break;            break;
388                
389          case Rec8:          case Rec8:
# Line 401  void Finley_Mesh_saveVTK(const char * fi Line 393  void Finley_Mesh_saveVTK(const char * fi
393            numCellFactor=1;            numCellFactor=1;
394            cellType = VTK_QUADRATIC_QUAD;            cellType = VTK_QUADRATIC_QUAD;
395            numVTKNodesPerElement = 8;            numVTKNodesPerElement = 8;
           strcpy(elemTypeStr, "VTK_QUADRATIC_QUAD");  
396            break;            break;
397                
398          case Tet10:          case Tet10:
399            numCellFactor=1;            numCellFactor=1;
400            cellType = VTK_QUADRATIC_TETRA;            cellType = VTK_QUADRATIC_TETRA;
401            numVTKNodesPerElement = 10;            numVTKNodesPerElement = 10;
           strcpy(elemTypeStr, "VTK_QUADRATIC_TETRA");  
402            break;            break;
403                
404          case Hex20:          case Hex20:
405            numCellFactor=1;            numCellFactor=1;
406            cellType = VTK_QUADRATIC_HEXAHEDRON;            cellType = VTK_QUADRATIC_HEXAHEDRON;
407            numVTKNodesPerElement = 20;            numVTKNodesPerElement = 20;
           strcpy(elemTypeStr, "VTK_QUADRATIC_HEXAHEDRON");  
408            break;            break;
409    
410          case Hex27:          case Hex27:
411            numCellFactor=8;            numCellFactor=8;
412            cellType = VTK_HEXAHEDRON;            cellType = VTK_HEXAHEDRON;
413            numVTKNodesPerElement = 8;            numVTKNodesPerElement = 8;
           strcpy(elemTypeStr, "VTK_HEXAHEDRON");  
414            break;            break;
415                
416          default:          default:

Legend:
Removed from v.1942  
changed lines
  Added in v.1985

  ViewVC Help
Powered by ViewVC 1.1.26