/[escript]/branches/doubleplusgood/dudley/src/Mesh.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/dudley/src/Mesh.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4345 - (hide annotations)
Fri Mar 29 07:09:41 2013 UTC (5 years, 11 months ago) by jfenwick
File size: 4307 byte(s)
Spelling fixes
1 jfenwick 3981 /*****************************************************************************
2 ksteube 1811 *
3 jfenwick 4154 * Copyright (c) 2003-2013 by University of Queensland
4 jfenwick 3981 * http://www.uq.edu.au
5 ksteube 1811 *
6     * Primary Business: Queensland, Australia
7     * Licensed under the Open Software License version 3.0
8     * http://www.opensource.org/licenses/osl-3.0.php
9     *
10 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11     * Development since 2012 by School of Earth Sciences
12     *
13     *****************************************************************************/
14 ksteube 1312
15 jfenwick 3981 /************************************************************************************/
16 jgs 82
17 jfenwick 3086 /* Dudley: Mesh */
18 jgs 82
19 jfenwick 3981 /************************************************************************************/
20 jgs 82
21     #include "Mesh.h"
22    
23 jfenwick 3981 /************************************************************************************/
24 jgs 82
25     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
26 jfenwick 4345 /* the most appropriate order is selected independently. */
27 jgs 82
28 jfenwick 3227 Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
29 bcumming 730 {
30 jfenwick 3224 Dudley_Mesh *out;
31 jgs 102
32 jfenwick 3224 /* allocate the return value */
33 gross 2856
34 jfenwick 4332 out = new Dudley_Mesh;
35 jfenwick 3224 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 jfenwick 3227 out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
50 jfenwick 3224 if (!Dudley_noError())
51     {
52     Dudley_Mesh_free(out);
53     return NULL;
54     }
55     /* copy name: */
56    
57 jfenwick 4332 out->Name = new char[strlen(name) + 1];
58 jfenwick 3224 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 jgs 82 }
83    
84 jfenwick 3086 /* returns a reference to Dudley_Mesh in */
85 jgs 102
86 jfenwick 3224 Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
87     {
88     if (in != NULL)
89     ++(in->reference_counter);
90     return in;
91 jgs 102 }
92    
93 jfenwick 3227 /* frees a mesh: */
94 jgs 82
95 jfenwick 3224 void Dudley_Mesh_free(Dudley_Mesh * in)
96     {
97     if (in != NULL)
98     {
99     in->reference_counter--;
100     if (in->reference_counter < 1)
101     {
102 jfenwick 4332 delete[] in->Name;
103 jfenwick 3224 Dudley_NodeFile_free(in->Nodes);
104     Dudley_ElementFile_free(in->FaceElements);
105     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 jfenwick 3227 Esys_MPIInfo_free(in->MPIInfo);
113 jfenwick 4332 delete in;
114 jfenwick 3224 }
115     }
116 jgs 82 }
117    
118 jfenwick 3981 /************************************************************************************/
119 jgs 82
120     /* returns the spatial dimension of the mesh: */
121    
122 jfenwick 3224 dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
123     {
124     return in->Nodes->numDim;
125 jgs 82 }
126    
127 jfenwick 3224 void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
128     {
129 jfenwick 3086 Dudley_ElementFile_free(self->Elements);
130 jfenwick 3224 self->Elements = elements;
131 jgs 82 }
132 jfenwick 3224
133     void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
134     {
135 jfenwick 3086 Dudley_ElementFile_free(self->FaceElements);
136 jfenwick 3224 self->FaceElements = elements;
137 jgs 82 }
138 jfenwick 3224
139     void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
140     {
141 jfenwick 3086 Dudley_ElementFile_free(self->Points);
142 jfenwick 3224 self->Points = elements;
143 ksteube 1312 }
144 jfenwick 3224
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 gross 2533 }
160 gross 2856
161 caltinay 3247 void Dudley_Mesh_setOrders(Dudley_Mesh * in)
162 gross 2856 {
163 jfenwick 3251 in->approximationOrder = 1; /* order of shapeFunctions is always 1 in Dudley */
164 jfenwick 3224 in->reducedApproximationOrder = 1;
165     in->integrationOrder = 2;
166     in->reducedIntegrationOrder = 0;
167 gross 2856
168     }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26