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

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

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

revision 1222 by ksteube, Tue May 15 03:23:17 2007 UTC revision 1223 by gross, Fri Aug 3 02:40:39 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   ************************************************************   ************************************************************
3   *          Copyright 2006 by ACcESS MNRF                   *   *          Copyright 2006, 2007 by ACcESS MNRF                   *
4   *                                                          *   *                                                          *
5   *              http://www.access.edu.au                    *   *              http://www.access.edu.au                    *
6   *       Primary Business: Queensland, Australia            *   *       Primary Business: Queensland, Australia            *
# Line 10  Line 10 
10   ************************************************************   ************************************************************
11  */  */
12    
   
   
13  /**************************************************************/  /**************************************************************/
14    
15  /*   Finley: Mesh */  /*   Finley: Mesh */
# Line 32  Line 30 
30    
31  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  extern Finley_RefElementInfo Finley_RefElement_InfoList[];
32    
 #ifndef PASO_MPI  
 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order)  
 #else  
33  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
 #endif  
34  {  {
35    Finley_Mesh *out;    Finley_Mesh *out;
36        
# Line 57  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 51  Finley_Mesh* Finley_Mesh_alloc(char* nam
51    out->FullReducedPattern=NULL;    out->FullReducedPattern=NULL;
52    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
53    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
   
 #ifdef PASO_MPI  
   out->MPIInfo = NULL;  
   
   /* get MPI info */  
54    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
55    if (! Finley_noError()) {    if (! Finley_noError()) {
56        Finley_Mesh_dealloc(out);        Finley_Mesh_free(out);
57        return NULL;        return NULL;
58    }    }
 #endif  
59    /*   copy name: */    /*   copy name: */
60        
61    out->Name=MEMALLOC(strlen(name)+1,char);    out->Name=MEMALLOC(strlen(name)+1,char);
62    if (Finley_checkPtr(out->Name)) {    if (Finley_checkPtr(out->Name)) {
63        Finley_Mesh_dealloc(out);        Finley_Mesh_free(out);
64        return NULL;        return NULL;
65    }    }
66    strcpy(out->Name,name);    strcpy(out->Name,name);
67        
68    /*   allocate node table: */    /*   allocate node table: */
 #ifdef PASO_MPI  
69    out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );    out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
 #else  
   out->Nodes=Finley_NodeFile_alloc(numDim);  
 #endif  
70    if (! Finley_noError()) {    if (! Finley_noError()) {
71        Finley_Mesh_dealloc(out);        Finley_Mesh_free(out);
72        return NULL;        return NULL;
73    }    }
74    out->order=order;    out->order=order;
# Line 104  Finley_Mesh* Finley_Mesh_reference(Finle Line 88  Finley_Mesh* Finley_Mesh_reference(Finle
88       return in;       return in;
89  }  }
90    
91  /*   deallocates a mesh: */  /*   freeates a mesh: */
92    
93  void Finley_Mesh_dealloc(Finley_Mesh* in) {  void Finley_Mesh_free(Finley_Mesh* in) {
94    if (in!=NULL) {    if (in!=NULL) {
95       in->reference_counter--;       in->reference_counter--;
96       if (in->reference_counter<1) {       if (in->reference_counter<1) {
97         #ifdef Finley_TRACE         #ifdef Finley_TRACE
98         if (in->Name!=NULL) {         if (in->Name!=NULL) {
99             printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);             printf("Finley_Mesh_free: mesh %s is freed.\n",in->Name);
100         } else {         } else {
101             printf("Finley_Mesh_dealloc\n");             printf("Finley_Mesh_free\n");
102         }         }
103         #endif         #endif
104         MEMFREE(in->Name);         MEMFREE(in->Name);
105         Finley_NodeFile_dealloc(in->Nodes);         Finley_NodeFile_free(in->Nodes);
106         Finley_ElementFile_dealloc(in->Elements);           Finley_ElementFile_free(in->Elements);  
107         Finley_ElementFile_dealloc(in->FaceElements);         Finley_ElementFile_free(in->FaceElements);
108         Finley_ElementFile_dealloc(in->ContactElements);         Finley_ElementFile_free(in->ContactElements);
109         Finley_ElementFile_dealloc(in->Points);         Finley_ElementFile_free(in->Points);
110         Finley_TagMap_free(in->TagMap);         Finley_TagMap_free(in->TagMap);
111         Paso_SystemMatrixPattern_dealloc(in->FullFullPattern);         Paso_SystemMatrixPattern_free(in->FullFullPattern);
112         Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);         Paso_SystemMatrixPattern_free(in->FullReducedPattern);
113         Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
114         Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);         Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
115  #ifdef PASO_MPI         Paso_MPIInfo_free( in->MPIInfo );
        Paso_MPIInfo_dealloc( in->MPIInfo );  
 #endif  
116         MEMFREE(in);               MEMFREE(in);      
117       }       }
118    }    }
# Line 144  dim_t Finley_Mesh_getDim(Finley_Mesh *in Line 126  dim_t Finley_Mesh_getDim(Finley_Mesh *in
126    return in->Nodes->numDim;    return in->Nodes->numDim;
127  }  }
128    
129  /**************************************************************/  void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
130        Finley_ElementFile_free(self->Elements);
131  /*  returns the number of nodes in the mesh: */      self->Elements=elements;
132    }
133  dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {  void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
134    return in->Nodes->numNodes;      Finley_ElementFile_free(self->FaceElements);
135        self->FaceElements=elements;
136    }
137    void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
138        Finley_ElementFile_free(self->ContactElements);
139        self->ContactElements=elements;
140    }
141    void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
142        Finley_ElementFile_free(self->Points);
143        self->Points=elements;
144  }  }
 /**************************************************************/  
