/[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

temp_trunk_copy/finley/src/Mesh_saveVTK.c revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC trunk/finley/src/Mesh_saveVTK.c revision 1665 by gross, Wed Jul 23 03:23:03 2008 UTC
# Line 51  void Finley_Mesh_saveVTK(const char * fi Line 51  void Finley_Mesh_saveVTK(const char * fi
51  {  {
52    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];
53    double sampleAvg[NCOMP_MAX], *values, rtmp;    double sampleAvg[NCOMP_MAX], *values, rtmp;
54    size_t len_txt_buffer, max_len_names, txt_buffer_in_use;    size_t txt_buffer_in_use;
55      dim_t len_txt_buffer,  max_len_names;
56    FILE * fileHandle_p = NULL;    FILE * fileHandle_p = NULL;
57    int mpi_size, i_data, i,j , cellType;    int mpi_size, i, j, cellType;
58    dim_t nDim, globalNumPoints, numCells, globalNumCells, numVTKNodesPerElement, myNumPoints, numPointsPerSample, rank, nComp, nCompReqd, shape, NN, numCellFactor, myNumCells, max_name_len;    dim_t i_data;
59    bool_t do_write, *isCellCentered=NULL,write_celldata=FALSE,write_pointdata=FALSE;    dim_t nDim, globalNumPoints, numCells, globalNumCells, numVTKNodesPerElement;
60      dim_t myNumPoints, numPointsPerSample, rank, nComp, nCompReqd;
61      dim_t shape, NN, numCellFactor, myNumCells, max_name_len;
62      bool_t *isCellCentered=NULL,write_celldata=FALSE,write_pointdata=FALSE;
63    bool_t set_scalar=FALSE,set_vector=FALSE, set_tensor=FALSE;    bool_t set_scalar=FALSE,set_vector=FALSE, set_tensor=FALSE;
64    index_t myFirstNode, myLastNode, *globalNodeIndex, k, *node_index, myFirstCell;    index_t myFirstNode, myLastNode, *globalNodeIndex, k, *node_index, myFirstCell;
65    #ifdef PASO_MPI    #ifdef PASO_MPI
66    int ierr;    int ierr;
67    int amode = MPI_MODE_CREATE | MPI_MODE_WRONLY |  MPI_MODE_SEQUENTIAL;    int amode = MPI_MODE_CREATE | MPI_MODE_WRONLY |  MPI_MODE_SEQUENTIAL;
68    MPI_File mpi_fileHandle_p;    MPI_File mpi_fileHandle_p;
69    MPI_Status mpi_status;    MPI_Status mpi_status;
70    MPI_Request mpi_req;    MPI_Request mpi_req;
# Line 128  void Finley_Mesh_saveVTK(const char * fi Line 132  void Finley_Mesh_saveVTK(const char * fi
132              /*   MPI_Info_set(mpi_info, "direct_write",          "true"); */              /*   MPI_Info_set(mpi_info, "direct_write",          "true"); */
133            #endif            #endif
134            ierr=MPI_File_open(mesh_p->Nodes->MPIInfo->comm, (char*)filename_p, amode,mpi_info, &mpi_fileHandle_p);            ierr=MPI_File_open(mesh_p->Nodes->MPIInfo->comm, (char*)filename_p, amode,mpi_info, &mpi_fileHandle_p);
135            if (! ierr) {            if (ierr != MPI_SUCCESS) {
136            perror(filename_p);            perror(filename_p);
137                sprintf(error_msg, "saveVTK: File %s could not be opened for writing in parallel.", filename_p);                sprintf(error_msg, "saveVTK: File %s could not be opened for writing in parallel.", filename_p);
138                Finley_setError(IO_ERROR,error_msg);                Finley_setError(IO_ERROR,error_msg);
# Line 227  void Finley_Mesh_saveVTK(const char * fi Line 231  void Finley_Mesh_saveVTK(const char * fi
231           } else {           } else {
232             write_pointdata=TRUE;             write_pointdata=TRUE;
233           }           }
234           max_len_names =MAX(max_len_names,strlen(names_p[i_data]));           max_len_names =MAX(max_len_names,(dim_t)strlen(names_p[i_data]));
235         }         }
236       }       }
237       nodetype = (nodetype == FINLEY_UNKNOWN) ? FINLEY_NODES : nodetype;       nodetype = (nodetype == FINLEY_UNKNOWN) ? FINLEY_NODES : nodetype;
# Line 274  void Finley_Mesh_saveVTK(const char * fi Line 278  void Finley_Mesh_saveVTK(const char * fi
278         myNumCells= Finley_ElementFile_getMyNumElements(elements);         myNumCells= Finley_ElementFile_getMyNumElements(elements);
279         myFirstCell= Finley_ElementFile_getFirstElement(elements);         myFirstCell= Finley_ElementFile_getFirstElement(elements);
280         NN = elements->numNodes;         NN = elements->numNodes;
281         if (nodetype==FINLEY_REDUCED_NODES || nodetype==FINLEY_REDUCED_NODES) {         if (nodetype==FINLEY_REDUCED_NODES) {
282            TypeId = elements->LinearReferenceElement->Type->TypeId;            TypeId = elements->LinearReferenceElement->Type->TypeId;
283         } else {         } else {
284            TypeId = elements->ReferenceElement->Type->TypeId;            TypeId = elements->ReferenceElement->Type->TypeId;
# Line 397  void Finley_Mesh_saveVTK(const char * fi Line 401  void Finley_Mesh_saveVTK(const char * fi
401    /*   allocate text buffer              */    /*   allocate text buffer              */
402    /*                                     */    /*                                     */
403    max_name_len=0;    max_name_len=0;
404    for (i_data =0 ;i_data<num_data;++i_data) max_name_len=MAX(max_name_len,strlen(names_p[i_data]));    for (i_data =0 ;i_data<num_data;++i_data) max_name_len=MAX(max_name_len,(dim_t)strlen(names_p[i_data]));
405    len_txt_buffer= strlen(tags_header) + 3 * LEN_PRINTED_INT_FORMAT + (30+3*max_name_len); /* header */    len_txt_buffer= strlen(tags_header) + 3 * LEN_PRINTED_INT_FORMAT + (30+3*max_name_len); /* header */
406    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, myNumPoints * LEN_TMP_BUFFER);    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, myNumPoints * LEN_TMP_BUFFER);
407    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, numCellFactor*myNumCells*(LEN_PRINTED_INT_FORMAT*numVTKNodesPerElement+1));    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, numCellFactor*myNumCells*(LEN_PRINTED_INT_FORMAT*numVTKNodesPerElement+1));
408    len_txt_buffer=MAX(len_txt_buffer,200+3*max_len_names);    len_txt_buffer=MAX(len_txt_buffer,200+3*max_len_names);
409    len_txt_buffer=MAX(len_txt_buffer, strlen(tag_Float_DataArray) + LEN_PRINTED_INT_FORMAT + max_len_names);    len_txt_buffer=MAX(len_txt_buffer, (dim_t)strlen(tag_Float_DataArray) + LEN_PRINTED_INT_FORMAT + max_len_names);
410    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, numCellFactor*myNumCells*LEN_PRINTED_FLOAT_TENSOR_FORMAT);    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, numCellFactor*myNumCells*LEN_PRINTED_FLOAT_TENSOR_FORMAT);
411    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, myNumPoints*LEN_PRINTED_FLOAT_TENSOR_FORMAT);    if (mpi_size > 1) len_txt_buffer=MAX(len_txt_buffer, myNumPoints*LEN_PRINTED_FLOAT_TENSOR_FORMAT);
412    txt_buffer=TMPMEMALLOC(len_txt_buffer+1,char);    txt_buffer=TMPMEMALLOC(len_txt_buffer+1,char);
# Line 590  void Finley_Mesh_saveVTK(const char * fi Line 594  void Finley_Mesh_saveVTK(const char * fi
594      } else {      } else {
595         fprintf(fileHandle_p,tags_End_Offset_and_Start_Type);         fprintf(fileHandle_p,tags_End_Offset_and_Start_Type);
596      }      }
       
         
597       /* write element type */       /* write element type */
598       sprintf(tmp_buffer, INT_NEWLINE_FORMAT, cellType);       sprintf(tmp_buffer, INT_NEWLINE_FORMAT, cellType);
599       if ( mpi_size > 1) {       if ( mpi_size > 1) {
# Line 943  void Finley_Mesh_saveVTK(const char * fi Line 945  void Finley_Mesh_saveVTK(const char * fi
945          if ( mpi_size > 1) {          if ( mpi_size > 1) {
946            if ( my_mpi_rank == 0) {            if ( my_mpi_rank == 0) {
947               #ifdef PASO_MPI               #ifdef PASO_MPI
948                  MPI_File_iwrite_shared(mpi_fileHandle_p,tag_End_CellData,strlen(tag_End_PointData),MPI_CHAR,&mpi_req);                  MPI_File_iwrite_shared(mpi_fileHandle_p,tag_End_PointData,strlen(tag_End_PointData),MPI_CHAR,&mpi_req);
949                  MPI_Wait(&mpi_req,&mpi_status);                  MPI_Wait(&mpi_req,&mpi_status);
950               #endif               #endif
951            }            }
# Line 961  void Finley_Mesh_saveVTK(const char * fi Line 963  void Finley_Mesh_saveVTK(const char * fi
963                 MPI_Info_free(&mpi_info);                 MPI_Info_free(&mpi_info);
964                 #undef MPIO_HINTS                 #undef MPIO_HINTS
965               #endif               #endif
              MPI_File_close(&mpi_fileHandle_p);  
966            #endif            #endif
967          }          }
968            #ifdef PASO_MPI
969               MPI_File_close(&mpi_fileHandle_p);
970            #endif
971       } else {       } else {
972           fprintf(fileHandle_p,footer);           fprintf(fileHandle_p,footer);
973           fclose(fileHandle_p);           fclose(fileHandle_p);

Legend:
Removed from v.1384  
changed lines
  Added in v.1665

  ViewVC Help
Powered by ViewVC 1.1.26