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

Diff of /trunk/finley/src/Mesh.c

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

trunk/finley/src/finleyC/Mesh.c revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/finley/src/Mesh.c revision 782 by bcumming, Tue Jul 18 00:47:47 2006 UTC
# Line 1  Line 1 
1  /*  /*
2   ******************************************************************************   ************************************************************
3   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
4   *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *   *                                                          *
5   *                                                                            *   *              http://www.access.edu.au                    *
6   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
7   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
8   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
9   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
10   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
11  */  */
12    
13  /**************************************************************/  /**************************************************************/
# Line 32  Line 30 
30    
31  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  extern Finley_RefElementInfo Finley_RefElement_InfoList[];
32    
33  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order) {  #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    Finley_Mesh *out;    Finley_Mesh *out;
40        
41    /*  allocate the return value */    /*  allocate the return value */
# Line 51  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 54  Finley_Mesh* Finley_Mesh_alloc(char* nam
54    out->FullReducedPattern=NULL;    out->FullReducedPattern=NULL;
55    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
56    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
57      
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    /*   copy name: */    /*   copy name: */
69        
70    out->Name=MEMALLOC(strlen(name)+1,char);    out->Name=MEMALLOC(strlen(name)+1,char);
# Line 62  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 75  Finley_Mesh* Finley_Mesh_alloc(char* nam
75    strcpy(out->Name,name);    strcpy(out->Name,name);
76        
77    /*   allocate node table: */    /*   allocate node table: */
78      #ifdef PASO_MPI
79      out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
80    #else
81    out->Nodes=Finley_NodeFile_alloc(numDim);    out->Nodes=Finley_NodeFile_alloc(numDim);
82    #endif
83    if (! Finley_noError()) {    if (! Finley_noError()) {
84        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
85        return NULL;        return NULL;
# Line 107  void Finley_Mesh_dealloc(Finley_Mesh* in Line 123  void Finley_Mesh_dealloc(Finley_Mesh* in
123         Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);         Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);
124         Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);         Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);
125         Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);         Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);
126    #ifdef PASO_MPI
127           Paso_MPIInfo_dealloc( in->MPIInfo );
128    #endif
129         MEMFREE(in);               MEMFREE(in);      
130       }       }
131    }    }
# Line 141  dim_t Finley_Mesh_getNumDegreesOfFreedom Line 160  dim_t Finley_Mesh_getNumDegreesOfFreedom
160  dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {
161    return in->Nodes->reducedNumDegreesOfFreedom;    return in->Nodes->reducedNumDegreesOfFreedom;
162  }  }
163    
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  /*  /*
267  * $Log$  * $Log$
268  * Revision 1.6  2005/09/15 03:44:22  jgs  * Revision 1.6  2005/09/15 03:44:22  jgs

Legend:
Removed from v.155  
changed lines
  Added in v.782

  ViewVC Help
Powered by ViewVC 1.1.26