/[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 150 by jgs, Thu Sep 15 03:44:45 2005 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-2013 by University of Queensland
4   *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *  * http://www.uq.edu.au
5   *                                                                            *  *
6   * This software is the property of ACcESS. No part of this code              *  * Primary Business: Queensland, Australia
7   * may be copied in any form or by any means without the expressed written    *  * Licensed under the Open Software License version 3.0
8   * consent of ACcESS.  Copying, use or modification of this software          *  * http://www.opensource.org/licenses/osl-3.0.php
9   * by any unauthorised person is illegal unless that person has a software    *  *
10   * license agreement with ACcESS.                                             *  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11   *                                                                            *  * Development since 2012 by School of Earth Sciences
12   ******************************************************************************  *
13  */  *****************************************************************************/
   
 /**************************************************************/  
   
 /*   Finley: Mesh */  
14    
15  /**************************************************************/  /************************************************************************************/
16    
17  /*  Author: gross@access.edu.au */  /*   Dudley: Mesh */
 /*  Version: $Id$ */  
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  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order) {      Dudley_Mesh *out;
31    Finley_Mesh *out;  
32          /*  allocate the return value */
33    /*  allocate the return value */  
34          out = MEMALLOC(1, Dudley_Mesh);
35    out=MEMALLOC(1,Finley_Mesh);      if (Dudley_checkPtr(out))
36    if (Finley_checkPtr(out)) return NULL;      return NULL;
37    out->Name=NULL;        out->Name = NULL;
38    out->Nodes=NULL;      out->Nodes = NULL;
39    out->Elements=NULL;        out->Elements = NULL;
40    out->FaceElements=NULL;      out->FaceElements = NULL;
41    out->Points=NULL;            out->Points = NULL;
42    out->ContactElements=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 = Esys_MPIInfo_getReference(mpi_info);
50    /*   copy name: */      if (!Dudley_noError())
51          {
52    out->Name=MEMALLOC(strlen(name)+1,char);      Dudley_Mesh_free(out);
53    if (Finley_checkPtr(out->Name)) {      return NULL;
54        Finley_Mesh_dealloc(out);      }
55        return NULL;      /*   copy name: */
56    }  
57    strcpy(out->Name,name);      out->Name = MEMALLOC(strlen(name) + 1, char);
58          if (Dudley_checkPtr(out->Name))
59    /*   allocate node table: */      {
60          Dudley_Mesh_free(out);
61    out->Nodes=Finley_NodeFile_alloc(numDim);      return NULL;
62    if (! Finley_noError()) {      }
63        Finley_Mesh_dealloc(out);      strcpy(out->Name, name);
64        return NULL;  
65    }      /*   allocate node table: */
66    out->order=order;      out->Nodes = Dudley_NodeFile_alloc(numDim, mpi_info);
67    out->Elements=NULL;      if (!Dudley_noError())
68    out->FaceElements=NULL;      {
69    out->Points=NULL;      Dudley_Mesh_free(out);
70    out->ContactElements=NULL;      return NULL;
71    out->reference_counter++;      }
72    return out;      out->approximationOrder = -1;
73  }      out->reducedApproximationOrder = -1;
74        out->integrationOrder = -1;
75  /* returns a reference to Finley_Mesh in */      out->reducedIntegrationOrder = -1;
76    
77  Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {      out->Elements = NULL;
78       if (in!=NULL) ++(in->reference_counter);      out->FaceElements = NULL;
79       return in;      out->Points = NULL;
80  }      out->reference_counter++;
81        return out;
82  /*   deallocates a mesh: */  }
83    
84  void Finley_Mesh_dealloc(Finley_Mesh* in) {  /* returns a reference to Dudley_Mesh in */
85    if (in!=NULL) {  
86       in->reference_counter--;  Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
87       if (in->reference_counter<1) {  {
88         #ifdef Finley_TRACE      if (in != NULL)
89         if (in->Name!=NULL) {      ++(in->reference_counter);
90             printf("Finley_Mesh_dealloc: mesh %s is deallocated.\n",in->Name);      return in;
91         } else {  }
92             printf("Finley_Mesh_dealloc\n");  
93         }  /*   frees a mesh: */
94         #endif  
95         MEMFREE(in->Name);  void Dudley_Mesh_free(Dudley_Mesh * in)
96         Finley_NodeFile_dealloc(in->Nodes);  {
97         Finley_ElementFile_dealloc(in->Elements);        if (in != NULL)
98         Finley_ElementFile_dealloc(in->FaceElements);      {
99         Finley_ElementFile_dealloc(in->ContactElements);      in->reference_counter--;
100         Finley_ElementFile_dealloc(in->Points);      if (in->reference_counter < 1)
101         Paso_SystemMatrixPattern_dealloc(in->FullFullPattern);      {
102         Paso_SystemMatrixPattern_dealloc(in->FullReducedPattern);          MEMFREE(in->Name);
103         Paso_SystemMatrixPattern_dealloc(in->ReducedFullPattern);          Dudley_NodeFile_free(in->Nodes);
104         Paso_SystemMatrixPattern_dealloc(in->ReducedReducedPattern);          Dudley_ElementFile_free(in->FaceElements);
105         MEMFREE(in);                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            MEMFREE(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 Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
128  /*  returns the number of nodes in the mesh: */  {
129        Dudley_ElementFile_free(self->Elements);
130  dim_t Finley_Mesh_getNumNodes(Finley_Mesh *in) {      self->Elements = elements;
131    return in->Nodes->numNodes;  }
132  }  
133  /**************************************************************/  void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
134    {
135  /*  returns the number of degrees of freedom in the mesh: */      Dudley_ElementFile_free(self->FaceElements);
136        self->FaceElements = elements;
137  dim_t Finley_Mesh_getNumDegreesOfFreedom(Finley_Mesh *in) {  }
138    return in->Nodes->numDegreesOfFreedom;  
139  }  void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
140  /**************************************************************/  {
141        Dudley_ElementFile_free(self->Points);
142  /*  returns the number of degrees of freedom in the mesh: */      self->Points = elements;
143    }
144    
145    int Dudley_Mesh_getStatus(Dudley_Mesh * in)
146    {
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    
 dim_t Finley_Mesh_getReducedNumDegreesOfFreedom(Finley_Mesh *in) {  
   return in->Nodes->reducedNumDegreesOfFreedom;  
168  }  }
 /*  
 * $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.150  
changed lines
  Added in v.4257

  ViewVC Help
Powered by ViewVC 1.1.26