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

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

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

trunk/esys2/finley/src/finleyC/Mesh.c revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/finley/src/Mesh.c revision 3981 by jfenwick, Fri Sep 21 02:47:54 2012 UTC
# Line 1  Line 1 
1  /**************************************************************/  /*****************************************************************************
2    *
3    * Copyright (c) 2003-2012 by University of Queensland
4    * http://www.uq.edu.au
5    *
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    * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11    * Development since 2012 by School of Earth Sciences
12    *
13    *****************************************************************************/
14    
 /*   Finley: Mesh */  
15    
16  /**************************************************************/  /************************************************************************************/
17    
18  /*   Copyrights by ACcESS Australia 2003,04 */  /*   Finley: Mesh */
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /************************************************************************************/
21    
 #include "Finley.h"  
22  #include "Mesh.h"  #include "Mesh.h"
23    
24  /**************************************************************/  /************************************************************************************/
25    
26  /*   allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */  /*   allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
27  /*   the most appropriate order is selected indepently. */  /*   the most appropriate order is selected independently. */
   
 extern Finley_RefElementInfo Finley_RefElement_InfoList[];  
28    
29  Finley_Mesh* Finley_Mesh_alloc(char* name,int numDim, int order) {  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Esys_MPIInfo *mpi_info)
30    {
31    Finley_Mesh *out;    Finley_Mesh *out;
32        
33    /*  allocate the return value */    /*  allocate the return value */
# Line 33  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 40  Finley_Mesh* Finley_Mesh_alloc(char* nam
40    out->FaceElements=NULL;    out->FaceElements=NULL;
41    out->Points=NULL;          out->Points=NULL;      
42    out->ContactElements=NULL;          out->ContactElements=NULL;      
43      out->TagMap=NULL;      
44    out->reference_counter=0;    out->reference_counter=0;
45    
46    out->FullFullPattern=NULL;    out->FullFullPattern=NULL;
47    out->FullReducedPattern=NULL;    out->FullReducedPattern=NULL;
48    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
49    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
50        out->MPIInfo = Esys_MPIInfo_getReference( mpi_info );
51      if (! Finley_noError()) {
52          Finley_Mesh_free(out);
53          return NULL;
54      }
55    /*   copy name: */    /*   copy name: */
56        
57    out->Name=MEMALLOC(strlen(name)+1,char);    out->Name=MEMALLOC(strlen(name)+1,char);
58    if (Finley_checkPtr(out->Name)) {    if (Finley_checkPtr(out->Name)) {
59        Finley_Mesh_dealloc(out);        Finley_Mesh_free(out);
60        return NULL;        return NULL;
61    }    }
62    strcpy(out->Name,name);    strcpy(out->Name,name);
63        
64    /*   allocate node table: */    /*   allocate node table: */
65        out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
66    out->Nodes=Finley_NodeFile_alloc(numDim);    if (! Finley_noError()) {
67    if (Finley_ErrorCode!=NO_ERROR) {        Finley_Mesh_free(out);
       Finley_Mesh_dealloc(out);  
68        return NULL;        return NULL;
69    }    }
70    out->order=order;    out->approximationOrder=-1;
71      out->reducedApproximationOrder=-1;
72      out->integrationOrder=-1;
73      out->reducedIntegrationOrder=-1;
74    
75    out->Elements=NULL;    out->Elements=NULL;
76    out->FaceElements=NULL;    out->FaceElements=NULL;
77    out->Points=NULL;    out->Points=NULL;
# Line 72  Finley_Mesh* Finley_Mesh_reference(Finle Line 87  Finley_Mesh* Finley_Mesh_reference(Finle
87       return in;       return in;
88  }  }
89    
90  /*   deallocates a mesh: */  /*   frees a mesh: */
91    
92  void Finley_Mesh_dealloc(Finley_Mesh* in) {  void Finley_Mesh_free(Finley_Mesh* in) {
93    if (in!=NULL) {    if (in!=NULL) {
94       in->reference_counter--;       in->reference_counter--;
95       if (in->reference_counter<1) {       if (in->reference_counter<1) {
        #ifdef Finley_TRACE  
        if (in->Name!=NULL) {  
            printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);  
        } else {  
            printf("Finley_Mesh_dealloc\n");  
        }  
        #endif  
96         MEMFREE(in->Name);         MEMFREE(in->Name);
97         Finley_NodeFile_dealloc(in->Nodes);         Finley_NodeFile_free(in->Nodes);
98         Finley_ElementFile_dealloc(in->Elements);           Finley_ElementFile_free(in->FaceElements);
99         Finley_ElementFile_dealloc(in->FaceElements);         Finley_ElementFile_free(in->Elements);  
100         Finley_ElementFile_dealloc(in->ContactElements);         Finley_ElementFile_free(in->ContactElements);
101         Finley_ElementFile_dealloc(in->Points);         Finley_ElementFile_free(in->Points);
102         Finley_SystemMatrixPattern_dealloc(in->FullFullPattern);         Finley_TagMap_free(in->TagMap);
103         Finley_SystemMatrixPattern_dealloc(in->FullReducedPattern);         Paso_SystemMatrixPattern_free(in->FullFullPattern);
104         Finley_SystemMatrixPattern_dealloc(in->ReducedFullPattern);         Paso_SystemMatrixPattern_free(in->FullReducedPattern);
105         Finley_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
106           Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
107           Esys_MPIInfo_free( in->MPIInfo );
108         MEMFREE(in);               MEMFREE(in);      
109       }       }
110    }    }
111  }  }
112    
113  /**************************************************************/  /************************************************************************************/
114    
115  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
116    
117  int Finley_Mesh_getDim(Finley_Mesh *in) {  dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
118    return in->Nodes->numDim;    return in->Nodes->numDim;
119  }  }
120    
121  /**************************************************************/  void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
122        Finley_ElementFile_free(self->Elements);
123        self->Elements=elements;
124    }
125    void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
126        Finley_ElementFile_free(self->FaceElements);
127        self->FaceElements=elements;
128    }
129    void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
130        Finley_ElementFile_free(self->ContactElements);
131        self->ContactElements=elements;
132    }
133    void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
134        Finley_ElementFile_free(self->Points);
135        self->Points=elements;
136    }
137    int  Finley_Mesh_getStatus(Finley_Mesh* in) {
138       if  (in == NULL) {
139            return -1;
140       } else if (in->Nodes == NULL) {
141            return -1;
142       } else {
143            return in->Nodes->status;
144       }
145    }
146    
147    void Finley_Mesh_setOrders(Finley_Mesh *in)
148    {
149       const dim_t order_max=9999999;
150       dim_t locals[4];
151       #ifdef ESYS_MPI
152           dim_t globals[4];
153       #endif
154       locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;
155    
156      if ( in->Elements!=NULL) {
157         if (in->Elements->numElements > 0) {
158             locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
159             locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
160             locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);
161             locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
162         }
163      }
164      if ( in->FaceElements!=NULL) {
165         if (in->FaceElements->numElements > 0) {
166             locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
167             locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
168             locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);
169             locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
170         }
171    
 /*  returns the number of nodes in the mesh: */  
