/[escript]/trunk/finley/src/Mesh_resolveNodeIds.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_resolveNodeIds.c

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

trunk/esys2/finley/src/finleyC/Mesh_resolveNodeIds.c revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/finley/src/Mesh_resolveNodeIds.c revision 730 by bcumming, Mon May 15 04:03:49 2006 UTC
# Line 1  Line 1 
1    /*
2     ************************************************************
3     *          Copyright 2006 by ACcESS MNRF                   *
4     *                                                          *
5     *              http://www.access.edu.au                    *
6     *       Primary Business: Queensland, Australia            *
7     *  Licensed under the Open Software License version 3.0    *
8     *     http://www.opensource.org/licenses/osl-3.0.php       *
9     *                                                          *
10     ************************************************************
11    */
12    
13  /**************************************************************/  /**************************************************************/
14    
15  /*   Finley: Mesh */  /*   Finley: Mesh */
# Line 8  Line 20 
20    
21  /**************************************************************/  /**************************************************************/
22    
 /*   Copyrights by ACcESS Australia 2003 */  
23  /*   Author: gross@access.edu.au */  /*   Author: gross@access.edu.au */
24  /*   Version: $Id$ */  /*   Version: $Id$ */
25    
26  /**************************************************************/  /**************************************************************/
27    
 #include "Finley.h"  
