/[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 2548 by jfenwick, Mon Jul 20 06:20:06 2009 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  * Copyright (c) 2003-2009 by University of Queensland  * Copyright (c) 2003-2010 by University of Queensland
4  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
5  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
6  *  *
# Line 10  Line 10 
10  *  *
11  *******************************************************/  *******************************************************/
12    
   
13  /**************************************************************/  /**************************************************************/
14    
15  /*   Finley: Mesh */  /*   Dudley: Mesh */
16    
17  /**************************************************************/  /**************************************************************/
18    
# Line 24  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        Dudley_Mesh *out;
29    
30        /*  allocate the return value */
31    
32  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)      out = MEMALLOC(1, Dudley_Mesh);
33        if (Dudley_checkPtr(out))
34        return NULL;
35        out->Name = NULL;
36        out->Nodes = NULL;
37        out->Elements = NULL;
38        out->FaceElements = NULL;
39        out->Points = NULL;
40        out->TagMap = NULL;
41        out->reference_counter = 0;
42    
43        out->FullFullPattern = NULL;
44        out->FullReducedPattern = NULL;
45        out->ReducedFullPattern = NULL;
46        out->ReducedReducedPattern = NULL;
47        out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
48        if (!Dudley_noError())
49        {
50        Dudley_Mesh_free(out);
51        return NULL;
52        }
53        /*   copy name: */
54    
55        out->Name = MEMALLOC(strlen(name) + 1, char);
56        if (Dudley_checkPtr(out->Name))
57        {
58        Dudley_Mesh_free(out);
59        return NULL;
60        }
61        strcpy(out->Name, name);
62    
63        /*   allocate node table: */
64        out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
65        if (!Dudley_noError())
66        {
67        Dudley_Mesh_free(out);
68        return NULL;
69        }
70        out->approximationOrder = -1;
71        out->reducedApproximationOrder = -1;
72        out->integrationOrder = -1;
73        out->reducedIntegrationOrder = -1;
74    
75        out->Elements = NULL;
76        out->FaceElements = NULL;
77        out->Points = NULL;
78        out->reference_counter++;
79        return out;
80    }
81    
82    /* returns a reference to Dudley_Mesh in */
83    
84    Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
85  {  {
86    Finley_Mesh *out;      if (in != NULL)
87          ++(in->reference_counter);
88    /*  allocate the return value */      return in;
89      }
90    out=MEMALLOC(1,Finley_Mesh);  
91    if (Finley_checkPtr(out)) return NULL;  /*   frees a mesh: */
92    out->Name=NULL;    
93    out->Nodes=NULL;  void Dudley_Mesh_free(Dudley_Mesh * in)
94    out->Elements=NULL;    {
95    out->FaceElements=NULL;      if (in != NULL)
96    out->Points=NULL;            {
97    out->ContactElements=NULL;            in->reference_counter--;
98    out->TagMap=NULL;            if (in->reference_counter < 1)
99    out->reference_counter=0;      {
100            MEMFREE(in->Name);
101    out->FullFullPattern=NULL;          Dudley_NodeFile_free(in->Nodes);
102    out->FullReducedPattern=NULL;          Dudley_ElementFile_free(in->FaceElements);
103    out->ReducedFullPattern=NULL;          Dudley_ElementFile_free(in->Elements);
104    out->ReducedReducedPattern=NULL;          Dudley_ElementFile_free(in->Points);
105    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );          Dudley_TagMap_free(in->TagMap);
106    if (! Finley_noError()) {          Paso_SystemMatrixPattern_free(in->FullFullPattern);
107        Finley_Mesh_free(out);          Paso_SystemMatrixPattern_free(in->FullReducedPattern);
108        return NULL;          Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
109    }          Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
110    /*   copy name: */          Esys_MPIInfo_free(in->MPIInfo);
111              MEMFREE(in);
112    out->Name=MEMALLOC(strlen(name)+1,char);      }
113    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);        
      }  
   }  
114  }  }
115    
116  /**************************************************************/  /**************************************************************/
117    
118  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
119    
120  dim_t 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 Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
126      Finley_ElementFile_free(self->Elements);  {
127      self->Elements=elements;      Dudley_ElementFile_free(self->Elements);
128  }      self->Elements = elements;
129  void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {  }
130      Finley_ElementFile_free(self->FaceElements);  
131      self->FaceElements=elements;  void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
132  }  {
133  void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {      Dudley_ElementFile_free(self->FaceElements);
134      Finley_ElementFile_free(self->ContactElements);      self->FaceElements = elements;
135      self->ContactElements=elements;  }
136  }  
137  void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
138      Finley_ElementFile_free(self->Points);  {
139      self->Points=elements;      Dudley_ElementFile_free(self->Points);
140  }      self->Points = elements;
141  int  Finley_Mesh_getStatus(Finley_Mesh* in) {  }
142     if  (in == NULL) {  
143          return -1;  int Dudley_Mesh_getStatus(Dudley_Mesh * in)
144     } else if (in->Nodes == NULL) {  {
145          return -1;      if (in == NULL)
146     } else {      {
147          return in->Nodes->status;      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    
166  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26