/[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 806 - (hide annotations)
Thu Aug 10 11:58:52 2006 UTC (12 years, 7 months ago) by gross
Original Path: trunk/finley/src/Mesh.c
File MIME type: text/plain
File size: 11766 byte(s)
Interface to the direct solver library UMLPACK is no implemented.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26