/[escript]/branches/doubleplusgood/finley/src/Mesh_read.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/finley/src/Mesh_read.cpp

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

revision 4261 by jfenwick, Wed Feb 27 06:09:33 2013 UTC revision 4327 by jfenwick, Wed Mar 20 05:09:11 2013 UTC
# Line 87  Finley_Mesh* Finley_Mesh_read(char* fnam Line 87  Finley_Mesh* Finley_Mesh_read(char* fnam
87      if (Finley_noError()) {      if (Finley_noError()) {
88          /* Each CPU will get at most chunkSize nodes so the message has to be sufficiently large */          /* Each CPU will get at most chunkSize nodes so the message has to be sufficiently large */
89          int chunkSize = numNodes / mpi_info->size + 1, totalNodes=0, chunkNodes=0,  nextCPU=1;          int chunkSize = numNodes / mpi_info->size + 1, totalNodes=0, chunkNodes=0,  nextCPU=1;
90          int *tempInts = TMPMEMALLOC(chunkSize*3+1, index_t);        /* Stores the integer message data */          int *tempInts = new index_t[chunkSize*3+1];        /* Stores the integer message data */
91          double *tempCoords = TMPMEMALLOC(chunkSize*numDim, double); /* Stores the double message data */          double *tempCoords = new double[chunkSize*numDim]; /* Stores the double message data */
92    
93          /*          /*
94          Read chunkSize nodes, send it in a chunk to worker CPU which copies chunk into its local mesh_p          Read chunkSize nodes, send it in a chunk to worker CPU which copies chunk into its local mesh_p
# Line 171  Finley_Mesh* Finley_Mesh_read(char* fnam Line 171  Finley_Mesh* Finley_Mesh_read(char* fnam
171                  }                  }
172              }              }
173          }          }
174          TMPMEMFREE(tempInts);          delete[] tempInts;
175          TMPMEMFREE(tempCoords);          delete[] tempCoords;
176      }      }
177    
178      /* ***********************************  read elements ****************************************************************************************/      /* ***********************************  read elements ****************************************************************************************/
# Line 215  Finley_Mesh* Finley_Mesh_read(char* fnam Line 215  Finley_Mesh* Finley_Mesh_read(char* fnam
215      if (Finley_noError()) {      if (Finley_noError()) {
216    
217          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;
218          int *tempInts = TMPMEMALLOC(chunkSize*(2+numNodes)+1, index_t); /* Store Id + Tag + node list (+ one int at end for chunkEle) */          int *tempInts = new index_t[chunkSize*(2+numNodes)+1]; /* Store Id + Tag + node list (+ one int at end for chunkEle) */
219          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */
220          if (mpi_info->rank == 0) {  /* Master */          if (mpi_info->rank == 0) {  /* Master */
221              for (;;) {            /* Infinite loop */              for (;;) {            /* Infinite loop */
# Line 278  Finley_Mesh* Finley_Mesh_read(char* fnam Line 278  Finley_Mesh* Finley_Mesh_read(char* fnam
278              }              }
279          }          }
280    
281          TMPMEMFREE(tempInts);          delete[] tempInts;
282      }      }
283      /* ******************** end of Read the element data ******************************************************/      /* ******************** end of Read the element data ******************************************************/
284    
# Line 318  Finley_Mesh* Finley_Mesh_read(char* fnam Line 318  Finley_Mesh* Finley_Mesh_read(char* fnam
318    
319      if (Finley_noError()) {      if (Finley_noError()) {
320          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;
321          int *tempInts = TMPMEMALLOC(chunkSize*(2+numNodes)+1, index_t); /* Store Id + Tag + node list (+ one int at end for chunkEle) */          int *tempInts = new index_t[chunkSize*(2+numNodes)+1]; /* Store Id + Tag + node list (+ one int at end for chunkEle) */
322          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */
323          if (mpi_info->rank == 0) {  /* Master */          if (mpi_info->rank == 0) {  /* Master */
324              for (;;) {            /* Infinite loop */              for (;;) {            /* Infinite loop */
# Line 379  Finley_Mesh* Finley_Mesh_read(char* fnam Line 379  Finley_Mesh* Finley_Mesh_read(char* fnam
379              }              }
380          }          }
381    
382          TMPMEMFREE(tempInts);          delete[] tempInts;
383      }      }
384      /* ************************************* end of Read the face element data *************************************** */      /* ************************************* end of Read the face element data *************************************** */
385    
# Line 418  Finley_Mesh* Finley_Mesh_read(char* fnam Line 418  Finley_Mesh* Finley_Mesh_read(char* fnam
418      /* *************************** Read the contact element data ************************************************* */      /* *************************** Read the contact element data ************************************************* */
419      if (Finley_noError()) {      if (Finley_noError()) {
420          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;
421          int *tempInts = TMPMEMALLOC(chunkSize*(2+numNodes)+1, index_t); /* Store Id + Tag + node list (+ one int at end for chunkEle) */          int *tempInts = new index_t[chunkSize*(2+numNodes)+1]; /* Store Id + Tag + node list (+ one int at end for chunkEle) */
422          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */
423          if (mpi_info->rank == 0) {  /* Master */          if (mpi_info->rank == 0) {  /* Master */
424              for (;;) {            /* Infinite loop */              for (;;) {            /* Infinite loop */
# Line 477  Finley_Mesh* Finley_Mesh_read(char* fnam Line 477  Finley_Mesh* Finley_Mesh_read(char* fnam
477                   }                   }
478               }               }
479          }          }
480          TMPMEMFREE(tempInts);          delete[] tempInts;
481      } /* end of Read the contact element data */      } /* end of Read the contact element data */
482    
483      /* ********************************* read nodal elements ****************************************************** */      /* ********************************* read nodal elements ****************************************************** */
# Line 516  Finley_Mesh* Finley_Mesh_read(char* fnam Line 516  Finley_Mesh* Finley_Mesh_read(char* fnam
516      /**********************************  Read the nodal element data **************************************************/      /**********************************  Read the nodal element data **************************************************/
517      if (Finley_noError()) {      if (Finley_noError()) {
518          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;          int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1, chunkEle=0;
519          int *tempInts = TMPMEMALLOC(chunkSize*(2+numNodes)+1, index_t); /* Store Id + Tag + node list (+ one int at end for chunkEle) */          int *tempInts = new index_t[chunkSize*(2+numNodes)+1]; /* Store Id + Tag + node list (+ one int at end for chunkEle) */
520          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */          /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */
521          if (mpi_info->rank == 0) {  /* Master */          if (mpi_info->rank == 0) {  /* Master */
522              for (;;) {            /* Infinite loop */              for (;;) {            /* Infinite loop */
# Line 576  Finley_Mesh* Finley_Mesh_read(char* fnam Line 576  Finley_Mesh* Finley_Mesh_read(char* fnam
576              }              }
577          }          }
578    
579          TMPMEMFREE(tempInts);          delete[] tempInts;
580      } /* ******************************** end of Read the nodal element data *********************************************************************************** */      } /* ******************************** end of Read the nodal element data *********************************************************************************** */
581    
582            
# Line 631  Finley_Mesh* Finley_Mesh_read(char* fnam Line 631  Finley_Mesh* Finley_Mesh_read(char* fnam
631                      fseek(fileHandle_p, 0L, SEEK_END);                      fseek(fileHandle_p, 0L, SEEK_END);
632                      end_pos = ftell(fileHandle_p);                      end_pos = ftell(fileHandle_p);
633                      fseek(fileHandle_p, (long)cur_pos, SEEK_SET);                      fseek(fileHandle_p, (long)cur_pos, SEEK_SET);
634                      remainder = TMPMEMALLOC(end_pos-cur_pos+1, char);                      remainder = new char[end_pos-cur_pos+1];
635                      if (! feof(fileHandle_p))                      if (! feof(fileHandle_p))
636                      {                      {
637                          scan_ret = fread(remainder, (size_t) end_pos-cur_pos,                          scan_ret = fread(remainder, (size_t) end_pos-cur_pos,
# Line 653  Finley_Mesh* Finley_Mesh_read(char* fnam Line 653  Finley_Mesh* Finley_Mesh_read(char* fnam
653              MPI_Bcast (&len_i, 1, MPI_INT,  0, mpi_info->comm);              MPI_Bcast (&len_i, 1, MPI_INT,  0, mpi_info->comm);
654              len=(size_t) len_i;              len=(size_t) len_i;
655              if (mpi_info->rank != 0) {              if (mpi_info->rank != 0) {
656                  remainder = TMPMEMALLOC(len+1, char);                  remainder = new char[len+1];
657                  remainder[0] = 0;                  remainder[0] = 0;
658              }              }
659              if (MPI_Bcast (remainder, len+1, MPI_CHAR,  0, mpi_info->comm) !=              if (MPI_Bcast (remainder, len+1, MPI_CHAR,  0, mpi_info->comm) !=
# Line 670  Finley_Mesh* Finley_Mesh_read(char* fnam Line 670  Finley_Mesh* Finley_Mesh_read(char* fnam
670              } while(NULL != (ptr = strchr(ptr, '\n')) && *ptr);              } while(NULL != (ptr = strchr(ptr, '\n')) && *ptr);
671          }          }
672          if (remainder)          if (remainder)
673              TMPMEMFREE(remainder);              delete[] remainder;
674      }      }
675    
676      /* close file */      /* close file */

Legend:
Removed from v.4261  
changed lines
  Added in v.4327

  ViewVC Help
Powered by ViewVC 1.1.26