/[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/esys2/finley/src/finleyC/Mesh.c revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC branches/domexper/dudley/src/Mesh.c revision 3251 by jfenwick, Thu Oct 7 04:02:30 2010 UTC
# Line 1  Line 1 
1  /**************************************************************/  /*******************************************************
2    *
3  /*   Finley: Mesh */  * Copyright (c) 2003-2010 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    
13  /**************************************************************/  /**************************************************************/
14    
15  /*   Copyrights by ACcESS Australia 2003,04 */  /*   Dudley: Mesh */
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$ */  
16    
17  /**************************************************************/  /**************************************************************/
18    
 #include "Finley.h"  
19  #include "Mesh.h"  #include "Mesh.h"
20    
21  /**************************************************************/  /**************************************************************/
# Line 18  Line 23 
23  /*   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, */
24  /*   the most appropriate order is selected indepently. */  /*   the most appropriate order is selected indepently. */
25    
26  extern Finley_RefElementInfo Finley_RefElement_InfoList[];  Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
27    {
28  Finley_Mesh* Finley_Mesh_alloc(char* name,int numDim, int order) {      Dudley_Mesh *out;
29    Finley_Mesh *out;  
30          /*  allocate the return value */
31    /*  allocate the return value */  
32          out = MEMALLOC(1, Dudley_Mesh);
33    out=MEMALLOC(1,Finley_Mesh);      if (Dudley_checkPtr(out))
34    if (Finley_checkPtr(out)) return NULL;      return NULL;
35    out->Name=NULL;        out->Name = NULL;
36    out->Nodes=NULL;      out->Nodes = NULL;
37    out->Elements=NULL;        out->Elements = NULL;
38    out->FaceElements=NULL;      out->FaceElements = NULL;
39    out->Points=NULL;            out->Points = NULL;
40    out->ContactElements=NULL;            out->TagMap = NULL;
41    out->reference_counter=0;      out->reference_counter = 0;
42    
43    out->FullFullPattern=NULL;      out->FullFullPattern = NULL;
44    out->FullReducedPattern=NULL;      out->FullReducedPattern = NULL;
45    out->ReducedFullPattern=NULL;      out->ReducedFullPattern = NULL;
46    out->ReducedReducedPattern=NULL;      out->ReducedReducedPattern = NULL;
47          out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
48    /*   copy name: */      if (!Dudley_noError())
49          {
50    out->Name=MEMALLOC(strlen(name)+1,char);      Dudley_Mesh_free(out);
51    if (Finley_checkPtr(out->Name)) {      return NULL;
52        Finley_Mesh_dealloc(out);      }
53        return NULL;      /*   copy name: */
54    }  
55    strcpy(out->Name,name);      out->Name = MEMALLOC(strlen(name) + 1, char);
56          if (Dudley_checkPtr(out->Name))
57    /*   allocate node table: */      {
58          Dudley_Mesh_free(out);
59    out->Nodes=Finley_NodeFile_alloc(numDim);      return NULL;
60    if (Finley_ErrorCode!=NO_ERROR) {      }
61        Finley_Mesh_dealloc(out);      strcpy(out->Name, name);
62        return NULL;  
63    }      /*   allocate node table: */
64    out->order=order;      out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
65    out->Elements=NULL;      if (!Dudley_noError())
66    out->FaceElements=NULL;      {
67    out->Points=NULL;      Dudley_Mesh_free(out);
68    out->ContactElements=NULL;      return NULL;
69    out->reference_counter++;      }
70    return out;      out->approximationOrder = -1;
71  }      out->reducedApproximationOrder = -1;
72        out->integrationOrder = -1;
73  /* returns a reference to Finley_Mesh in */      out->reducedIntegrationOrder = -1;
74    
75  Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {      out->Elements = NULL;
76       if (in!=NULL) ++(in->reference_counter);      out->FaceElements = NULL;
77       return in;      out->Points = NULL;
78  }      out->reference_counter++;
79        return out;
80  /*   deallocates a mesh: */  }
81    
82  void Finley_Mesh_dealloc(Finley_Mesh* in) {  /* returns a reference to Dudley_Mesh in */
83    if (in!=NULL) {  
84       in->reference_counter--;  Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
85       if (in->reference_counter<1) {  {
86         #ifdef Finley_TRACE      if (in != NULL)
87         if (in->Name!=NULL) {      ++(in->reference_counter);
88             printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);      return in;
89         } else {  }
90             printf("Finley_Mesh_dealloc\n");  
91         }  /*   frees a mesh: */
92         #endif  
93         MEMFREE(in->Name);  void Dudley_Mesh_free(Dudley_Mesh * in)
94         Finley_NodeFile_dealloc(in->Nodes);  {
95         Finley_ElementFile_dealloc(in->Elements);        if (in != NULL)
96         Finley_ElementFile_dealloc(in->FaceElements);      {
97         Finley_ElementFile_dealloc(in->ContactElements);      in->reference_counter--;
98         Finley_ElementFile_dealloc(in->Points);      if (in->reference_counter < 1)
99         Finley_SystemMatrixPattern_dealloc(in->FullFullPattern);      {
100         Finley_SystemMatrixPattern_dealloc(in->FullReducedPattern);          MEMFREE(in->Name);
101         Finley_SystemMatrixPattern_dealloc(in->ReducedFullPattern);          Dudley_NodeFile_free(in->Nodes);
102         Finley_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);          Dudley_ElementFile_free(in->FaceElements);
103         MEMFREE(in);                Dudley_ElementFile_free(in->Elements);
104       }          Dudley_ElementFile_free(in->Points);
105    }          Dudley_TagMap_free(in->TagMap);
106            Paso_SystemMatrixPattern_free(in->FullFullPattern);
107            Paso_SystemMatrixPattern_free(in->FullReducedPattern);
108            Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
109            Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
110            Esys_MPIInfo_free(in->MPIInfo);
111            MEMFREE(in);
112        }
113        }
114  }  }
115    
116  /**************************************************************/  /**************************************************************/
117    
118  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
119    
120  int Finley_Mesh_getDim(Finley_Mesh *in) {  dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
121    return in->Nodes->numDim;  {
122  }      return in->Nodes->numDim;
123    }
124  /**************************************************************/  
125    void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
126    {
127        Dudley_ElementFile_free(self->Elements);
128        self->Elements = elements;
129    }
130    
131    void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
132    {
133        Dudley_ElementFile_free(self->FaceElements);
134        self->FaceElements = elements;
135    }
136    
137    void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
138    {
139        Dudley_ElementFile_free(self->Points);
140        self->Points = elements;
141    }
142    
143    int Dudley_Mesh_getStatus(Dudley_Mesh * in)
144    {
145        if (in == NULL)
146        {
147        return -1;
148        }
149        else if (in->Nodes == NULL)
150        {
151        return -1;
152        }
153        else
154        {
155        return in->Nodes->status;
156        }
157    }
158    
159    void Dudley_Mesh_setOrders(Dudley_Mesh * in)
160    {
161        in->approximationOrder = 1; /* order of shapeFunctions is always 1 in Dudley */
162        in->reducedApproximationOrder = 1;
163        in->integrationOrder = 2;
164        in->reducedIntegrationOrder = 0;
165    
 /*  returns the number of nodes in the mesh: */  
   
 int Finley_Mesh_getNumNodes(Finley_Mesh *in) {  
   return in->Nodes->numNodes;  
166  }  }
 /**************************************************************/  
   
 /*  returns the number of degrees of freedom in the mesh: */  
   
 int Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->numDegreesOfFreedom;  
 }  
 /**************************************************************/  
   
 /*  returns the number of degrees of freedom in the mesh: */  
   
 int Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
 }  
 /*  
 * $Log$  
 * Revision 1.4  2004/12/15 07:08:32  jgs  
 * *** empty log message ***  
 *  
 *  
 *  
 */  

Legend:
Removed from v.102  
changed lines
  Added in v.3251

  ViewVC Help
Powered by ViewVC 1.1.26