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

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

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

branches/domexper/dudley/src/Mesh.c revision 3080 by jfenwick, Tue Aug 3 04:28:03 2010 UTC branches/doubleplusgood/dudley/src/Mesh.cpp revision 4332 by jfenwick, Thu Mar 21 04:21:14 2013 UTC
# Line 1  Line 1 
1  /*******************************************************  /*****************************************************************************
2  *  *
3  * Copyright (c) 2003-2010 by University of Queensland  * Copyright (c) 2003-2013 by University of Queensland
4  * Earth Systems Science Computational Center (ESSCC)  * http://www.uq.edu.au
 * http://www.uq.edu.au/esscc  
5  *  *
6  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
7  * Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
8  * http://www.opensource.org/licenses/osl-3.0.php  * 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    
15  /**************************************************************/  /************************************************************************************/
16    
17  /*   Finley: Mesh */  /*   Dudley: Mesh */
18    
19  /**************************************************************/  /************************************************************************************/
20    
21  #include "Mesh.h"  #include "Mesh.h"
22    
23  /**************************************************************/  /************************************************************************************/
24    
25  /*   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, */
26  /*   the most appropriate order is selected indepently. */  /*   the most appropriate order is selected indepently. */
27    
28  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Paso_MPIInfo *mpi_info)  Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
29  {  {
30    Finley_Mesh *out;      Dudley_Mesh *out;
31      
32    /*  allocate the return value */      /*  allocate the return value */
33      
34    out=MEMALLOC(1,Finley_Mesh);      out = new Dudley_Mesh;
35    if (Finley_checkPtr(out)) return NULL;      if (Dudley_checkPtr(out))
36    out->Name=NULL;        return NULL;
37    out->Nodes=NULL;      out->Name = NULL;
38    out->Elements=NULL;        out->Nodes = NULL;
39    out->FaceElements=NULL;      out->Elements = NULL;
40    out->Points=NULL;            out->FaceElements = NULL;
41    out->ContactElements=NULL;            out->Points = NULL;
42    out->TagMap=NULL;            out->TagMap = NULL;
43    out->reference_counter=0;      out->reference_counter = 0;
44    
45    out->FullFullPattern=NULL;      out->FullFullPattern = NULL;
46    out->FullReducedPattern=NULL;      out->FullReducedPattern = NULL;
47    out->ReducedFullPattern=NULL;      out->ReducedFullPattern = NULL;
48    out->ReducedReducedPattern=NULL;      out->ReducedReducedPattern = NULL;
49    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );      out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
50    if (! Finley_noError()) {      if (!Dudley_noError())
51        Finley_Mesh_free(out);      {
52        return NULL;      Dudley_Mesh_free(out);
53    }      return NULL;
54    /*   copy name: */      }
55          /*   copy name: */
56    out->Name=MEMALLOC(strlen(name)+1,char);  
57    if (Finley_checkPtr(out->Name)) {      out->Name = new  char[strlen(name) + 1];
58        Finley_Mesh_free(out);      if (Dudley_checkPtr(out->Name))
59        return NULL;      {
60    }      Dudley_Mesh_free(out);
61    strcpy(out->Name,name);      return NULL;
62          }
63    /*   allocate node table: */      strcpy(out->Name, name);
64    out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );  
65    if (! Finley_noError()) {      /*   allocate node table: */
66        Finley_Mesh_free(out);      out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
67        return NULL;      if (!Dudley_noError())
68    }      {
69    out->approximationOrder=-1;      Dudley_Mesh_free(out);
70    out->reducedApproximationOrder=-1;      return NULL;
71    out->integrationOrder=-1;      }
72    out->reducedIntegrationOrder=-1;      out->approximationOrder = -1;
73        out->reducedApproximationOrder = -1;
74    out->Elements=NULL;      out->integrationOrder = -1;
75    out->FaceElements=NULL;      out->reducedIntegrationOrder = -1;
76    out->Points=NULL;  
77    out->ContactElements=NULL;      out->Elements = NULL;
78    out->reference_counter++;      out->FaceElements = NULL;
79    return out;      out->Points = NULL;
80  }      out->reference_counter++;
81        return out;
 /* returns a reference to Finley_Mesh in */  
   
 Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {  
      if (in!=NULL) ++(in->reference_counter);  
      return in;  
 }  
   
 /*   freeates a mesh: */  
   
 void Finley_Mesh_free(Finley_Mesh* in) {  
   if (in!=NULL) {  
      in->reference_counter--;  
      if (in->reference_counter<1) {  
        MEMFREE(in->Name);  
        Finley_NodeFile_free(in->Nodes);  
        Finley_ElementFile_free(in->FaceElements);  
        Finley_ElementFile_free(in->Elements);    
        Finley_ElementFile_free(in->ContactElements);  
        Finley_ElementFile_free(in->Points);  
        Finley_TagMap_free(in->TagMap);  
        Paso_SystemMatrixPattern_free(in->FullFullPattern);  
        Paso_SystemMatrixPattern_free(in->FullReducedPattern);  
        Paso_SystemMatrixPattern_free(in->ReducedFullPattern);  
        Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);  
        Paso_MPIInfo_free( in->MPIInfo );  
        MEMFREE(in);        
      }  
   }  
