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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (hide annotations)
Thu Sep 15 03:44:45 2005 UTC (14 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_resolveNodeIds.c
File MIME type: text/plain
File size: 6210 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-15

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26