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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (hide annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 4 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_resolveNodeIds.c
File MIME type: text/plain
File size: 5167 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 jgs 82 /**************************************************************/
2    
3     /* Finley: Mesh */
4    
5     /* at input the element nodes refers to the numbering defined the Id assigned to the nodes in the */
6     /* NodeFile. At the output, the numbering of the element nodes is between 0 and numNodes */
7     /* degreesOfFreedom are not neccessarily referening to a dense numbering */
8    
9     /**************************************************************/
10    
11     /* Copyrights by ACcESS Australia 2003 */
12     /* Author: gross@access.edu.au */
13     /* Version: $Id$ */
14    
15     /**************************************************************/
16    
17     #include "Finley.h"
18     #include "Mesh.h"
19 jgs 123 #include "Util.h"
20 jgs 82
21     /**************************************************************/
22    
23     void Finley_Mesh_resolveNodeIds(Finley_Mesh* in) {
24 jgs 123 dim_t k,len,numDim,newNumNodes,n;
25     index_t min_id,max_id,min_id2,max_id2,*maskNodes=NULL,*maskElements=NULL,*index=NULL;
26 jgs 82 Finley_NodeFile *newNodeFile=NULL;
27     Finley_ErrorCode=NO_ERROR;
28     numDim=Finley_Mesh_getDim(in);
29    
30     /* find the minimum and maximum id used: */
31    
32 jgs 123 min_id=INDEX_T_MAX;
33     max_id=-INDEX_T_MAX;
34 jgs 82 Finley_NodeFile_setIdRange(&min_id2,&max_id2,in->Nodes);
35 jgs 123 if (min_id2==INDEX_T_MAX || max_id2==-INDEX_T_MAX) {
36 jgs 82 Finley_ErrorCode=VALUE_ERROR;
37     sprintf(Finley_ErrorMsg,"Mesh has not been defined completely.");
38     goto clean;
39     }
40    
41     max_id=MAX(max_id,max_id2);
42     min_id=MIN(min_id,min_id2);
43     Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Elements);
44     max_id=MAX(max_id,max_id2);
45     min_id=MIN(min_id,min_id2);
46     Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->FaceElements);
47     max_id=MAX(max_id,max_id2);
48     min_id=MIN(min_id,min_id2);
49     Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->ContactElements);
50     max_id=MAX(max_id,max_id2);
51     min_id=MIN(min_id,min_id2);
52     Finley_ElementFile_setNodeRange(&min_id2,&max_id2,in->Points);
53     max_id=MAX(max_id,max_id2);
54     min_id=MIN(min_id,min_id2);
55     #ifdef Finley_TRACE
56     printf("Node id range is %d:%d\n",min_id,max_id);
57     #endif
58    
59     /* allocate a new node file used to gather existing node file: */
60    
61     len=max_id-min_id+1;
62     newNodeFile=Finley_NodeFile_alloc(numDim);
63     if (Finley_ErrorCode!=NO_ERROR) goto clean;
64    
65 jgs 123 maskNodes=TMPMEMALLOC(len,index_t);
66 jgs 82 if (Finley_checkPtr(maskNodes)) goto clean;
67    
68 jgs 123 maskElements=TMPMEMALLOC(len,index_t);
69 jgs 82 if (Finley_checkPtr(maskElements)) goto clean;
70    
71 jgs 123 index=TMPMEMALLOC(in->Nodes->numNodes,index_t);
72 jgs 82 if (Finley_checkPtr(maskElements)) goto clean;
73    
74     Finley_NodeFile_allocTable(newNodeFile,len);
75     if (Finley_ErrorCode!=NO_ERROR) goto clean;
76    
77     #pragma omp parallel for private(n) schedule(static)
78     for (n=0;n<in->Nodes->numNodes;n++) index[n]=-1;
79     #pragma omp parallel for private(n) schedule(static)
80     for (n=0;n<len;n++) {
81     maskNodes[n]=-1;
82     maskElements[n]=-1;
83     }
84     /* mark the nodes referred by elements in maskElements: */
85    
86     Finley_Mesh_markNodes(maskElements,min_id,in,FALSE);
87    
88     /* mark defined nodes */
89    
90     #pragma omp parallel for private(k) schedule(static)
91     for (k=0;k<in->Nodes->numNodes;k++) maskNodes[in->Nodes->Id[k]-min_id]=1;
92    
93     /* check if all referenced nodes are actually defined: */
94    
95     #pragma omp parallel for private(k) schedule(static)
96     for (k=0;k<len;k++) {
97     /* if a node is refered by an element is there a node defined ?*/
98     if (maskElements[k]>=0 && maskNodes[k]<0) {
99     Finley_ErrorCode=VALUE_ERROR;
100     sprintf(Finley_ErrorMsg,"Node id %d is referenced by element but is not defined.",k+min_id);
101     }
102     }
103    
104     if (Finley_ErrorCode==NO_ERROR) {
105    
106     /* scatter the nodefile in->nodes into newNodeFile using index; */
107     #pragma omp parallel for private(k) schedule(static)
108     for (k=0;k<in->Nodes->numNodes;k++) index[k]=in->Nodes->Id[k]-min_id;
109     Finley_NodeFile_scatter(index,in->Nodes,newNodeFile);
110    
111     /* relable used nodes: */
112     /* index maps the new node labeling onto the old one */
113     newNumNodes=Finley_Util_packMask(len,maskElements,index);
114     #pragma omp parallel for private(k) schedule(static)
115     for (k=0;k<newNumNodes;k++) maskElements[index[k]]=k;
116    
117     /* create a new table of nodes: */
118     Finley_NodeFile_deallocTable(in->Nodes);
119     Finley_NodeFile_allocTable(in->Nodes,newNumNodes);
120     if (Finley_ErrorCode!=NO_ERROR) goto clean;
121    
122     /* gather the new nodefile into in->Nodes */
123     Finley_NodeFile_gather(index,newNodeFile,in->Nodes);
124    
125     /* relable nodes of the elements: */
126     Finley_Mesh_relableElementNodes(maskElements,min_id,in);
127    
128     }
129    
130     /* clean-up: */
131    
132     clean: TMPMEMFREE(maskNodes);
133     TMPMEMFREE(maskElements);
134     TMPMEMFREE(index);
135     Finley_NodeFile_deallocTable(newNodeFile);
136     Finley_NodeFile_dealloc(newNodeFile);
137     }
138    
139     /*
140     * $Log$
141 jgs 123 * Revision 1.5 2005/07/08 04:07:54 jgs
142     * Merge of development branch back to main trunk on 2005-07-08
143     *
144 jgs 102 * Revision 1.4 2004/12/15 07:08:33 jgs
145 jgs 97 * *** empty log message ***
146 jgs 123 * Revision 1.1.1.1.2.2 2005/06/29 02:34:53 gross
147     * some changes towards 64 integers in finley
148 jgs 82 *
149 jgs 123 * Revision 1.1.1.1.2.1 2004/11/24 01:37:14 gross
150     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
151 jgs 97 *
152 jgs 82 *
153 jgs 123 *
154 jgs 82 */
155    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26