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

trunk/finley/src/Mesh.c revision 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC branches/doubleplusgood/dudley/src/Mesh.c revision 4257 by jfenwick, Wed Feb 27 03:42:40 2013 UTC
# Line 1  Line 1 
1    /*****************************************************************************
 /*******************************************************  
2  *  *
3  * Copyright (c) 2003-2008 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  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
29    {
30        Dudley_Mesh *out;
31    
32        /*  allocate the return value */
33    
34        out = MEMALLOC(1, Dudley_Mesh);
35        if (Dudley_checkPtr(out))
36        return NULL;
37        out->Name = NULL;
38        out->Nodes = NULL;
39        out->Elements = NULL;
40        out->FaceElements = NULL;
41        out->Points = NULL;
42        out->TagMap = NULL;
43        out->reference_counter = 0;
44    
45        out->FullFullPattern = NULL;
46        out->FullReducedPattern = NULL;
47        out->ReducedFullPattern = NULL;
48        out->ReducedReducedPattern = NULL;
49        out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
50        if (!Dudley_noError())
51        {
52        Dudley_Mesh_free(out);
53        return NULL;
54        }
55        /*   copy name: */
56    
57        out->Name = MEMALLOC(strlen(name) + 1, char);
58        if (Dudley_checkPtr(out->Name))
59        {
60        Dudley_Mesh_free(out);
61        return NULL;
62        }
63        strcpy(out->Name, name);
64    
65        /*   allocate node table: */
66        out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
67        if (!Dudley_noError())
68        {
69        Dudley_Mesh_free(out);
70        return NULL;
71        }
72        out->approximationOrder = -1;
73        out->reducedApproximationOrder = -1;
74        out->integrationOrder = -1;
75        out->reducedIntegrationOrder = -1;
76    
77        out->Elements = NULL;
78        out->FaceElements = NULL;
79        out->Points = NULL;
80        out->reference_counter++;
81        return out;
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  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)  void Dudley_Mesh_free(Dudley_Mesh * in)
96  {  {
97    Finley_Mesh *out;      if (in != NULL)
98          {
99    /*  allocate the return value */      in->reference_counter--;
100          if (in->reference_counter < 1)
101    out=MEMALLOC(1,Finley_Mesh);      {
102    if (Finley_checkPtr(out)) return NULL;          MEMFREE(in->Name);
103    out->Name=NULL;            Dudley_NodeFile_free(in->Nodes);
104    out->Nodes=NULL;          Dudley_ElementFile_free(in->FaceElements);
105    out->Elements=NULL;            Dudley_ElementFile_free(in->Elements);
106    out->FaceElements=NULL;          Dudley_ElementFile_free(in->Points);
107    out->Points=NULL;                Dudley_TagMap_free(in->TagMap);
108    out->ContactElements=NULL;                Paso_SystemMatrixPattern_free(in->FullFullPattern);
109    out->TagMap=NULL;                Paso_SystemMatrixPattern_free(in->FullReducedPattern);
110    out->reference_counter=0;          Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
111            Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
112    out->FullFullPattern=NULL;          Esys_MPIInfo_free(in->MPIInfo);
113    out->FullReducedPattern=NULL;          MEMFREE(in);
114    out->ReducedFullPattern=NULL;      }
115    out->ReducedReducedPattern=NULL;      }
   out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );  
   if (! Finley_noError()) {  
       Finley_Mesh_free(out);  
       return NULL;  
   }  
   /*   copy name: */  
     
   out->Name=MEMALLOC(strlen(name)+1,char);  
   if (Finley_checkPtr(out->Name)) {  
       Finley_Mesh_free(out);  
       return NULL;  
   }  
   strcpy(out->Name,name);  
     
   /*   allocate node table: */  
   out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );  
   if (! Finley_noError()) {  
       Finley_Mesh_free(out);  
       return NULL;  
   }  
   out->order=order;  
   out->reduced_order=reduced_order;  
   out->Elements=NULL;  
   out->FaceElements=NULL;  
   out->Points=NULL;  
   out->ContactElements=NULL;  
   out->reference_counter++;  
   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) {  
        #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  
        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);        
      }  
   }  
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  }  }
132  void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {  
133      Finley_ElementFile_free(self->FaceElements);  void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
134      self->FaceElements=elements;  {
135        Dudley_ElementFile_free(self->FaceElements);
136        self->FaceElements = elements;
137  }  }
138  void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {  
139      Finley_ElementFile_free(self->ContactElements);  void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
140      self->ContactElements=elements;  {
141        Dudley_ElementFile_free(self->Points);
142        self->Points = elements;
143  }  }
144  void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {  
145      Finley_ElementFile_free(self->Points);  int Dudley_Mesh_getStatus(Dudley_Mesh * in)
146      self->Points=elements;  {
147        if (in == NULL)
148        {
149        return -1;
150        }
151        else if (in->Nodes == NULL)
152        {
153        return -1;
154        }
155        else
156        {
157        return in->Nodes->status;
158        }
159  }  }
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.1811  
changed lines
  Added in v.4257

  ViewVC Help
Powered by ViewVC 1.1.26