/[escript]/trunk/finley/src/Mesh_read.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_read.c

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

temp/finley/src/Mesh_read.c revision 1387 by trankine, Fri Jan 11 07:45:26 2008 UTC trunk/finley/src/Mesh_read.c revision 1725 by ksteube, Tue Aug 26 03:31:49 2008 UTC
# Line 230  Finley_Mesh* Finley_Mesh_read(char* fnam Line 230  Finley_Mesh* Finley_Mesh_read(char* fnam
230    return mesh_p;    return mesh_p;
231  }  }
232    
233  Finley_Mesh* Finley_Mesh_read_MPI(char* fname,index_t order, index_t reduced_order,  bool_t optimize)  Finley_Mesh* Finley_Mesh_read_MPI(char* fname,index_t order, index_t reduced_order,  bool_t optimize)
234    
235  {  {
236    
237    Paso_MPIInfo *mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );    Paso_MPIInfo *mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
238    dim_t numNodes, numDim, numEle, i0, i1;    dim_t numNodes, numDim, numEle, i0, i1;
   index_t tag_key;  
239    Finley_Mesh *mesh_p=NULL;    Finley_Mesh *mesh_p=NULL;
240    char name[LenString_MAX],element_type[LenString_MAX],frm[20];    char name[LenString_MAX],element_type[LenString_MAX],frm[20];
241    char error_msg[LenErrorMsg_MAX];    char error_msg[LenErrorMsg_MAX];
242    double time0=Finley_timer();    double time0=Finley_timer();
243    FILE *fileHandle_p = NULL;    FILE *fileHandle_p = NULL;
244    ElementTypeId typeID, faceTypeID, contactTypeID, pointTypeID;    ElementTypeId typeID, faceTypeID, contactTypeID, pointTypeID;
245        index_t tag_key;
246    
247    Finley_resetError();    Finley_resetError();
248    
249    if (mpi_info->rank == 0) {    if (mpi_info->rank == 0) {
# Line 255  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 255  Finley_Mesh* Finley_Mesh_read_MPI(char*
255         Paso_MPIInfo_free( mpi_info );         Paso_MPIInfo_free( mpi_info );
256         return NULL;         return NULL;
257       }       }
258      
259       /* read header */       /* read header */
260       sprintf(frm,"%%%d[^\n]",LenString_MAX-1);       sprintf(frm,"%%%d[^\n]",LenString_MAX-1);
261       fscanf(fileHandle_p, frm, name);       fscanf(fileHandle_p, frm, name);
262      
263       /* get the nodes */       /* get the number of nodes */
     
264       fscanf(fileHandle_p, "%1d%*s %d\n", &numDim,&numNodes);       fscanf(fileHandle_p, "%1d%*s %d\n", &numDim,&numNodes);
265    }    }
266    
267  #ifdef PASO_MPI  #ifdef PASO_MPI
268    /* MPI Broadcast numDim, numNodes, name */    /* MPI Broadcast numDim, numNodes, name if there are multiple MPI procs*/
269    if (mpi_info->size > 0) {    if (mpi_info->size > 1) {
270      int temp1[3], error_code;      int temp1[3], error_code;
271      temp1[0] = numDim;      temp1[0] = numDim;
272      temp1[1] = numNodes;      temp1[1] = numNodes;
# Line 286  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 285  Finley_Mesh* Finley_Mesh_read_MPI(char*
285      }      }
286    }    }
287  #endif  #endif
   printf("ksteube CPU=%d/%d name='%s' numDim=%d numNodes=%d\n", mpi_info->rank, mpi_info->size, name, numDim, numNodes);  
