/[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 730 by bcumming, Mon May 15 04:03:49 2006 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 2006 by ACcESS MNRF                   *  * Copyright (c) 2003-2010 by University of Queensland
4   *                                                          *  * Earth Systems Science Computational Center (ESSCC)
5   *              http://www.access.edu.au                    *  * http://www.uq.edu.au/esscc
6   *       Primary Business: Queensland, Australia            *  *
7   *  Licensed under the Open Software License version 3.0    *  * Primary Business: Queensland, Australia
8   *     http://www.opensource.org/licenses/osl-3.0.php       *  * Licensed under the Open Software License version 3.0
9   *                                                          *  * http://www.opensource.org/licenses/osl-3.0.php
10   ************************************************************  *
11  */  *******************************************************/
   
 /**************************************************************/  
   
 /*   Finley: Mesh */  
12    
13  /**************************************************************/  /**************************************************************/
14    
15  /*  Author: gross@access.edu.au */  /*   Dudley: Mesh */
 /*  Version: $Id$ */  
16    
17  /**************************************************************/  /**************************************************************/
18    
# Line 28  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  #ifndef PASO_MPI      out = MEMALLOC(1, Dudley_Mesh);
33  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order)      if (Dudley_checkPtr(out))
34  #else      return NULL;
35  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, Paso_MPIInfo *mpi_info)      out->Name = NULL;
36  #endif      out->Nodes = NULL;
37  {      out->Elements = NULL;
38    Finley_Mesh *out;      out->FaceElements = NULL;
39          out->Points = NULL;
40    /*  allocate the return value */      out->TagMap = NULL;
41          out->reference_counter = 0;
42    out=MEMALLOC(1,Finley_Mesh);  
43    if (Finley_checkPtr(out)) return NULL;      out->FullFullPattern = NULL;
44    out->Name=NULL;        out->FullReducedPattern = NULL;
45    out->Nodes=NULL;      out->ReducedFullPattern = NULL;
46    out->Elements=NULL;        out->ReducedReducedPattern = NULL;
47    out->FaceElements=NULL;      out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
48    out->Points=NULL;            if (!Dudley_noError())
49    out->ContactElements=NULL;            {
50    out->reference_counter=0;      Dudley_Mesh_free(out);
51        return NULL;
52    out->FullFullPattern=NULL;      }
53    out->FullReducedPattern=NULL;      /*   copy name: */
54    out->ReducedFullPattern=NULL;  
55    out->ReducedReducedPattern=NULL;      out->Name = MEMALLOC(strlen(name) + 1, char);
56        if (Dudley_checkPtr(out->Name))
57  #ifdef PASO_MPI      {
58    out->MPIInfo = NULL;      Dudley_Mesh_free(out);
59        return NULL;
60    /* get MPI info */      }
61    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );      strcpy(out->Name, name);
62    if (! Finley_noError()) {  
63        Finley_Mesh_dealloc(out);      /*   allocate node table: */
64        return NULL;      out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
65    }      if (!Dudley_noError())
66  #endif      {
67    /*   copy name: */      Dudley_Mesh_free(out);
68          return NULL;
69    out->Name=MEMALLOC(strlen(name)+1,char);      }
70    if (Finley_checkPtr(out->Name)) {      out->approximationOrder = -1;
71        Finley_Mesh_dealloc(out);      out->reducedApproximationOrder = -1;
72        return NULL;      out->integrationOrder = -1;
73    }      out->reducedIntegrationOrder = -1;
74    strcpy(out->Name,name);  
75          out->Elements = NULL;
76    /*   allocate node table: */      out->FaceElements = NULL;
77  #ifdef PASO_MPI      out->Points = NULL;
78    out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );      out->reference_counter++;
79  #else      return out;
   out->Nodes=Finley_NodeFile_alloc(numDim);  
 #endif  
   if (! Finley_noError()) {  
       Finley_Mesh_dealloc(out);  
       return NULL;  
   }  
   out->order=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;  
 }  
   
 /*   deallocates a mesh: */  
   
 void Finley_Mesh_dealloc(Finley_Mesh* in) {  
   if (in!=NULL) {  
      in->reference_counter--;  
      if (in->reference_counter<1) {  
        #ifdef Finley_TRACE  
        if (in->Name!=NULL) {  
            printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);  
        } else {  
            printf("Finley_Mesh_dealloc\n");  
        }  
        #endif  
        MEMFREE(in->Name);  
        Finley_NodeFile_dealloc(in->Nodes);  
        Finley_ElementFile_dealloc(in->Elements);    
        Finley_ElementFile_dealloc(in->FaceElements);  
        Finley_ElementFile_dealloc(in->ContactElements);  
        Finley_ElementFile_dealloc(in->Points);  
        Paso_SystemMatrixPattern_dealloc(in->FullFullPattern);  
        Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);  
        Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);  
        Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);  
 #ifdef PASO_MPI  
        Paso_MPIInfo_dealloc( in->MPIInfo );  
 #endif  
        MEMFREE(in);        
      }  
   }  
80  }  }
81    
82  /**************************************************************/  /* returns a reference to Dudley_Mesh in */
83    
84  /*  returns the spatial dimension of the mesh: */  Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
85    {
86        if (in != NULL)
87        ++(in->reference_counter);
88        return in;
89    }
90    
91  dim_t Finley_Mesh_getDim(Finley_Mesh *in) {  /*   frees a mesh: */
92    return in->Nodes->numDim;  
93    void Dudley_Mesh_free(Dudley_Mesh * in)
94    {
95        if (in != NULL)
96        {
97        in->reference_counter--;
98        if (in->reference_counter < 1)
99        {
100            MEMFREE(in->Name);
101            Dudley_NodeFile_free(in->Nodes);
102            Dudley_ElementFile_free(in->FaceElements);
103            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 number of nodes in the mesh: */  /*  returns the spatial dimension of the mesh: */
119    
120  dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {  dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
121    return in->Nodes->numNodes;  {
122        return in->Nodes->numDim;
123  }  }
 /**************************************************************/  
124    
125  /*  returns the number of degrees of freedom in the mesh: */  void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
126    {
127        Dudley_ElementFile_free(self->Elements);
128        self->Elements = elements;
129    }
130    
131  dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {  void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
132    return in->Nodes->numDegreesOfFreedom;  {
133        Dudley_ElementFile_free(self->FaceElements);
134        self->FaceElements = elements;
135  }  }
 /**************************************************************/  
136    
137  /*  returns the number of degrees of freedom in the mesh: */  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    
 dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
166  }  }
 /*  
 * $Log$  
 * Revision 1.6  2005/09/15 03:44:22  jgs  
 * Merge of development branch dev-02 back to main trunk on 2005-09-15  
 *  
 * Revision 1.5.2.1  2005/09/07 06:26:19  gross  
 * the solver from finley are put into the standalone package paso now  
 *  
 * Revision 1.5  2005/07/08 04:07:51  jgs  
 * Merge of development branch back to main trunk on 2005-07-08  
 *  
 * Revision 1.4  2004/12/15 07:08:32  jgs  
 * *** empty log message ***  
 * Revision 1.1.1.1.2.3  2005/06/29 02:34:51  gross  
 * some changes towards 64 integers in finley  
 *  
 * Revision 1.1.1.1.2.2  2004/11/24 01:37:13  gross  
 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
 *  
 *  
 *  
 */  

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

  ViewVC Help
Powered by ViewVC 1.1.26