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

revision 1739 by gross, Fri Aug 29 06:19:53 2008 UTC revision 1771 by ksteube, Mon Sep 8 22:47:55 2008 UTC
# Line 19  Line 19 
19    
20  /**************************************************************/  /**************************************************************/
21    
22    #include <ctype.h>
23  #include "Mesh.h"  #include "Mesh.h"
24    
25  /**************************************************************/  /**************************************************************/
# Line 246  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 247  Finley_Mesh* Finley_Mesh_read_MPI(char*
247    double time0=Finley_timer();    double time0=Finley_timer();
248    FILE *fileHandle_p = NULL;    FILE *fileHandle_p = NULL;
249    ElementTypeId typeID, faceTypeID, contactTypeID, pointTypeID;    ElementTypeId typeID, faceTypeID, contactTypeID, pointTypeID;
250      Finley_TagMap* tag_map;
251    index_t tag_key;    index_t tag_key;
252    
253    Finley_resetError();    Finley_resetError();
# Line 789  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 791  Finley_Mesh* Finley_Mesh_read_MPI(char*
791      TMPMEMFREE(tempInts);      TMPMEMFREE(tempInts);
792        } /* end of Read the nodal element data */        } /* end of Read the nodal element data */
793    
794        /* ksteube TODO: read tags */        /* get the name tags */
795          if (Finley_noError()) {
796            char *remainder, *ptr;
797            int tag_key, len, error_code;
798            long cur_pos, end_pos;
799            if (mpi_info->rank == 0) {  /* Master */
800          /* Read the word 'Tag' */
801          if (! feof(fileHandle_p)) fscanf(fileHandle_p, "%s\n", name);
802          /* Read rest of file in one chunk, after using seek to find length */
803              cur_pos = ftell(fileHandle_p);
804              fseek(fileHandle_p, 0L, SEEK_END);
805              end_pos = ftell(fileHandle_p);
806              fseek(fileHandle_p, (long)cur_pos, SEEK_SET);
807          remainder = TMPMEMALLOC(end_pos-cur_pos+1, char);
808          if (! feof(fileHandle_p)) fread(remainder, (size_t) end_pos-cur_pos, sizeof(char), fileHandle_p);
809          remainder[end_pos-cur_pos] = 0;
810          len = strlen(remainder);    
811          while ((--len)>0 && isspace(remainder[len])) remainder[len]=0;
812          len = strlen(remainder);
813            }
814    #ifdef PASO_MPI
815            error_code = MPI_Bcast (&len, 1, MPI_INT,  0, mpi_info->comm);
816            if (error_code != MPI_SUCCESS) {
817              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: broadcast of tag len failed");
818              return NULL;
819            }
820        if (mpi_info->rank != 0) {
821          remainder = TMPMEMALLOC(len+1, char);
822          remainder[0] = 0;
823        }
824            error_code = MPI_Bcast (remainder, len+1, MPI_CHAR,  0, mpi_info->comm);
825            if (error_code != MPI_SUCCESS) {
826              Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: broadcast of tags failed");
827              return NULL;
828            }
829    #endif
830        if (remainder[0]) {
831              ptr = remainder;
832              do {
833                sscanf(ptr, "%s %d\n", name, &tag_key);
834                if (*name) Finley_Mesh_addTagMap(mesh_p,name,tag_key);
835                ptr++;
836              } while(NULL != (ptr = strchr(ptr, '\n')) && *ptr);
837              TMPMEMFREE(remainder);
838        }
839          }
840    
841       }       }
842    
# Line 799  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 846  Finley_Mesh* Finley_Mesh_read_MPI(char*
846       /*   resolve id's : */       /*   resolve id's : */
847       /* rearrange elements: */       /* rearrange elements: */
848    
      /* return mesh_p; */ /* ksteube temp return for debugging */  
   
849       if (Finley_noError()) Finley_Mesh_resolveNodeIds(mesh_p);       if (Finley_noError()) Finley_Mesh_resolveNodeIds(mesh_p);
850       if (Finley_noError()) Finley_Mesh_prepare(mesh_p, optimize);       if (Finley_noError()) Finley_Mesh_prepare(mesh_p, optimize);
851    

Legend:
Removed from v.1739  
changed lines
  Added in v.1771

  ViewVC Help
Powered by ViewVC 1.1.26