288    
289       /* allocate mesh */       /* allocate mesh */
290       mesh_p = Finley_Mesh_alloc(name,numDim,order,reduced_order,mpi_info);       mesh_p = Finley_Mesh_alloc(name,numDim,order,reduced_order,mpi_info);
291       if (Finley_noError()) {       if (Finley_noError()) {
292      int chunkSize = numNodes / mpi_info->size + 1, totalNodes=0, chunkNodes=0, nextCPU=1, mpi_error;      /* Each CPU will get at most chunkSize nodes so the message has to be sufficiently large */
293      int *tempInts = TMPMEMALLOC(numNodes*3+1, index_t);      int chunkSize = numNodes / mpi_info->size + 1, totalNodes=0, chunkNodes=0, chunkEle=0, nextCPU=1;
294      double *tempCoords = TMPMEMALLOC(numNodes*numDim, double);      int *tempInts = TMPMEMALLOC(chunkSize*3+1, index_t);        /* Stores the integer message data */
295        double *tempCoords = TMPMEMALLOC(chunkSize*numDim, double); /* Stores the double message data */
296    
297      /*      /*
298        Read a chunk of nodes, send to worker CPU if necessary, copy chunk into local mesh_p        Read chunkSize nodes, send it in a chunk to worker CPU which copies chunk into its local mesh_p
299        It doesn't matter that a CPU has the wrong nodes, this is sorted out later        It doesn't matter that a CPU has the wrong nodes for its elements, this is sorted out later
300        First chunk sent to CPU 1, second to CPU 2, ...        First chunk sent to CPU 1, second to CPU 2, ...
301        Last chunk stays on CPU 0 (the master)        Last chunk stays on CPU 0 (the master)
302        The three columns of integers (Id, gDOF, Tag) are gathered into a single array tempInts and sent together in a single MPI message        The three columns of integers (Id, gDOF, Tag) are gathered into a single array tempInts and sent together in a single MPI message
# Line 305  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 304  Finley_Mesh* Finley_Mesh_read_MPI(char*
304    
305      if (mpi_info->rank == 0) {  /* Master */      if (mpi_info->rank == 0) {  /* Master */
306        for (;;) {            /* Infinite loop */        for (;;) {            /* Infinite loop */
307            for (i0=0; i0<chunkSize*3+1; i0++) tempInts[i0] = -1;
308            for (i0=0; i0<chunkSize*numDim; i0++) tempCoords[i0] = -1.0;
309          chunkNodes = 0;          chunkNodes = 0;
         for (i0=0; i0<numNodes*3; i0++) tempInts[i0] = -1;  
         for (i0=0; i0<numNodes*numDim; i0++) tempCoords[i0] = -1.0;  
310          for (i1=0; i1<chunkSize; i1++) {          for (i1=0; i1<chunkSize; i1++) {
311            if (totalNodes >= numNodes) break;            if (totalNodes >= numNodes) break;    /* Maybe end the infinite loop */
312                if (1 == numDim)                if (1 == numDim)
313          fscanf(fileHandle_p, "%d %d %d %le\n",          fscanf(fileHandle_p, "%d %d %d %le\n",
314            &tempInts[0+i1], &tempInts[numNodes+i1], &tempInts[numNodes*2+i1],            &tempInts[0+i1], &tempInts[chunkSize+i1], &tempInts[chunkSize*2+i1],
315            &tempCoords[i1*numDim+0]);            &tempCoords[i1*numDim+0]);
316                if (2 == numDim)                if (2 == numDim)
317          fscanf(fileHandle_p, "%d %d %d %le %le\n",          fscanf(fileHandle_p, "%d %d %d %le %le\n",
318            &tempInts[0+i1], &tempInts[numNodes+i1], &tempInts[numNodes*2+i1],            &tempInts[0+i1], &tempInts[chunkSize+i1], &tempInts[chunkSize*2+i1],
319            &tempCoords[i1*numDim+0], &tempCoords[i1*numDim+1]);            &tempCoords[i1*numDim+0], &tempCoords[i1*numDim+1]);
320                if (3 == numDim)                if (3 == numDim)
321          fscanf(fileHandle_p, "%d %d %d %le %le %le\n",          fscanf(fileHandle_p, "%d %d %d %le %le %le\n",
322            &tempInts[0+i1], &tempInts[numNodes+i1], &tempInts[numNodes*2+i1],            &tempInts[0+i1], &tempInts[chunkSize+i1], &tempInts[chunkSize*2+i1],
323            &tempCoords[i1*numDim+0], &tempCoords[i1*numDim+1], &tempCoords[i1*numDim+2]);            &tempCoords[i1*numDim+0], &tempCoords[i1*numDim+1], &tempCoords[i1*numDim+2]);
324            totalNodes++;            totalNodes++; /* When do we quit the infinite loop? */
325            chunkNodes++;            chunkNodes++; /* How many nodes do we actually have in this chunk? It may be smaller than chunkSize. */
326            }
327            if (chunkNodes > chunkSize) {
328                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: error reading chunks of mesh, data too large for message size");
329                  return NULL;
330          }          }
         /* Eventually we'll send chunk of nodes to each CPU numbered 1 ... mpi_info->size-1, here goes one of them */  
         if (nextCPU < mpi_info->size) {  
331  #ifdef PASO_MPI  #ifdef PASO_MPI
332            tempInts[numNodes*3] = chunkNodes;          /* Eventually we'll send chunkSize nodes to each CPU numbered 1 ... mpi_info->size-1, here goes one of them */
333            mpi_error = MPI_Send(tempInts, numNodes*3+1, MPI_INT, nextCPU, 8727, mpi_info->comm);          if (nextCPU < mpi_info->size) {
334                  int mpi_error;
335              tempInts[chunkSize*3] = chunkNodes;   /* The message has one more int to send chunkNodes */
336              mpi_error = MPI_Send(tempInts, chunkSize*3+1, MPI_INT, nextCPU, 81720, mpi_info->comm);
337            if ( mpi_error != MPI_SUCCESS ) {            if ( mpi_error != MPI_SUCCESS ) {
338                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: send of tempInts failed");                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: send of tempInts failed");
339                  return NULL;                  return NULL;
340            }            }
341            mpi_error = MPI_Send(tempCoords, numNodes*numDim, MPI_DOUBLE, nextCPU, 8728, mpi_info->comm);            mpi_error = MPI_Send(tempCoords, chunkSize*numDim, MPI_DOUBLE, nextCPU, 81721, mpi_info->comm);
342            if ( mpi_error != MPI_SUCCESS ) {            if ( mpi_error != MPI_SUCCESS ) {
343                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: send of tempCoords failed");                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: send of tempCoords failed");
344                  return NULL;                  return NULL;
345            }            }
 #endif  
346            nextCPU++;            nextCPU++;
347          }          }
348          if (totalNodes >= numNodes) break;  #endif
349            if (totalNodes >= numNodes) break;  /* Maybe end the infinite loop */
350        } /* Infinite loop */        } /* Infinite loop */
351      }   /* End master */      }   /* End master */
352      else {  /* Worker */      else {  /* Worker */
353  #ifdef PASO_MPI  #ifdef PASO_MPI
354        /* Each worker receives two messages */        /* Each worker receives two messages */
355        MPI_Status status;        MPI_Status status;
356        mpi_error = MPI_Recv(tempInts, numNodes*3+1, MPI_INT, 0, 8727, mpi_info->comm, &status);            int mpi_error;
357          mpi_error = MPI_Recv(tempInts, chunkSize*3+1, MPI_INT, 0, 81720, mpi_info->comm, &status);
358        if ( mpi_error != MPI_SUCCESS ) {        if ( mpi_error != MPI_SUCCESS ) {
359              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: receive of tempInts failed");              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: receive of tempInts failed");
360              return NULL;              return NULL;
361        }        }
362        mpi_error = MPI_Recv(tempCoords, numNodes*numDim, MPI_DOUBLE, 0, 8728, mpi_info->comm, &status);        mpi_error = MPI_Recv(tempCoords, chunkSize*numDim, MPI_DOUBLE, 0, 81721, mpi_info->comm, &status);
363        if ( mpi_error != MPI_SUCCESS ) {        if ( mpi_error != MPI_SUCCESS ) {
364              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: receive of tempCoords failed");              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: receive of tempCoords failed");
365              return NULL;              return NULL;
366        }        }
367        chunkNodes = tempInts[numNodes*3];        chunkNodes = tempInts[chunkSize*3];   /* How many nodes are in this workers chunk? */
368  #endif  #endif
369      }   /* Worker */      }   /* Worker */
370  printf("ksteube CPU=%d/%d name='%s' numDim=%d numNodes=%d chunkNodes=%d\n", mpi_info->rank, mpi_info->size, name, numDim, numNodes, chunkNodes);  
371  #if 0  #if 0
372          printf("ksteube tempInts totalNodes=%d:\n", totalNodes);          /* Display the temp mem for debugging */
373          for (i0=0; i0<numNodes*3; i0++) {          printf("ksteube Nodes tempInts\n");
374            for (i0=0; i0<chunkSize*3; i0++) {
375            printf(" %2d", tempInts[i0]);            printf(" %2d", tempInts[i0]);
376            if (i0%numNodes==numNodes-1) printf("\n");            if (i0%chunkSize==chunkSize-1) printf("\n");
377          }          }
378          printf("ksteube tempCoords:\n");          printf("ksteube tempCoords:\n");
379          for (i0=0; i0<chunkNodes*numDim; i0++) {          for (i0=0; i0<chunkSize*numDim; i0++) {
380            printf(" %20.15e", tempCoords[i0]);            printf(" %20.15e", tempCoords[i0]);
381            if (i0%numDim==numDim-1) printf("\n");            if (i0%numDim==numDim-1) printf("\n");
382          }          }
383                printf("ksteube numDim=%d numNodes=%d mesh name='%s' chunkNodes=%d numNodes=%d\n", numDim, numNodes, name, chunkNodes, numNodes);
384  #endif  #endif
385    
386      /* Copy tempMem into mesh_p */      /* Copy node data from tempMem to mesh_p */
387          Finley_NodeFile_allocTable(mesh_p->Nodes, numNodes);          Finley_NodeFile_allocTable(mesh_p->Nodes, chunkNodes);
388      for (i0=0; i0<numNodes; i0++) {          if (Finley_noError()) {
389        mesh_p->Nodes->Id[i0]                 = tempInts[0+i0];        for (i0=0; i0<chunkNodes; i0++) {
390        mesh_p->Nodes->globalDegreesOfFreedom[i0]     = tempInts[numNodes+i0];          mesh_p->Nodes->Id[i0]               = tempInts[0+i0];
391        mesh_p->Nodes->Tag[i0]                = tempInts[numNodes*2+i0];          mesh_p->Nodes->globalDegreesOfFreedom[i0]       = tempInts[chunkSize+i0];
392        for (i1=0; i1<numDim; i1++) {          mesh_p->Nodes->Tag[i0]              = tempInts[chunkSize*2+i0];
393          mesh_p->Nodes->Coordinates[INDEX2(i1,i0,numDim)]    = tempCoords[i0*numDim+i1];          for (i1=0; i1<numDim; i1++) {
394        }            mesh_p->Nodes->Coordinates[INDEX2(i1,i0,numDim)]  = tempCoords[i0*numDim+i1];
395            }
396              }
397          }          }
398    
399      TMPMEMFREE(tempInts);      TMPMEMFREE(tempInts);
400      TMPMEMFREE(tempCoords);      TMPMEMFREE(tempCoords);
401    
         return mesh_p; /* ksteube temp for debugging */  
   
