/[escript]/branches/doubleplusgood/dudley/src/Mesh.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/dudley/src/Mesh.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26