/[escript]/trunk-mpi-branch/finley/src/Mesh.c
ViewVC logotype

Contents of /trunk-mpi-branch/finley/src/Mesh.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (show annotations)
Thu Mar 8 06:31:28 2007 UTC (12 years, 5 months ago) by gross
File MIME type: text/plain
File size: 11767 byte(s)
MPI version compiles and starts to run now. 
Important:

   * the mpi library needs to be shared.
   * the path needs to be added to LD_LIBRARY path.

The program stucks in the matrix assemblage.


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 /**************************************************************/
16
17 /* Finley: Mesh */
18
19 /**************************************************************/
20
21 /* Author: gross@access.edu.au */
22 /* Version: $Id$ */
23
24 /**************************************************************/
25
26 #include "Mesh.h"
27
28 /**************************************************************/
29
30 /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
31 /* the most appropriate order is selected indepently. */
32
33 extern Finley_RefElementInfo Finley_RefElement_InfoList[];
34
35 #ifndef PASO_MPI
36 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order)
37 #else
38 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, Paso_MPIInfo *mpi_info)
39 #endif
40 {
41 Finley_Mesh *out;
42
43 /* allocate the return value */
44
45 out=MEMALLOC(1,Finley_Mesh);
46 if (Finley_checkPtr(out)) return NULL;
47 out->Name=NULL;
48 out->Nodes=NULL;
49 out->Elements=NULL;
50 out->FaceElements=NULL;
51 out->Points=NULL;
52 out->ContactElements=NULL;
53 out->reference_counter=0;
54
55 out->FullFullPattern=NULL;
56 out->FullReducedPattern=NULL;
57 out->ReducedFullPattern=NULL;
58 out->ReducedReducedPattern=NULL;
59
60 #ifdef PASO_MPI
61 out->MPIInfo = NULL;
62
63 /* get MPI info */
64 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
65 if (! Finley_noError()) {
66 Finley_Mesh_dealloc(out);
67 return NULL;
68 }
69 #endif
70 /* copy name: */
71
72 out->Name=MEMALLOC(strlen(name)+1,char);
73 if (Finley_checkPtr(out->Name)) {
74 Finley_Mesh_dealloc(out);
75 return NULL;
76 }
77 strcpy(out->Name,name);
78
79 /* allocate node table: */
80 #ifdef PASO_MPI
81 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
82 #else
83 out->Nodes=Finley_NodeFile_alloc(numDim);
84 #endif
85 if (! Finley_noError()) {
86 Finley_Mesh_dealloc(out);
87 return NULL;
88 }
89 out->order=order;
90 out->Elements=NULL;
91 out->FaceElements=NULL;
92 out->Points=NULL;
93 out->ContactElements=NULL;
94 out->reference_counter++;
95 return out;
96 }
97
98 /* returns a reference to Finley_Mesh in */
99
100 Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
101 if (in!=NULL) ++(in->reference_counter);
102 return in;
103 }
104
105 /* deallocates a mesh: */
106
107 void Finley_Mesh_dealloc(Finley_Mesh* in) {
108 if (in!=NULL) {
109 in->reference_counter--;
110 if (in->reference_counter<1) {
111 #ifdef Finley_TRACE
112 if (in->Name!=NULL) {
113 printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);
114 } else {
115 printf("Finley_Mesh_dealloc\n");
116 }
117 #endif
118 MEMFREE(in->Name);
119 Finley_NodeFile_dealloc(in->Nodes);
120 Finley_ElementFile_dealloc(in->Elements);
121 Finley_ElementFile_dealloc(in->FaceElements);
122 Finley_ElementFile_dealloc(in->ContactElements);
123 Finley_ElementFile_dealloc(in->Points);
124 Paso_SystemMatrixPattern_dealloc(in->FullFullPattern);
125 Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);
126 Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);
127 Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);
128 #ifdef PASO_MPI
129 Paso_MPIInfo_dealloc( in->MPIInfo );
130 #endif
131 MEMFREE(in);
132 }
133 }
134 }
135
136 /**************************************************************/
137
138 /* returns the spatial dimension of the mesh: */
139
140 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
141 return in->Nodes->numDim;
142 }
143
144 /**************************************************************/
145
146 /* returns the number of nodes in the mesh: */
147
148 dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {
149 return in->Nodes->numNodes;
150 }
151 /**************************************************************/
152
153 /* returns the number of degrees of freedom in the mesh: */
154
155 dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {
156 return in->Nodes->numDegreesOfFreedom;
157 }
158 /**************************************************************/
159
160 /* returns the number of degrees of freedom in the mesh: */
161
162 dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {
163 return in->Nodes->reducedNumDegreesOfFreedom;
164 }
165
166 #ifdef PASO_MPI
167 void print_mesh_statistics( Finley_Mesh *out, bool_t reduced )
168 {
169 index_t i, r, j, N, M, dim;
170 int *ref;
171 dim = out->Nodes->numDim;
172
173 if( !reduced ){
174 printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nFULL MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );
175 printf( "\nNodes\n========\n\n" );
176 printf( "\t%d internal DOF\n\t%d boundary DOF\n\t%d local DOF\n\t%d external DOF\n", out->Nodes->degreeOfFreedomDistribution->numInternal, out->Nodes->degreeOfFreedomDistribution->numBoundary, out->Nodes->degreeOfFreedomDistribution->numLocal, out->Nodes->degreeOfFreedomDistribution->numExternal);
177 for( i=0; i<out->Nodes->numNodes; i++ ){
178 printf( "node %d\t: id %d \tDOF %d \t: tag %d \t: Dom %d \t: coordinates [%3g", i, out->Nodes->Id[i], out->Nodes->degreeOfFreedom[i], out->Nodes->Tag[i], out->Nodes->Dom[i], out->Nodes->Coordinates[INDEX2(0,i,dim)] );
179 for( j=1; j<dim; j++ )
180 printf( ", %3g", out->Nodes->Coordinates[INDEX2(j,i,dim)]);
181 printf( " ]\n" );
182 }
183
184 printf( "Elements\n=========\n\n" );
185 printf( "\t%d internal\n\t%d boundary\n\t%d local\n", out->Elements->elementDistribution->numInternal, out->Elements->elementDistribution->numBoundary, out->Elements->elementDistribution->numLocal );
186 N = out->Elements->ReferenceElement->Type->numNodes;
187 for( i=0; i<out->Elements->numElements; i++ ){
188 printf( "element %d \t: id %d \t: dom %d \t: nodes [ %2d", i, out->Elements->Id[i], out->Elements->Dom[i], out->Elements->Nodes[INDEX2(0,i,N)] );
189 for( j=1; j<N; j++ )
190 printf( ", %2d", out->Elements->Nodes[INDEX2(j,i,N)]);
191 printf( " ] -> " );
192 if( N>8 )
193 printf( "\n\t\t\t\t\t\t" );
194 printf( ": DOF [ %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(0,i,N)]] );
195 for( j=1; j<N; j++ )
196 printf( ", %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(j,i,N)]]);
197 printf( " ]\n" );
198 }
199
200 printf( "\nFace Elements\n==========\n\n" );
201 printf( "\t%d internal\n\t%d boundary\n\t%d local\n", out->FaceElements->elementDistribution->numInternal, out->FaceElements->elementDistribution->numBoundary, out->FaceElements->elementDistribution->numLocal );
202 N = out->FaceElements->ReferenceElement->Type->numNodes;
203 for( i=0; i<out->FaceElements->numElements; i++ ){
204 printf( "face element %d \t: id %d \t: dom %d \t: nodes [ %2d", i, out->FaceElements->Id[i], out->FaceElements->Dom[i], out->FaceElements->Nodes[INDEX2(0,i,N)] );
205 for( j=1; j<N; j++ )
206 printf( ", %2d", out->FaceElements->Nodes[INDEX2(j,i,N)] );
207 printf( " ] -> " );
208 if( N>8 )
209 printf( "\n\t\t\t\t\t\t" );
210 printf( ": DOF [ %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(0,i,N)]]);
211 for( j=1; j<N; j++ )
212 printf( ", %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,N)]]);
213 printf( " ]\n" );
214 }
215 printf( "\nDistribution Data\n==========\n\n" );
216 Finley_NodeDistribution_print( out->Nodes->degreeOfFreedomDistribution, stdout );
217 }
218 else{
219 printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nREDUCED MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );
220 printf( "\nNodes\n========\n\n" );
221 printf( "\t%d internal DOF\n\t%d boundary DOF\n\t%d local DOF\n\t%d external DOF\n", out->Nodes->reducedDegreeOfFreedomDistribution->numInternal, out->Nodes->reducedDegreeOfFreedomDistribution->numBoundary, out->Nodes->reducedDegreeOfFreedomDistribution->numLocal, out->Nodes->reducedDegreeOfFreedomDistribution->numExternal);
222 for( i=0, r=0; i<out->Nodes->numNodes; i++ ){
223 if( out->Nodes->toReduced[i]>=0 ){
224 printf( "node %d \t: id %d \tDOF %d \t: tag %d \t: Dom %d \t: coordinates [%3g", r, out->Nodes->Id[i], out->Nodes->reducedDegreeOfFreedom[i], out->Nodes->Tag[i], out->Nodes->Dom[i], out->Nodes->Coordinates[INDEX2(0,i,dim)] );
225 for( j=1; j<dim; j++ )
226 printf( ", %3g", out->Nodes->Coordinates[INDEX2(j,i,dim)]);
227 printf( " ]\n" );
228 r++;
229 }
230 }
231
232 printf( "Elements\n=========\n\n" );
233 printf( "\t%d internal\n\t%d boundary\n\t%d local\n", out->Elements->elementDistribution->numInternal, out->Elements->elementDistribution->numBoundary, out->Elements->elementDistribution->numLocal );
234 N = out->Elements->LinearReferenceElement->Type->numNodes;
235 M = out->Elements->ReferenceElement->Type->numNodes;
236 ref = out->Elements->ReferenceElement->Type->linearNodes;
237 for( i=0; i<out->Elements->numElements; i++ ){
238 printf( "element %d \t: id %d \t: dom %d \t: nodes [ %3d", i, out->Elements->Id[i], out->Elements->Dom[i], out->Nodes->toReduced[out->Elements->Nodes[INDEX2(ref[0],i,M)]] );
239 for( j=1; j<N; j++ ){
240 printf( ", %3d", out->Nodes->toReduced[out->Elements->Nodes[INDEX2(ref[j],i,M)]] );
241 }
242 printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[0],i,M)]] );
243 for( j=1; j<N; j++ )
244 printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[j],i,M)]]);
245 printf( " ]\n" );
246 }
247
248 printf( "\nFace Elements\n=================================================\n\n" );
249 printf( "\t%d internal\n\t%d boundary\n\t%d local\n", out->FaceElements->elementDistribution->numInternal, out->FaceElements->elementDistribution->numBoundary, out->FaceElements->elementDistribution->numLocal );
250 N = out->FaceElements->LinearReferenceElement->Type->numNodes;
251 M = out->FaceElements->ReferenceElement->Type->numNodes;
252 ref = out->FaceElements->ReferenceElement->Type->linearNodes;
253 for( i=0; i<out->FaceElements->numElements; i++ ){
254 printf( "face element %d \t: id %d \t: dom %d \t: nodes [ %3d", i, out->FaceElements->Id[i], out->FaceElements->Dom[i], out->Nodes->toReduced[out->FaceElements->Nodes[INDEX2(ref[0],i,M)]] );
255 for( j=1; j<N; j++ )
256 printf( ", %3d", out->Nodes->toReduced[out->FaceElements->Nodes[INDEX2(j,i,M)]] );
257 printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(ref[0],i,M)]]);
258 for( j=1; j<N; j++ )
259 printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,M)]]);
260 printf( " ]\n" );
261 }
262
263 printf( "\nDistribution Data\n==================\n\n" );
264 Finley_NodeDistribution_print( out->Nodes->reducedDegreeOfFreedomDistribution, stdout );
265 }
266 }
267 #endif
268 /*
269 * $Log$
270 * Revision 1.6 2005/09/15 03:44:22 jgs
271 * Merge of development branch dev-02 back to main trunk on 2005-09-15
272 *
273 * Revision 1.5.2.1 2005/09/07 06:26:19 gross
274 * the solver from finley are put into the standalone package paso now
275 *
276 * Revision 1.5 2005/07/08 04:07:51 jgs
277 * Merge of development branch back to main trunk on 2005-07-08
278 *
279 * Revision 1.4 2004/12/15 07:08:32 jgs
280 * *** empty log message ***
281 * Revision 1.1.1.1.2.3 2005/06/29 02:34:51 gross
282 * some changes towards 64 integers in finley
283 *
284 * Revision 1.1.1.1.2.2 2004/11/24 01:37:13 gross
285 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
286 *
287 *
288 *
289 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26