/[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

temp/finley/src/Mesh.c revision 1387 by trankine, Fri Jan 11 07:45:26 2008 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    
 /* $Id$ */  
15    
16  /*******************************************************  /************************************************************************************/
  *  
  *           Copyright 2003-2007 by ACceSS MNRF  
  *       Copyright 2007 by University of Queensland  
  *  
  *                http://esscc.uq.edu.au  
  *        Primary Business: Queensland, Australia  
  *  Licensed under the Open Software License version 3.0  
  *     http://www.opensource.org/licenses/osl-3.0.php  
  *  
  *******************************************************/  
   
 /**************************************************************/  
17    
18  /*   Finley: Mesh */  /*   Finley: Mesh */
19    
20  /**************************************************************/  /************************************************************************************/
21    
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,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Esys_MPIInfo *mpi_info)
30  {  {
31    Finley_Mesh *out;    Finley_Mesh *out;
32        
# Line 49  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 47  Finley_Mesh* Finley_Mesh_alloc(char* nam
47    out->FullReducedPattern=NULL;    out->FullReducedPattern=NULL;
48    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
49    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
50    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );    out->MPIInfo = Esys_MPIInfo_getReference( mpi_info );
51    if (! Finley_noError()) {    if (! Finley_noError()) {
52        Finley_Mesh_free(out);        Finley_Mesh_free(out);
53        return NULL;        return NULL;
# Line 69  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 67  Finley_Mesh* Finley_Mesh_alloc(char* nam
67        Finley_Mesh_free(out);        Finley_Mesh_free(out);
68        return NULL;        return NULL;
69    }    }
70    out->order=order;    out->approximationOrder=-1;
71    out->reduced_order=reduced_order;    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 86  Finley_Mesh* Finley_Mesh_reference(Finle Line 87  Finley_Mesh* Finley_Mesh_reference(Finle
87       return in;       return in;
88  }  }
89    
90  /*   freeates a mesh: */  /*   frees a mesh: */
91    
92  void Finley_Mesh_free(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_free: mesh %s is freed.\n",in->Name);  
        } else {  
            printf("Finley_Mesh_free\n");  
        }  
        #endif  
96         MEMFREE(in->Name);         MEMFREE(in->Name);
97         Finley_NodeFile_free(in->Nodes);         Finley_NodeFile_free(in->Nodes);
        Finley_ElementFile_free(in->Elements);    
98         Finley_ElementFile_free(in->FaceElements);         Finley_ElementFile_free(in->FaceElements);
99           Finley_ElementFile_free(in->Elements);  
100         Finley_ElementFile_free(in->ContactElements);         Finley_ElementFile_free(in->ContactElements);
101         Finley_ElementFile_free(in->Points);         Finley_ElementFile_free(in->Points);
102         Finley_TagMap_free(in->TagMap);         Finley_TagMap_free(in->TagMap);
# Line 110  void Finley_Mesh_free(Finley_Mesh* in) { Line 104  void Finley_Mesh_free(Finley_Mesh* in) {
104         Paso_SystemMatrixPattern_free(in->FullReducedPattern);         Paso_SystemMatrixPattern_free(in->FullReducedPattern);
105         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
106         Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);         Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
107         Paso_MPIInfo_free( in->MPIInfo );         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    
# Line 140  void Finley_Mesh_setPoints(Finley_Mesh* Line 134  void Finley_Mesh_setPoints(Finley_Mesh*
134      Finley_ElementFile_free(self->Points);      Finley_ElementFile_free(self->Points);
135      self->Points=elements;      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    
172    
173      }
174      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      }
183    
184       #ifdef ESYS_MPI
185           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    
197    
198    }
199      

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

  ViewVC Help
Powered by ViewVC 1.1.26