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

trunk/finley/src/Mesh_resolveNodeIds.c revision 1739 by gross, Fri Aug 29 06:19:53 2008 UTC branches/domexper/dudley/src/Mesh_resolveNodeIds.c revision 3114 by jfenwick, Fri Aug 27 05:26:25 2010 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2010 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
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 30  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 65  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 76  void  Finley_Mesh_resolveNodeIds(Finley_ Line 78  void  Finley_Mesh_resolveNodeIds(Finley_
78    /* allocate mappings for new local node labeling to global node labeling (newLocalToGlobalNodeLabels)    /* allocate mappings for new local node labeling to global node labeling (newLocalToGlobalNodeLabels)
79       and global node labeling to the new local node labeling (globalToNewLocalNodeLabels[i-min_id] is the       and global node labeling to the new local node labeling (globalToNewLocalNodeLabels[i-min_id] is the
80       new local id of global node i) */       new local id of global node i) */
81    len=max_id-min_id+1;    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 90  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           Dudley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);
        Finley_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)
103         for (n=0;n<newNumNodes;n++) {         for (n=0;n<newNumNodes;n++) {
104  #ifdef BOUNDS_CHECK                #ifdef BOUNDS_CHECK
105         if (n >= len || n < 0) { printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n); exit(1); }                       if (n >= len || n < 0) { printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n); exit(1); }
106         if (newLocalToGlobalNodeLabels[n] >= len || newLocalToGlobalNodeLabels[n] < 0) { printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n); exit(1); }                       if (newLocalToGlobalNodeLabels[n] >= len || newLocalToGlobalNodeLabels[n] < 0) { printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n); exit(1); }
107  #endif                #endif
108                globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]]=n;                globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]]=n;
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 (Dudley_noError()) {
117                Dudley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);
118          }          }
119          if (Finley_noError())          if (Dudley_noError()) {
120              Finley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);             Dudley_NodeFile_free(in->Nodes);
         if (Finley_noError()) {  
            Finley_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.1739  
changed lines
  Added in v.3114

  ViewVC Help
Powered by ViewVC 1.1.26