/[escript]/branches/domexper/dudley/src/Mesh_resolveNodeIds.c
ViewVC logotype

Diff of /branches/domexper/dudley/src/Mesh_resolveNodeIds.c

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

revision 3080 by jfenwick, Tue Aug 3 04:28:03 2010 UTC revision 3114 by jfenwick, Fri Aug 27 05:26:25 2010 UTC
# Line 14  Line 14 
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*   Finley: Mesh */  /*   Dudley: Mesh */
18    
19  /*   at input the element nodes refers to the numbering defined the global Id assigned to the nodes in the */  /*   at input the element nodes refers to the numbering defined the global Id assigned to the nodes in the */
20  /*   NodeFile. It is also not ensured that all nodes refered by an element is actually available */  /*   NodeFile. It is also not ensured that all nodes refered by an element is actually available */
# Line 29  Line 29 
29    
30  /**************************************************************/  /**************************************************************/
31    
32  void  Finley_Mesh_resolveNodeIds(Finley_Mesh* in) {  void  Dudley_Mesh_resolveNodeIds(Dudley_Mesh* in) {
33    
34    index_t min_id, max_id,  min_id2, max_id2, global_min_id, global_max_id,    index_t min_id, max_id,  min_id2, max_id2, global_min_id, global_max_id,
35            *globalToNewLocalNodeLabels=NULL, *newLocalToGlobalNodeLabels=NULL;            *globalToNewLocalNodeLabels=NULL, *newLocalToGlobalNodeLabels=NULL;
36    dim_t len, n, newNumNodes, numDim;    dim_t len, n, newNumNodes, numDim;
37    Finley_NodeFile *newNodeFile=NULL;    Dudley_NodeFile *newNodeFile=NULL;
38    #ifdef PASO_MPI    #ifdef PASO_MPI
39    index_t id_range[2], global_id_range[2];    index_t id_range[2], global_id_range[2];
40    #endif    #endif
41    numDim=Finley_Mesh_getDim(in);    numDim=Dudley_Mesh_getDim(in);
42    /*  find the minimum and maximum id used by elements: */    /*  find the minimum and maximum id used by elements: */
43    min_id=INDEX_T_MAX;    min_id=INDEX_T_MAX;
44    max_id=-INDEX_T_MAX;    max_id=-INDEX_T_MAX;
45    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Elements);  //printf("Trying Elements:\n");
46      Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Elements);
47    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
48    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
49    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->FaceElements);  //printf("Trying FaceElements:\n");
50      Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->FaceElements);
51    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
52    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
53    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->ContactElements);  //printf("Trying ContactElements:\n");
54      Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->ContactElements);
55    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
56    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
57    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Points);    Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Points);
58    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
59    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
60    #ifdef PASO_MPI    #ifdef PASO_MPI
# Line 64  void  Finley_Mesh_resolveNodeIds(Finley_ Line 67  void  Finley_Mesh_resolveNodeIds(Finley_
67       global_min_id=min_id;       global_min_id=min_id;
68       global_max_id=max_id;       global_max_id=max_id;
69    #endif    #endif
70    #ifdef Finley_TRACE    #ifdef Dudley_TRACE
71    printf("Node id range used by elements is %d:%d\n",global_min_id,global_max_id);    printf("Node id range used by elements is %d:%d\n",global_min_id,global_max_id);
72    #endif    #endif
73    if (min_id>max_id) {    if (min_id>max_id) {
# Line 78  void  Finley_Mesh_resolveNodeIds(Finley_ Line 81  void  Finley_Mesh_resolveNodeIds(Finley_
81    len=(max_id>=min_id) ? max_id-min_id+1 : 0 ;    len=(max_id>=min_id) ? max_id-min_id+1 : 0 ;
82    globalToNewLocalNodeLabels=TMPMEMALLOC(len,index_t); /* local mask for used nodes */    globalToNewLocalNodeLabels=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
83    newLocalToGlobalNodeLabels=TMPMEMALLOC(len,index_t);    newLocalToGlobalNodeLabels=TMPMEMALLOC(len,index_t);
84    if (! ( (Finley_checkPtr(globalToNewLocalNodeLabels) && Finley_checkPtr(newLocalToGlobalNodeLabels) ) ) ) {    if (! ( (Dudley_checkPtr(globalToNewLocalNodeLabels) && Dudley_checkPtr(newLocalToGlobalNodeLabels) ) ) ) {
85    
86         #pragma omp parallel         #pragma omp parallel
87         {         {
# Line 89  void  Finley_Mesh_resolveNodeIds(Finley_ Line 92  void  Finley_Mesh_resolveNodeIds(Finley_
92         }         }
93    
94         /*  mark the nodes referred by elements in globalToNewLocalNodeLabels which is currently used as a mask: */         /*  mark the nodes referred by elements in globalToNewLocalNodeLabels which is currently used as a mask: */
95         Finley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);         Dudley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);
96    
97         /* create a local labeling newLocalToGlobalNodeLabels of the local nodes by packing the mask globalToNewLocalNodeLabels*/         /* create a local labeling newLocalToGlobalNodeLabels of the local nodes by packing the mask globalToNewLocalNodeLabels*/
98    
99         newNumNodes=Finley_Util_packMask(len,globalToNewLocalNodeLabels,newLocalToGlobalNodeLabels);         newNumNodes=Dudley_Util_packMask(len,globalToNewLocalNodeLabels,newLocalToGlobalNodeLabels);
100    
101         /* invert the new labeling and shift the index newLocalToGlobalNodeLabels to global node ids */         /* invert the new labeling and shift the index newLocalToGlobalNodeLabels to global node ids */
102         #pragma omp parallel for private(n) schedule(static)         #pragma omp parallel for private(n) schedule(static)
# Line 106  void  Finley_Mesh_resolveNodeIds(Finley_ Line 109  void  Finley_Mesh_resolveNodeIds(Finley_
109                newLocalToGlobalNodeLabels[n]+=min_id;                newLocalToGlobalNodeLabels[n]+=min_id;
110          }          }
111          /* create a new table */          /* create a new table */
112          newNodeFile=Finley_NodeFile_alloc(numDim,in->MPIInfo);          newNodeFile=Dudley_NodeFile_alloc(numDim,in->MPIInfo);
113          if (Finley_noError()) {          if (Dudley_noError()) {
114             Finley_NodeFile_allocTable(newNodeFile,newNumNodes);             Dudley_NodeFile_allocTable(newNodeFile,newNumNodes);
115          }          }
116          if (Finley_noError()) {          if (Dudley_noError()) {
117              Finley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);              Dudley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);
118          }          }
119          if (Finley_noError()) {          if (Dudley_noError()) {
120             Finley_NodeFile_free(in->Nodes);             Dudley_NodeFile_free(in->Nodes);
121             in->Nodes=newNodeFile;             in->Nodes=newNodeFile;
122             /*  relable nodes of the elements: */             /*  relable nodes of the elements: */
123             Finley_Mesh_relableElementNodes(globalToNewLocalNodeLabels,min_id,in);             Dudley_Mesh_relableElementNodes(globalToNewLocalNodeLabels,min_id,in);
124          }          }
125    }    }
126    TMPMEMFREE(globalToNewLocalNodeLabels);    TMPMEMFREE(globalToNewLocalNodeLabels);
127    TMPMEMFREE(newLocalToGlobalNodeLabels);    TMPMEMFREE(newLocalToGlobalNodeLabels);
128    if (! Finley_noError()) {    if (! Dudley_noError()) {
129         Finley_NodeFile_free(newNodeFile);         Dudley_NodeFile_free(newNodeFile);
130    }    }
131  }  }

Legend:
Removed from v.3080  
changed lines
  Added in v.3114

  ViewVC Help
Powered by ViewVC 1.1.26