/[escript]/branches/domexper/dudley/src/Mesh_resolveNodeIds.c
ViewVC logotype

Annotation of /branches/domexper/dudley/src/Mesh_resolveNodeIds.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (hide annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 11 months ago) by elspeth
Original Path: trunk/finley/src/Mesh_resolveNodeIds.c
File MIME type: text/plain
File size: 5888 byte(s)
Copyright added to more source files.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26