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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/finley/src/finleyC/Mesh.c revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC trunk/finley/src/Mesh.c revision 1044 by gross, Mon Mar 19 07:29:31 2007 UTC
# Line 1  Line 1 
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  /*   Finley: Mesh */  /*   Finley: Mesh */
17    
18  /**************************************************************/  /**************************************************************/
19    
20  /*   Copyrights by ACcESS Australia 2003,04 */  /*  Author: gross@access.edu.au */
21  /*   Author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
22    
23  /**************************************************************/  /**************************************************************/
24    
 #include "Finley.h"  
25  #include "Mesh.h"  #include "Mesh.h"
26    
27  /**************************************************************/  /**************************************************************/
# Line 20  Line 31 
31    
32  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  extern Finley_RefElementInfo Finley_RefElement_InfoList[];
33    
34  Finley_Mesh* Finley_Mesh_alloc(char* name,int numDim, int order) {  #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    Finley_Mesh *out;    Finley_Mesh *out;
41        
42    /*  allocate the return value */    /*  allocate the return value */
43        
44    out=(Finley_Mesh*)MEMALLOC(sizeof(Finley_Mesh));    out=MEMALLOC(1,Finley_Mesh);
45    if (Finley_checkPtr(out)) return NULL;    if (Finley_checkPtr(out)) return NULL;
46    out->Name=NULL;      out->Name=NULL;  
47    out->Nodes=NULL;    out->Nodes=NULL;
# Line 33  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 49  Finley_Mesh* Finley_Mesh_alloc(char* nam
49    out->FaceElements=NULL;    out->FaceElements=NULL;
50    out->Points=NULL;          out->Points=NULL;      
51    out->ContactElements=NULL;          out->ContactElements=NULL;      
52      out->TagMap=NULL;      
53    out->reference_counter=0;    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: */    /*   copy name: */
71        
72    out->Name=(char*)MEMALLOC((strlen(name)+1)*sizeof(char));    out->Name=MEMALLOC(strlen(name)+1,char);
73    if (Finley_checkPtr(out->Name)) {    if (Finley_checkPtr(out->Name)) {
74        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
75        return NULL;        return NULL;
# Line 45  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 77  Finley_Mesh* Finley_Mesh_alloc(char* nam
77    strcpy(out->Name,name);    strcpy(out->Name,name);
78        
79    /*   allocate node table: */    /*   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);    out->Nodes=Finley_NodeFile_alloc(numDim);
84    if (Finley_ErrorCode!=NO_ERROR) {  #endif
85      if (! Finley_noError()) {
86        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
87        return NULL;        return NULL;
88    }    }
# Line 60  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 95  Finley_Mesh* Finley_Mesh_alloc(char* nam
95    return out;    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: */  /*   deallocates a mesh: */
106    
107  void Finley_Mesh_dealloc(Finley_Mesh* in) {  void Finley_Mesh_dealloc(Finley_Mesh* in) {
# Line 79  void Finley_Mesh_dealloc(Finley_Mesh* in Line 121  void Finley_Mesh_dealloc(Finley_Mesh* in
121         Finley_ElementFile_dealloc(in->FaceElements);         Finley_ElementFile_dealloc(in->FaceElements);
122         Finley_ElementFile_dealloc(in->ContactElements);         Finley_ElementFile_dealloc(in->ContactElements);
123         Finley_ElementFile_dealloc(in->Points);         Finley_ElementFile_dealloc(in->Points);
124           Finley_TagMap_free(in->TagMap);
125           Paso_SystemMatrixPattern_dealloc(in->FullFullPattern);
126           Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);
127           Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);
128           Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);
129    #ifdef PASO_MPI
130           Paso_MPIInfo_dealloc( in->MPIInfo );
131    #endif
132         MEMFREE(in);               MEMFREE(in);      
133       }       }
134    }    }
# Line 88  void Finley_Mesh_dealloc(Finley_Mesh* in Line 138  void Finley_Mesh_dealloc(Finley_Mesh* in
138    
139  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
140    
141  int Finley_Mesh_getDim(Finley_Mesh *in) {  dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
142    return in->Nodes->numDim;    return in->Nodes->numDim;
143  }  }
144    
# Line 96  int Finley_Mesh_getDim(Finley_Mesh *in) Line 146  int Finley_Mesh_getDim(Finley_Mesh *in)
146    
147  /*  returns the number of nodes in the mesh: */  /*  returns the number of nodes in the mesh: */
148    
149  int Finley_Mesh_getNumNodes(Finley_Mesh *in) {  dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {
150    return in->Nodes->numNodes;    return in->Nodes->numNodes;
151  }  }
152  /**************************************************************/  /**************************************************************/
153    
154  /*  returns the number of degrees of freedom in the mesh: */  /*  returns the number of degrees of freedom in the mesh: */
155    
156  int Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {  dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {
157    return in->Nodes->numDegreesOfFreedom;    return in->Nodes->numDegreesOfFreedom;
158  }  }
159  /**************************************************************/  /**************************************************************/
160    
161  /*  returns the number of degrees of freedom in the mesh: */  /*  returns the number of degrees of freedom in the mesh: */
162    
163  int Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {
164    return in->Nodes->reducedNumDegreesOfFreedom;    return in->Nodes->reducedNumDegreesOfFreedom;
165  }  }
166    
167    #ifdef PASO_MPI
168    void print_mesh_statistics( Finley_Mesh *out, bool_t reduced )
169    {
170      index_t i, r, j, N, M, dim;
171        int *ref;  
172        dim = out->Nodes->numDim;
173    
174        if( !reduced ){
175            printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nFULL MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );
176            printf( "\nNodes\n========\n\n" );
177            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);
178            for( i=0; i<out->Nodes->numNodes; i++ ){
179                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)] );
180                for( j=1; j<dim; j++ )
181                    printf( ", %3g",  out->Nodes->Coordinates[INDEX2(j,i,dim)]);
182                printf( " ]\n" );
183            }
184    
185            printf( "Elements\n=========\n\n" );
186            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 );
187            N = out->Elements->ReferenceElement->Type->numNodes;
188            for( i=0; i<out->Elements->numElements; i++ ){
189                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)] );
190                for( j=1; j<N; j++ )
191                    printf( ", %2d", out->Elements->Nodes[INDEX2(j,i,N)]);  
192                printf( " ] -> " );
193                if( N>8 )
194                    printf( "\n\t\t\t\t\t\t" );
195                printf( ": DOF   [ %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(0,i,N)]] );    
196                for( j=1; j<N; j++ )
197                    printf( ", %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(j,i,N)]]);
198                printf( " ]\n" );  
199            }
200    
201            printf( "\nFace Elements\n==========\n\n" );
202            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 );
203            N = out->FaceElements->ReferenceElement->Type->numNodes;
204            for( i=0; i<out->FaceElements->numElements; i++ ){
205                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)] );
206                for( j=1; j<N; j++ )
207                    printf( ", %2d", out->FaceElements->Nodes[INDEX2(j,i,N)]  );    
208                printf( " ] -> " );
209                if( N>8 )
210                    printf( "\n\t\t\t\t\t\t" );
211                printf( ": DOF   [ %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(0,i,N)]]);
212                for( j=1; j<N; j++ )
213                    printf( ", %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,N)]]);
214                printf( " ]\n" );  
215            }
216            printf( "\nDistribution Data\n==========\n\n" );
217            Finley_NodeDistribution_print( out->Nodes->degreeOfFreedomDistribution, stdout );
218        }
219        else{
220            printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nREDUCED MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );
221            printf( "\nNodes\n========\n\n" );
222            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);
223            for( i=0, r=0; i<out->Nodes->numNodes; i++ ){
224                if( out->Nodes->toReduced[i]>=0 ){
225                    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)] );
226                    for( j=1; j<dim; j++ )
227                        printf( ", %3g",  out->Nodes->Coordinates[INDEX2(j,i,dim)]);
228                    printf( " ]\n" );
229                    r++;
230                }
231            }
232    
233            printf( "Elements\n=========\n\n" );
234            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 );
235            N = out->Elements->LinearReferenceElement->Type->numNodes;
236            M = out->Elements->ReferenceElement->Type->numNodes;
237            ref = out->Elements->ReferenceElement->Type->linearNodes;
238            for( i=0; i<out->Elements->numElements; i++ ){
239                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)]] );
240                for( j=1; j<N; j++ ){
241                    printf( ", %3d", out->Nodes->toReduced[out->Elements->Nodes[INDEX2(ref[j],i,M)]] );
242                }
243                printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[0],i,M)]] );
244                for( j=1; j<N; j++ )
245                    printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[j],i,M)]]);
246                printf( " ]\n" );  
247            }
248    
249            printf( "\nFace Elements\n=================================================\n\n" );
250            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 );
251            N = out->FaceElements->LinearReferenceElement->Type->numNodes;
252            M = out->FaceElements->ReferenceElement->Type->numNodes;
253            ref = out->FaceElements->ReferenceElement->Type->linearNodes;
254            for( i=0; i<out->FaceElements->numElements; i++ ){
255                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)]] );
256                for( j=1; j<N; j++ )
257                    printf( ", %3d", out->Nodes->toReduced[out->FaceElements->Nodes[INDEX2(j,i,M)]]  );
258                printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(ref[0],i,M)]]);  
259                for( j=1; j<N; j++ )
260                    printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,M)]]);  
261                printf( " ]\n" );  
262            }
263    
264            printf( "\nDistribution Data\n==================\n\n" );
265            Finley_NodeDistribution_print( out->Nodes->reducedDegreeOfFreedomDistribution, stdout );
266        }
267    }
268    #endif
269  /*  /*
270  * $Log$  * $Log$
271  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.6  2005/09/15 03:44:22  jgs
272  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
273    *
274    * Revision 1.5.2.1  2005/09/07 06:26:19  gross
275    * the solver from finley are put into the standalone package paso now
276    *
277    * Revision 1.5  2005/07/08 04:07:51  jgs
278    * Merge of development branch back to main trunk on 2005-07-08
279    *
280    * Revision 1.4  2004/12/15 07:08:32  jgs
281    * *** empty log message ***
282    * Revision 1.1.1.1.2.3  2005/06/29 02:34:51  gross
283    * some changes towards 64 integers in finley
284    *
285    * Revision 1.1.1.1.2.2  2004/11/24 01:37:13  gross
286    * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
287  *  *
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
288  *  *
289  *  *
290  */  */

Legend:
Removed from v.82  
changed lines
  Added in v.1044

  ViewVC Help
Powered by ViewVC 1.1.26