/[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 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/finley/src/Mesh.c revision 2856 by gross, Mon Jan 18 04:14:37 2010 UTC
# Line 1  Line 1 
1  /**************************************************************/  /*******************************************************
2    *
3    * Copyright (c) 2003-2009 by University of Queensland
4    * Earth Systems Science Computational Center (ESSCC)
5    * http://www.uq.edu.au/esscc
6    *
7    * Primary Business: Queensland, Australia
8    * Licensed under the Open Software License version 3.0
9    * http://www.opensource.org/licenses/osl-3.0.php
10    *
11    *******************************************************/
12    
 /*   Finley: Mesh */  
13    
14  /**************************************************************/  /**************************************************************/
15    
16  /*   Copyrights by ACcESS Australia 2003,04 */  /*   Finley: Mesh */
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$ */  
17    
18  /**************************************************************/  /**************************************************************/
19    
 #include "Finley.h"  
20  #include "Mesh.h"  #include "Mesh.h"
21    
22  /**************************************************************/  /**************************************************************/
# Line 18  Line 24 
24  /*   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, */
25  /*   the most appropriate order is selected indepently. */  /*   the most appropriate order is selected indepently. */
26    
27  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Paso_MPIInfo *mpi_info)
28    {
 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order) {  
29    Finley_Mesh *out;    Finley_Mesh *out;
30        
31    /*  allocate the return value */    /*  allocate the return value */
# Line 33  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 38  Finley_Mesh* Finley_Mesh_alloc(char* nam
38    out->FaceElements=NULL;    out->FaceElements=NULL;
39    out->Points=NULL;          out->Points=NULL;      
40    out->ContactElements=NULL;          out->ContactElements=NULL;      
41      out->TagMap=NULL;      
42    out->reference_counter=0;    out->reference_counter=0;
43    
44    out->FullFullPattern=NULL;    out->FullFullPattern=NULL;
45    out->FullReducedPattern=NULL;    out->FullReducedPattern=NULL;
46    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
47    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
48        out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
49      if (! Finley_noError()) {
50          Finley_Mesh_free(out);
51          return NULL;
52      }
53    /*   copy name: */    /*   copy name: */
54        
55    out->Name=MEMALLOC(strlen(name)+1,char);    out->Name=MEMALLOC(strlen(name)+1,char);
56    if (Finley_checkPtr(out->Name)) {    if (Finley_checkPtr(out->Name)) {
57        Finley_Mesh_dealloc(out);        Finley_Mesh_free(out);
58        return NULL;        return NULL;
59    }    }
60    strcpy(out->Name,name);    strcpy(out->Name,name);
61        
62    /*   allocate node table: */    /*   allocate node table: */
63        out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
64    out->Nodes=Finley_NodeFile_alloc(numDim);    if (! Finley_noError()) {
65    if (Finley_ErrorCode!=NO_ERROR) {        Finley_Mesh_free(out);
       Finley_Mesh_dealloc(out);  
66        return NULL;        return NULL;
67    }    }
68    out->order=order;    out->approximationOrder=-1;
69      out->reducedApproximationOrder=-1;
70      out->integrationOrder=-1;
71      out->reducedIntegrationOrder=-1;
72    
73    out->Elements=NULL;    out->Elements=NULL;
74    out->FaceElements=NULL;    out->FaceElements=NULL;
75    out->Points=NULL;    out->Points=NULL;
# Line 72  Finley_Mesh* Finley_Mesh_reference(Finle Line 85  Finley_Mesh* Finley_Mesh_reference(Finle
85       return in;       return in;
86  }  }
87    
88  /*   deallocates a mesh: */  /*   freeates a mesh: */
89    
90  void Finley_Mesh_dealloc(Finley_Mesh* in) {  void Finley_Mesh_free(Finley_Mesh* in) {
91    if (in!=NULL) {    if (in!=NULL) {
92       in->reference_counter--;       in->reference_counter--;
93       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  
94         MEMFREE(in->Name);         MEMFREE(in->Name);
95         Finley_NodeFile_dealloc(in->Nodes);         Finley_NodeFile_free(in->Nodes);
96         Finley_ElementFile_dealloc(in->Elements);           Finley_ElementFile_free(in->FaceElements);
97         Finley_ElementFile_dealloc(in->FaceElements);         Finley_ElementFile_free(in->Elements);  
98         Finley_ElementFile_dealloc(in->ContactElements);         Finley_ElementFile_free(in->ContactElements);
99         Finley_ElementFile_dealloc(in->Points);         Finley_ElementFile_free(in->Points);
100         Finley_SystemMatrixPattern_dealloc(in->FullFullPattern);         Finley_TagMap_free(in->TagMap);
101         Finley_SystemMatrixPattern_dealloc(in->FullReducedPattern);         Paso_SystemMatrixPattern_free(in->FullFullPattern);
102         Finley_SystemMatrixPattern_dealloc(in->ReducedFullPattern);         Paso_SystemMatrixPattern_free(in->FullReducedPattern);
103         Finley_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
104           Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
105           Paso_MPIInfo_free( in->MPIInfo );
106         MEMFREE(in);               MEMFREE(in);      
107       }       }
108    }    }
# Line 108  dim_t Finley_Mesh_getDim(Finley_Mesh *in Line 116  dim_t Finley_Mesh_getDim(Finley_Mesh *in
116    return in->Nodes->numDim;    return in->Nodes->numDim;
117  }  }
118    
119  /**************************************************************/  void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
120        Finley_ElementFile_free(self->Elements);
121        self->Elements=elements;
122    }
123    void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
124        Finley_ElementFile_free(self->FaceElements);
125        self->FaceElements=elements;
126    }
127    void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
128        Finley_ElementFile_free(self->ContactElements);
129        self->ContactElements=elements;
130    }
131    void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
132        Finley_ElementFile_free(self->Points);
133        self->Points=elements;
134    }
135    int  Finley_Mesh_getStatus(Finley_Mesh* in) {
136       if  (in == NULL) {
137            return -1;
138       } else if (in->Nodes == NULL) {
139            return -1;
140       } else {
141            return in->Nodes->status;
142       }
143    }
144    
145    void Mesh_setOrders(Finley_Mesh *in)
146    {
147       const dim_t order_max=9999999;
148       dim_t locals[4];
149       #ifdef PASO_MPI
150           dim_t globals[4];
151       #endif
152       locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;
153    
154      if ( in->Elements!=NULL) {
155         if (in->Elements->numElements > 0) {
156             locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
157             locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
158             locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);
159             locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
160         }
161      }
162      if ( in->FaceElements!=NULL) {
163         if (in->FaceElements->numElements > 0) {
164             locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
165             locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
166             locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);
167             locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
168         }
169    
 /*  returns the number of nodes in the mesh: */  
170    
171  dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {    }
172    return in->Nodes->numNodes;    if ( in->ContactElements!=NULL) {
173  }       if (in->ContactElements->numElements > 0) {
174  /**************************************************************/           locals[0]=MIN(locals[0], in->ContactElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
175             locals[1]=MIN(locals[1], in->ContactElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
176             locals[2]=MIN(locals[2], in->ContactElements->referenceElementSet->referenceElement->integrationOrder);
177             locals[3]=MIN(locals[3], in->ContactElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
178         }
179    
180  /*  returns the number of degrees of freedom in the mesh: */    }
181    
182  dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {     #ifdef PASO_MPI
183    return in->Nodes->numDegreesOfFreedom;         MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );
184  }         in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );
185  /**************************************************************/         in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );
186           in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );
187           in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );
188       #else
189           in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );
190           in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );
191           in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );
192           in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );
193       #endif
194    
 /*  returns the number of degrees of freedom in the mesh: */  
195    
 dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
196  }  }
197  /*    
 * $Log$  
 * 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.123  
changed lines
  Added in v.2856

  ViewVC Help
Powered by ViewVC 1.1.26