28  #include "Mesh.h"  #include "Mesh.h"
29    #include "Util.h"
30    
31  /**************************************************************/  /**************************************************************/
32    
33  void  Finley_Mesh_resolveNodeIds(Finley_Mesh* in) {  void  Finley_Mesh_resolveNodeIds(Finley_Mesh* in) {
34    maybelong k,min_id,max_id,min_id2,max_id2,len,numDim,newNumNodes,n;    char error_msg[LenErrorMsg_MAX];
35    maybelong *maskNodes=NULL,*maskElements=NULL,*index=NULL;    dim_t k,len,numDim,newNumNodes,n;
36      index_t min_id,max_id,min_id2,max_id2,*maskNodes=NULL,*maskElements=NULL,*index=NULL;
37    Finley_NodeFile *newNodeFile=NULL;    Finley_NodeFile *newNodeFile=NULL;
38    Finley_ErrorCode=NO_ERROR;    Finley_resetError();
39    numDim=Finley_Mesh_getDim(in);    numDim=Finley_Mesh_getDim(in);
40        
41    /*   find the minimum and maximum id used: */    /*   find the minimum and maximum id used: */
42        
43    min_id=MAYBELONG_MAX;    min_id=INDEX_T_MAX;
44    max_id=-MAYBELONG_MAX;    max_id=-INDEX_T_MAX;
45    Finley_NodeFile_setIdRange(&min_id2,&max_id2,in->Nodes);    Finley_NodeFile_setIdRange(&min_id2,&max_id2,in->Nodes);
46    if (min_id2==MAYBELONG_MAX || max_id2==-MAYBELONG_MAX) {    if (min_id2==INDEX_T_MAX || max_id2==-INDEX_T_MAX) {
47      Finley_ErrorCode=VALUE_ERROR;      Finley_setError(VALUE_ERROR,"__FILE__: Mesh has not been defined completely.");
     sprintf(Finley_ErrorMsg,"Mesh has not been defined completely.");  
48      goto clean;      goto clean;
49    }    }
50    
# Line 58  void  Finley_Mesh_resolveNodeIds(Finley_ Line 69  void  Finley_Mesh_resolveNodeIds(Finley_
69    /*  allocate a new node file used to gather existing node file: */    /*  allocate a new node file used to gather existing node file: */
70        
71    len=max_id-min_id+1;    len=max_id-min_id+1;
72    #ifndef PASO_MPI
73    newNodeFile=Finley_NodeFile_alloc(numDim);    newNodeFile=Finley_NodeFile_alloc(numDim);
74    if (Finley_ErrorCode!=NO_ERROR) goto clean;  #else
75      newNodeFile=Finley_NodeFile_alloc(numDim,in->MPIInfo);
76    #endif
77      if (! Finley_noError()) goto clean;
78    
79    maskNodes=(maybelong*)TMPMEMALLOC(len*sizeof(maybelong));    maskNodes=TMPMEMALLOC(len,index_t);
80    if (Finley_checkPtr(maskNodes)) goto clean;    if (Finley_checkPtr(maskNodes)) goto clean;
81    
82    maskElements=(maybelong*)TMPMEMALLOC(len*sizeof(maybelong));    maskElements=TMPMEMALLOC(len,index_t);
83    if (Finley_checkPtr(maskElements)) goto clean;    if (Finley_checkPtr(maskElements)) goto clean;
84    
85    index=(maybelong*)TMPMEMALLOC(in->Nodes->numNodes*sizeof(maybelong));    index=TMPMEMALLOC(in->Nodes->numNodes,index_t);
   if (Finley_checkPtr(maskElements)) goto clean;  
86    
87    Finley_NodeFile_allocTable(newNodeFile,len);    if (Finley_checkPtr(maskElements)) goto clean;
   if (Finley_ErrorCode!=NO_ERROR) goto clean;  
88    
89    #pragma omp parallel for private(n) schedule(static)    #pragma omp parallel for private(n) schedule(static)
90    for (n=0;n<in->Nodes->numNodes;n++) index[n]=-1;    for (n=0;n<in->Nodes->numNodes;n++) index[n]=-1;
# Line 95  void  Finley_Mesh_resolveNodeIds(Finley_ Line 108  void  Finley_Mesh_resolveNodeIds(Finley_
108    for (k=0;k<len;k++) {    for (k=0;k<len;k++) {
109       /* if a node is refered by an element is there a node defined ?*/       /* if a node is refered by an element is there a node defined ?*/
110       if (maskElements[k]>=0 && maskNodes[k]<0) {       if (maskElements[k]>=0 && maskNodes[k]<0) {
111         Finley_ErrorCode=VALUE_ERROR;         sprintf(error_msg,"__FILE__:Node id %d is referenced by element but is not defined.",k+min_id);
112         sprintf(Finley_ErrorMsg,"Node id %d is referenced by element but is not defined.",k+min_id);         Finley_setError(VALUE_ERROR,error_msg);
113       }       }
114    }    }
115    
116    if (Finley_ErrorCode==NO_ERROR) {    Finley_NodeFile_allocTable(newNodeFile,len);
117      if (! Finley_noError() ) goto clean;
118    
119      if (Finley_noError()) {
120        
121        /*  scatter the nodefile in->nodes into newNodeFile using index; */        /*  scatter the nodefile in->nodes into newNodeFile using index; */
122        #pragma omp parallel for private(k) schedule(static)        #pragma omp parallel for private(k) schedule(static)
123        for (k=0;k<in->Nodes->numNodes;k++) index[k]=in->Nodes->Id[k]-min_id;        for (k=0;k<in->Nodes->numNodes;k++)
124            index[k]=in->Nodes->Id[k]-min_id;
125        Finley_NodeFile_scatter(index,in->Nodes,newNodeFile);        Finley_NodeFile_scatter(index,in->Nodes,newNodeFile);
126      
127        /*  relable used nodes: */        /*  relable used nodes: */
128        /* index maps the new node labeling onto the old one */        /* index maps the new node labeling onto the old one */
129        newNumNodes=Finley_Util_packMask(len,maskElements,index);        newNumNodes=Finley_Util_packMask(len,maskElements,index);
# Line 116  void  Finley_Mesh_resolveNodeIds(Finley_ Line 133  void  Finley_Mesh_resolveNodeIds(Finley_
133        /*  create a new table of nodes: */        /*  create a new table of nodes: */
134        Finley_NodeFile_deallocTable(in->Nodes);        Finley_NodeFile_deallocTable(in->Nodes);
135        Finley_NodeFile_allocTable(in->Nodes,newNumNodes);        Finley_NodeFile_allocTable(in->Nodes,newNumNodes);
136        if (Finley_ErrorCode!=NO_ERROR) goto clean;  
137          if (! Finley_noError()) goto clean;
138    
139        /* gather the new nodefile into in->Nodes */        /* gather the new nodefile into in->Nodes */
140        Finley_NodeFile_gather(index,newNodeFile,in->Nodes);        Finley_NodeFile_gather(index,newNodeFile,in->Nodes);
# Line 137  void  Finley_Mesh_resolveNodeIds(Finley_ Line 155  void  Finley_Mesh_resolveNodeIds(Finley_
155    
156  /*  /*
157  * $Log$  * $Log$
158  * Revision 1.3  2004/12/15 03:48:45  jgs  * Revision 1.6  2005/09/15 03:44:23  jgs
159    * Merge of development branch dev-02 back to main trunk on 2005-09-15
160    *
161    * Revision 1.5.2.1  2005/09/07 06:26:20  gross
162    * the solver from finley are put into the standalone package paso now
163    *
164    * Revision 1.5  2005/07/08 04:07:54  jgs
165    * Merge of development branch back to main trunk on 2005-07-08
166    *
167    * Revision 1.4  2004/12/15 07:08:33  jgs
168  * *** empty log message ***  * *** empty log message ***
169    * Revision 1.1.1.1.2.2  2005/06/29 02:34:53  gross
170    * some changes towards 64 integers in finley
171  *  *
172  * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  * Revision 1.1.1.1.2.1  2004/11/24 01:37:14  gross
173  * initial import of project esys2  * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
174  *  *
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
175  *  *
176  *  *
177  */  */

Legend:
Removed from v.100  
changed lines
  Added in v.730

  ViewVC Help
Powered by ViewVC 1.1.26