/[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 3086 by jfenwick, Thu Aug 5 05:07:58 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);    Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Elements);
46    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
47    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
48    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->FaceElements);    Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->FaceElements);
49    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
50    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
51    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->ContactElements);    Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->ContactElements);
52    max_id=MAX(max_id,max_id2);    max_id=MAX(max_id,max_id2);
53    min_id=MIN(min_id,min_id2);    min_id=MIN(min_id,min_id2);
54    Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Points);    Dudley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Points);
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    #ifdef PASO_MPI    #ifdef PASO_MPI
# Line 64  void  Finley_Mesh_resolveNodeIds(Finley_ Line 64  void  Finley_Mesh_resolveNodeIds(Finley_
64       global_min_id=min_id;       global_min_id=min_id;
65       global_max_id=max_id;       global_max_id=max_id;
66    #endif    #endif
67    #ifdef Finley_TRACE    #ifdef Dudley_TRACE
68    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);
69    #endif    #endif
70    if (min_id>max_id) {    if (min_id>max_id) {
# Line 78  void  Finley_Mesh_resolveNodeIds(Finley_ Line 78  void  Finley_Mesh_resolveNodeIds(Finley_
78    len=(max_id>=min_id) ? max_id-min_id+1 : 0 ;    len=(max_id>=min_id) ? max_id-min_id+1 : 0 ;
79    globalToNewLocalNodeLabels=TMPMEMALLOC(len,index_t); /* local mask for used nodes */    globalToNewLocalNodeLabels=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
80    newLocalToGlobalNodeLabels=TMPMEMALLOC(len,index_t);    newLocalToGlobalNodeLabels=TMPMEMALLOC(len,index_t);
81    if (! ( (Finley_checkPtr(globalToNewLocalNodeLabels) && Finley_checkPtr(newLocalToGlobalNodeLabels) ) ) ) {    if (! ( (Dudley_checkPtr(globalToNewLocalNodeLabels) && Dudley_checkPtr(newLocalToGlobalNodeLabels) ) ) ) {
82    
83         #pragma omp parallel         #pragma omp parallel
84         {         {
# Line 89  void  Finley_Mesh_resolveNodeIds(Finley_ Line 89  void  Finley_Mesh_resolveNodeIds(Finley_
89         }         }
90    
91         /*  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: */
92         Finley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);         Dudley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);
93    
94         /* 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*/
95    
96         newNumNodes=Finley_Util_packMask(len,globalToNewLocalNodeLabels,newLocalToGlobalNodeLabels);         newNumNodes=Dudley_Util_packMask(len,globalToNewLocalNodeLabels,newLocalToGlobalNodeLabels);
97    
98         /* 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 */
99         #pragma omp parallel for private(n) schedule(static)         #pragma omp parallel for private(n) schedule(static)
# Line 106  void  Finley_Mesh_resolveNodeIds(Finley_ Line 106  void  Finley_Mesh_resolveNodeIds(Finley_
106                newLocalToGlobalNodeLabels[n]+=min_id;                newLocalToGlobalNodeLabels[n]+=min_id;
107          }          }
108          /* create a new table */          /* create a new table */
109          newNodeFile=Finley_NodeFile_alloc(numDim,in->MPIInfo);          newNodeFile=Dudley_NodeFile_alloc(numDim,in->MPIInfo);
110          if (Finley_noError()) {          if (Dudley_noError()) {
111             Finley_NodeFile_allocTable(newNodeFile,newNumNodes);             Dudley_NodeFile_allocTable(newNodeFile,newNumNodes);
112          }          }
113          if (Finley_noError()) {          if (Dudley_noError()) {
114              Finley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);              Dudley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);
115          }          }
116          if (Finley_noError()) {          if (Dudley_noError()) {
117             Finley_NodeFile_free(in->Nodes);             Dudley_NodeFile_free(in->Nodes);
118             in->Nodes=newNodeFile;             in->Nodes=newNodeFile;
119             /*  relable nodes of the elements: */             /*  relable nodes of the elements: */
120             Finley_Mesh_relableElementNodes(globalToNewLocalNodeLabels,min_id,in);             Dudley_Mesh_relableElementNodes(globalToNewLocalNodeLabels,min_id,in);
121          }          }
122    }    }
123    TMPMEMFREE(globalToNewLocalNodeLabels);    TMPMEMFREE(globalToNewLocalNodeLabels);
124    TMPMEMFREE(newLocalToGlobalNodeLabels);    TMPMEMFREE(newLocalToGlobalNodeLabels);
125    if (! Finley_noError()) {    if (! Dudley_noError()) {
126         Finley_NodeFile_free(newNodeFile);         Dudley_NodeFile_free(newNodeFile);
127    }    }
128  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26