/[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 782 - (hide annotations)
Tue Jul 18 00:47:47 2006 UTC (13 years, 1 month ago) by bcumming
File MIME type: text/plain
File size: 5976 byte(s)
Large number of changes to Finley for meshing in MPI.

- optimisation and neatening up of rectcanglular mesh generation code
- first and second order 1D, 2D and 3D rectangular meshes are now
  available in finley and escript using MPI.
- reduced meshes now generated in MPI, and interpolation to and from 
  reduced data types now supported.  

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26