/[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 3086 by jfenwick, Thu Aug 5 05:07:58 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);    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 65  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 76  void  Finley_Mesh_resolveNodeIds(Finley_ Line 75  void  Finley_Mesh_resolveNodeIds(Finley_
75    /* allocate mappings for new local node labeling to global node labeling (newLocalToGlobalNodeLabels)    /* allocate mappings for new local node labeling to global node labeling (newLocalToGlobalNodeLabels)
76       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
77       new local id of global node i) */       new local id of global node i) */
78    len=max_id-min_id+1;    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 90  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           Dudley_Mesh_markNodes(globalToNewLocalNodeLabels,min_id,in,FALSE);
        Finley_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)
100         for (n=0;n<newNumNodes;n++) {         for (n=0;n<newNumNodes;n++) {
101  #ifdef BOUNDS_CHECK                #ifdef BOUNDS_CHECK
102         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); }
103         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); }
104  #endif                #endif
105                globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]]=n;                globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]]=n;
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 (Dudley_noError()) {
114                Dudley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);
115          }          }
116          if (Finley_noError())          if (Dudley_noError()) {
117              Finley_NodeFile_gather_global(newLocalToGlobalNodeLabels,in->Nodes, newNodeFile);             Dudley_NodeFile_free(in->Nodes);
         if (Finley_noError()) {  
            Finley_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.1739  
changed lines
  Added in v.3086

  ViewVC Help
Powered by ViewVC 1.1.26