172    
173  int Finley_Mesh_getNumNodes(Finley_Mesh *in) {    }
174    return in->Nodes->numNodes;    if ( in->ContactElements!=NULL) {
175  }       if (in->ContactElements->numElements > 0) {
176  /**************************************************************/           locals[0]=MIN(locals[0], in->ContactElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
177             locals[1]=MIN(locals[1], in->ContactElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
178             locals[2]=MIN(locals[2], in->ContactElements->referenceElementSet->referenceElement->integrationOrder);
179             locals[3]=MIN(locals[3], in->ContactElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
180         }
181    
182  /*  returns the number of degrees of freedom in the mesh: */    }
183    
184  int Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {     #ifdef ESYS_MPI
185    return in->Nodes->numDegreesOfFreedom;         MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );
186  }         in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );
187  /**************************************************************/         in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );
188           in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );
189           in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );
190       #else
191           in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );
192           in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );
193           in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );
194           in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );
195       #endif
196    
 /*  returns the number of degrees of freedom in the mesh: */  
197    
 int Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
198  }  }
199  /*    
 * $Log$  
 * Revision 1.2  2004/12/14 05:39:30  jgs  
 * *** empty log message ***  
 *  
 * 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  
 *  
 * Revision 1.1.1.1.2.1  2004/11/12 06:58:18  gross  
 * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry  
 *  
 * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  
 * initial import of project esys2  
 *  
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
 *  
 *  
 */  

Legend:
Removed from v.97  
changed lines
  Added in v.3981

  ViewVC Help
Powered by ViewVC 1.1.26