82  }  }
83    
84  /**************************************************************/  /* returns a reference to Dudley_Mesh in */
85    
86    Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
87    {
88        if (in != NULL)
89        ++(in->reference_counter);
90        return in;
91    }
92    
93    /*   frees a mesh: */
94    
95    void Dudley_Mesh_free(Dudley_Mesh * in)
96    {
97        if (in != NULL)
98        {
99        in->reference_counter--;
100        if (in->reference_counter < 1)
101        {
102            delete[] in->Name;
103            Dudley_NodeFile_free(in->Nodes);
104            Dudley_ElementFile_free(in->FaceElements);
105            Dudley_ElementFile_free(in->Elements);
106            Dudley_ElementFile_free(in->Points);
107            Dudley_TagMap_free(in->TagMap);
108            Paso_SystemMatrixPattern_free(in->FullFullPattern);
109            Paso_SystemMatrixPattern_free(in->FullReducedPattern);
110            Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
111            Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
112            Esys_MPIInfo_free(in->MPIInfo);
113            delete in;
114        }
115        }
116    }
117    
118    /************************************************************************************/
119    
120  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
121    
122  dim_t Finley_Mesh_getDim(Finley_Mesh *in) {  dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
123    return in->Nodes->numDim;  {
124        return in->Nodes->numDim;
125  }  }
126    
127  void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
128      Finley_ElementFile_free(self->Elements);  {
129      self->Elements=elements;      Dudley_ElementFile_free(self->Elements);
130  }      self->Elements = elements;
131  void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {  }
132      Finley_ElementFile_free(self->FaceElements);  
133      self->FaceElements=elements;  void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
134  }  {
135  void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {      Dudley_ElementFile_free(self->FaceElements);
136      Finley_ElementFile_free(self->ContactElements);      self->FaceElements = elements;
137      self->ContactElements=elements;  }
138  }  
139  void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
140      Finley_ElementFile_free(self->Points);  {
141      self->Points=elements;      Dudley_ElementFile_free(self->Points);
142  }      self->Points = elements;
143  int  Finley_Mesh_getStatus(Finley_Mesh* in) {  }
144     if  (in == NULL) {  
145          return -1;  int Dudley_Mesh_getStatus(Dudley_Mesh * in)
146     } else if (in->Nodes == NULL) {  {
147          return -1;      if (in == NULL)
148     } else {      {
149          return in->Nodes->status;      return -1;
150     }      }
151  }      else if (in->Nodes == NULL)
152        {
153  void Mesh_setOrders(Finley_Mesh *in)      return -1;
154  {      }
155     const dim_t order_max=9999999;      else
156     dim_t locals[4];      {
157     #ifdef PASO_MPI      return in->Nodes->status;
158         dim_t globals[4];      }
159     #endif  }
    locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;  
   
   if ( in->Elements!=NULL) {  
      if (in->Elements->numElements > 0) {  
          locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);  
          locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);  
          locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);  
          locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
      }  
   }  
   if ( in->FaceElements!=NULL) {  
      if (in->FaceElements->numElements > 0) {  
          locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);  
          locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);  
          locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);  
          locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
      }  
   
   
   }  
   if ( in->ContactElements!=NULL) {  
      if (in->ContactElements->numElements > 0) {  
          locals[0]=MIN(locals[0], in->ContactElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);  
          locals[1]=MIN(locals[1], in->ContactElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);  
          locals[2]=MIN(locals[2], in->ContactElements->referenceElementSet->referenceElement->integrationOrder);  
          locals[3]=MIN(locals[3], in->ContactElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
      }  
   
   }  
   
    #ifdef PASO_MPI  
        MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );  
        in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );  
        in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );  
        in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );  
        in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );  
    #else  
        in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );  
        in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );  
        in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );  
        in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );  
    #endif  
160    
161    void Dudley_Mesh_setOrders(Dudley_Mesh * in)
162    {
163        in->approximationOrder = 1; /* order of shapeFunctions is always 1 in Dudley */
164        in->reducedApproximationOrder = 1;
165        in->integrationOrder = 2;
166        in->reducedIntegrationOrder = 0;
167    
168  }  }
     

Legend:
Removed from v.3080  
changed lines
  Added in v.4332

  ViewVC Help
Powered by ViewVC 1.1.26