145    
 /*  returns the number of degrees of freedom in the mesh: */  
   
 dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->numDegreesOfFreedom;  
 }  
 /**************************************************************/  
   
 /*  returns the number of degrees of freedom in the mesh: */  
   
 dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
 }  
   
 #ifdef PASO_MPI  
 void print_mesh_statistics( Finley_Mesh *out, bool_t reduced )  
 {  
   index_t i, r, j, N, M, dim;  
     int *ref;    
     dim = out->Nodes->numDim;  
   
     if( !reduced ){  
         printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nFULL MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );  
         printf( "\nNodes\n========\n\n" );  
         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);  
         for( i=0; i<out->Nodes->numNodes; i++ ){  
             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)] );  
             for( j=1; j<dim; j++ )  
                 printf( ", %3g",  out->Nodes->Coordinates[INDEX2(j,i,dim)]);  
             printf( " ]\n" );  
         }  
   
         printf( "Elements\n=========\n\n" );  
         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 );  
         N = out->Elements->ReferenceElement->Type->numNodes;  
         for( i=0; i<out->Elements->numElements; i++ ){  
             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)] );  
             for( j=1; j<N; j++ )  
                 printf( ", %2d", out->Elements->Nodes[INDEX2(j,i,N)]);    
             printf( " ] -> " );  
             if( N>8 )  
                 printf( "\n\t\t\t\t\t\t" );  
             printf( ": DOF   [ %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(0,i,N)]] );      
             for( j=1; j<N; j++ )  
                 printf( ", %2d", out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(j,i,N)]]);  
             printf( " ]\n" );    
         }  
   
         printf( "\nFace Elements\n==========\n\n" );  
         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 );  
         N = out->FaceElements->ReferenceElement->Type->numNodes;  
         for( i=0; i<out->FaceElements->numElements; i++ ){  
             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)] );  
             for( j=1; j<N; j++ )  
                 printf( ", %2d", out->FaceElements->Nodes[INDEX2(j,i,N)]  );      
             printf( " ] -> " );  
             if( N>8 )  
                 printf( "\n\t\t\t\t\t\t" );  
             printf( ": DOF   [ %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(0,i,N)]]);  
             for( j=1; j<N; j++ )  
                 printf( ", %2d", out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,N)]]);  
             printf( " ]\n" );    
         }  
         printf( "\nDistribution Data\n==========\n\n" );  
         Finley_NodeDistribution_print( out->Nodes->degreeOfFreedomDistribution, stdout );  
     }  
     else{  
         printf( "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMESH STATISTICS\n\nREDUCED MESH\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n" );  
         printf( "\nNodes\n========\n\n" );  
         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);  
         for( i=0, r=0; i<out->Nodes->numNodes; i++ ){  
             if( out->Nodes->toReduced[i]>=0 ){  
                 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)] );  
                 for( j=1; j<dim; j++ )  
                     printf( ", %3g",  out->Nodes->Coordinates[INDEX2(j,i,dim)]);  
                 printf( " ]\n" );  
                 r++;  
             }  
         }  
   
         printf( "Elements\n=========\n\n" );  
         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 );  
         N = out->Elements->LinearReferenceElement->Type->numNodes;  
         M = out->Elements->ReferenceElement->Type->numNodes;  
         ref = out->Elements->ReferenceElement->Type->linearNodes;  
         for( i=0; i<out->Elements->numElements; i++ ){  
             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)]] );  
             for( j=1; j<N; j++ ){  
                 printf( ", %3d", out->Nodes->toReduced[out->Elements->Nodes[INDEX2(ref[j],i,M)]] );  
             }  
             printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[0],i,M)]] );  
             for( j=1; j<N; j++ )  
                 printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->Elements->Nodes[INDEX2(ref[j],i,M)]]);  
             printf( " ]\n" );    
         }  
   
         printf( "\nFace Elements\n=================================================\n\n" );  
         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 );  
         N = out->FaceElements->LinearReferenceElement->Type->numNodes;  
         M = out->FaceElements->ReferenceElement->Type->numNodes;  
         ref = out->FaceElements->ReferenceElement->Type->linearNodes;  
         for( i=0; i<out->FaceElements->numElements; i++ ){  
             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)]] );  
             for( j=1; j<N; j++ )  
                 printf( ", %3d", out->Nodes->toReduced[out->FaceElements->Nodes[INDEX2(j,i,M)]]  );  
             printf( " ] DOF [ %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(ref[0],i,M)]]);    
             for( j=1; j<N; j++ )  
                 printf( ", %3d", out->Nodes->reducedDegreeOfFreedom[out->FaceElements->Nodes[INDEX2(j,i,M)]]);    
             printf( " ]\n" );    
         }  
   
         printf( "\nDistribution Data\n==================\n\n" );  
         Finley_NodeDistribution_print( out->Nodes->reducedDegreeOfFreedomDistribution, stdout );  
     }  
 }  
 #endif  
 /*  
 * $Log$  
 * Revision 1.6  2005/09/15 03:44:22  jgs  
 * Merge of development branch dev-02 back to main trunk on 2005-09-15  
 *  
 * Revision 1.5.2.1  2005/09/07 06:26:19  gross  
 * the solver from finley are put into the standalone package paso now  
 *  
 * Revision 1.5  2005/07/08 04:07:51  jgs  
 * Merge of development branch back to main trunk on 2005-07-08  
 *  
 * Revision 1.4  2004/12/15 07:08:32  jgs  
 * *** empty log message ***  
 * Revision 1.1.1.1.2.3  2005/06/29 02:34:51  gross  
 * some changes towards 64 integers in finley  
 *  
 * Revision 1.1.1.1.2.2  2004/11/24 01:37:13  gross  
 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
 *  
 *  
 *  
 */  

Legend:
Removed from v.1222  
changed lines
  Added in v.1223

  ViewVC Help
Powered by ViewVC 1.1.26