402          /* read elements */          /* read elements */
403    
404        /* Read the element typeID */
405          if (Finley_noError()) {          if (Finley_noError()) {
406            if (mpi_info->rank == 0) {
407             fscanf(fileHandle_p, "%s %d\n", element_type, &numEle);              fscanf(fileHandle_p, "%s %d\n", element_type, &numEle);
408             typeID=Finley_RefElement_getTypeId(element_type);              typeID=Finley_RefElement_getTypeId(element_type);
409             if (typeID==NoType) {        }
410               sprintf(error_msg,"Finley_Mesh_read :Unidentified element type %s",element_type);  #ifdef PASO_MPI
411               Finley_setError(VALUE_ERROR,error_msg);        if (mpi_info->size > 1) {
412             } else {          int temp1[2], mpi_error;
413               /* read the elements */          temp1[0] = (int) typeID;
414               mesh_p->Elements=Finley_ElementFile_alloc(typeID,mesh_p->order, mesh_p->reduced_order, mpi_info);          temp1[1] = numEle;
415               if (Finley_noError()) {          mpi_error = MPI_Bcast (temp1, 2, MPI_INT,  0, mpi_info->comm);
416                   Finley_ElementFile_allocTable(mesh_p->Elements, numEle);          if (mpi_error != MPI_SUCCESS) {
417                   mesh_p->Elements->minColor=0;            Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: broadcast of Element typeID failed");
418                   mesh_p->Elements->maxColor=numEle-1;            return NULL;
419                   if (Finley_noError()) {          }
420                      for (i0 = 0; i0 < numEle; i0++) {          typeID = (ElementTypeId) temp1[0];
421                        fscanf(fileHandle_p, "%d %d", &mesh_p->Elements->Id[i0], &mesh_p->Elements->Tag[i0]);          numEle = temp1[1];
422                        mesh_p->Elements->Color[i0]=i0;        }
423                        for (i1 = 0; i1 < mesh_p->Elements->ReferenceElement->Type->numNodes; i1++) {  #endif
424                             fscanf(fileHandle_p, " %d",            if (typeID==NoType) {
425                                &mesh_p->Elements->Nodes[INDEX2(i1, i0, mesh_p->Elements->ReferenceElement->Type->numNodes)]);              sprintf(error_msg, "Finley_Mesh_read: Unidentified element type %s", element_type);
426                        } /* for i1 */              Finley_setError(VALUE_ERROR, error_msg);
                       fscanf(fileHandle_p, "\n");  
                     } /* for i0 */  
                  }  
              }  
427            }            }
428          }      }
429          /* get the face elements */  
430          if (Finley_noError()) {        /* Read the element data */
431               fscanf(fileHandle_p, "%s %d\n", element_type, &numEle);        mesh_p->Elements=Finley_ElementFile_alloc(typeID,mesh_p->order, mesh_p->reduced_order, mpi_info);
432               faceTypeID=Finley_RefElement_getTypeId(element_type);        numNodes = mesh_p->Elements->ReferenceElement->Type->numNodes; /* New meaning for numNodes: num nodes per element */
433               if (faceTypeID==NoType) {  
434                 sprintf(error_msg,"Finley_Mesh_read :Unidentified element type %s for face elements",element_type);        if (Finley_noError()) {
435                 Finley_setError(VALUE_ERROR,error_msg);      int chunkSize = numEle / mpi_info->size + 1, totalEle=0, nextCPU=1;
436               } else {      int *tempInts = TMPMEMALLOC(chunkSize*(2+numNodes)+1, index_t); /* Store Id + Tag + node list (+ one int at end for chunkEle) */
437                  mesh_p->FaceElements=Finley_ElementFile_alloc(faceTypeID,mesh_p->order, mesh_p->reduced_order, mpi_info);      /* Elements are specified as a list of integers...only need one message instead of two as with the nodes */
438                  if (Finley_noError()) {      if (mpi_info->rank == 0) {  /* Master */
439                     Finley_ElementFile_allocTable(mesh_p->FaceElements, numEle);        for (;;) {            /* Infinite loop */
440                     if (Finley_noError()) {          for (i0=0; i0<chunkSize*(2+numNodes)+1; i0++) tempInts[i0] = -1;
441                        mesh_p->FaceElements->minColor=0;          chunkEle = 0;
442                        mesh_p->FaceElements->maxColor=numEle-1;          for (i0=0; i0<chunkSize; i0++) {
443                        for (i0 = 0; i0 < numEle; i0++) {            if (totalEle >= numEle) break; /* End infinite loop */
444                          fscanf(fileHandle_p, "%d %d", &mesh_p->FaceElements->Id[i0], &mesh_p->FaceElements->Tag[i0]);            fscanf(fileHandle_p, "%d %d", &tempInts[i0*(2+numNodes)+0], &tempInts[i0*(2+numNodes)+1]);
445                          mesh_p->FaceElements->Color[i0]=i0;            for (i1 = 0; i1 < numNodes; i1++) fscanf(fileHandle_p, " %d", &tempInts[i0*(2+numNodes)+2+i1]);
446                          for (i1 = 0; i1 < mesh_p->FaceElements->ReferenceElement->Type->numNodes; i1++) {            fscanf(fileHandle_p, "\n");
447                               fscanf(fileHandle_p, " %d",            totalEle++;
448                                  &mesh_p->FaceElements->Nodes[INDEX2(i1, i0, mesh_p->FaceElements->ReferenceElement->Type->numNodes)]);            chunkEle++;
449                          }   /* for i1 */          }
450                          fscanf(fileHandle_p, "\n");  #ifdef PASO_MPI
451                        } /* for i0 */          /* Eventually we'll send chunk of elements to each CPU except 0 itself, here goes one of them */
452                     }          if (nextCPU < mpi_info->size) {
453                  }                int mpi_error;
454               }            tempInts[chunkSize*(2+numNodes)] = chunkEle;
455          }            mpi_error = MPI_Send(tempInts, chunkSize*(2+numNodes)+1, MPI_INT, nextCPU, 81722, mpi_info->comm);
456          /* get the Contact face element */            if ( mpi_error != MPI_SUCCESS ) {
457          if (Finley_noError()) {                  Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: send of tempInts for Elements failed");
458               fscanf(fileHandle_p, "%s %d\n", element_type, &numEle);                  return NULL;
459               contactTypeID=Finley_RefElement_getTypeId(element_type);            }
460               if (contactTypeID==NoType) {            nextCPU++;
461                 sprintf(error_msg,"Finley_Mesh_read: Unidentified element type %s for contact elements",element_type);          }
462                 Finley_setError(VALUE_ERROR,error_msg);  #endif
463               } else {          if (totalEle >= numEle) break; /* End infinite loop */
464                 mesh_p->ContactElements=Finley_ElementFile_alloc(contactTypeID,mesh_p->order, mesh_p->reduced_order, mpi_info);        } /* Infinite loop */
465                 if (Finley_noError()) {      }   /* End master */
466                     Finley_ElementFile_allocTable(mesh_p->ContactElements, numEle);      else {  /* Worker */
467                     if (Finley_noError()) {  #ifdef PASO_MPI
468                        mesh_p->ContactElements->minColor=0;        /* Each worker receives one message */
469                        mesh_p->ContactElements->maxColor=numEle-1;        MPI_Status status;
470                        for (i0 = 0; i0 < numEle; i0++) {        int mpi_error;
471                          fscanf(fileHandle_p, "%d %d", &mesh_p->ContactElements->Id[i0], &mesh_p->ContactElements->Tag[i0]);        mpi_error = MPI_Recv(tempInts, chunkSize*(2+numNodes)+1, MPI_INT, 0, 81722, mpi_info->comm, &status);
472                          mesh_p->ContactElements->Color[i0]=i0;        if ( mpi_error != MPI_SUCCESS ) {
473                          for (i1 = 0; i1 < mesh_p->ContactElements->ReferenceElement->Type->numNodes; i1++) {              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: receive of tempInts for Elements failed");
474                              fscanf(fileHandle_p, " %d",              return NULL;
475                                 &mesh_p->ContactElements->Nodes[INDEX2(i1, i0, mesh_p->ContactElements->ReferenceElement->Type->numNodes)]);        }
476                          }   /* for i1 */        chunkEle = tempInts[chunkSize*(2+numNodes)];
477                          fscanf(fileHandle_p, "\n");  #endif
478                        } /* for i0 */      }   /* Worker */
479                    }  
480                 }  #if 0
481               }      /* Display the temp mem for debugging */
482          }        for (i0=0; i0<chunkSize*(numNodes+2); i0++) {
483          /* get the nodal element */        printf(" %2d", tempInts[i0]);
484          if (Finley_noError()) {        if (i0%(numNodes+2)==numNodes+2-1) printf("\n");
485               fscanf(fileHandle_p, "%s %d\n", element_type, &numEle);      }
486               pointTypeID=Finley_RefElement_getTypeId(element_type);  #endif
487               if (pointTypeID==NoType) {  
488                 sprintf(error_msg,"Finley_Mesh_read: Unidentified element type %s for points",element_type);      /* Copy Element data from tempInts to mesh_p */
489                 Finley_setError(VALUE_ERROR,error_msg);      Finley_ElementFile_allocTable(mesh_p->Elements, chunkEle);
490               }          mesh_p->Elements->minColor=0;
491               mesh_p->Points=Finley_ElementFile_alloc(pointTypeID,mesh_p->order, mesh_p->reduced_order, mpi_info);          mesh_p->Elements->maxColor=chunkEle-1;
              if (Finley_noError()) {  
                 Finley_ElementFile_allocTable(mesh_p->Points, numEle);  
                 if (Finley_noError()) {  
                    mesh_p->Points->minColor=0;  
                    mesh_p->Points->maxColor=numEle-1;  
                    for (i0 = 0; i0 < numEle; i0++) {  
                      fscanf(fileHandle_p, "%d %d", &mesh_p->Points->Id[i0], &mesh_p->Points->Tag[i0]);  
                      mesh_p->Points->Color[i0]=i0;  
                      for (i1 = 0; i1 < mesh_p->Points->ReferenceElement->Type->numNodes; i1++) {  
                          fscanf(fileHandle_p, " %d",  
                             &mesh_p->Points->Nodes[INDEX2(i1, i0, mesh_p->Points->ReferenceElement->Type->numNodes)]);  
                      }  /* for i1 */  
                      fscanf(fileHandle_p, "\n");  
                    } /* for i0 */  
                 }  
              }  
         }  
         /* get the name tags */  
492          if (Finley_noError()) {          if (Finley_noError()) {
493             if (feof(fileHandle_p) == 0) {            #pragma omp parallel for private (i0, i1)
494                fscanf(fileHandle_p, "%s\n", name);        for (i0=0; i0<chunkEle; i0++) {
495                while (feof(fileHandle_p) == 0) {          mesh_p->Elements->Id[i0]    = tempInts[i0*(2+numNodes)+0];
496                     fscanf(fileHandle_p, "%s %d\n", name, &tag_key);          mesh_p->Elements->Tag[i0]   = tempInts[i0*(2+numNodes)+1];
497                     Finley_Mesh_addTagMap(mesh_p,name,tag_key);              mesh_p->Elements->Color[i0] = i0;
498                }          for (i1 = 0; i1 < numNodes; i1++) {
499             }            mesh_p->Elements->Nodes[INDEX2(i1, i0, numNodes)] = tempInts[i0*(2+numNodes)+2+i1];
500            }
501              }
502          }          }
503    
504        TMPMEMFREE(tempInts);
505          }
506       }       }
507    
508       /* close file */       /* close file */
509       fclose(fileHandle_p);       if (mpi_info->rank == 0) fclose(fileHandle_p);
510      
511       /*   resolve id's : */       /*   resolve id's : */
512       /* rearrange elements: */       /* rearrange elements: */
513      
514         return mesh_p; /* ksteube temp return for debugging */
515    
516       if (Finley_noError()) Finley_Mesh_resolveNodeIds(mesh_p);       if (Finley_noError()) Finley_Mesh_resolveNodeIds(mesh_p);
517       if (Finley_noError()) Finley_Mesh_prepare(mesh_p, optimize);       if (Finley_noError()) Finley_Mesh_prepare(mesh_p, optimize);
518      
519       /* that's it */       /* that's it */
520       #ifdef Finley_TRACE       #ifdef Finley_TRACE
521       printf("timing: reading mesh: %.4e sec\n",Finley_timer()-time0);       printf("timing: reading mesh: %.4e sec\n",Finley_timer()-time0);

Legend:
Removed from v.1387  
changed lines
  Added in v.1725

  ViewVC Help
Powered by ViewVC 1.1.26