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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4332 - (show annotations)
Thu Mar 21 04:21:14 2013 UTC (6 years, 1 month ago) by jfenwick
File size: 4304 byte(s)
like sand though the hourglass
1 /*****************************************************************************
2 *
3 * Copyright (c) 2003-2013 by University of Queensland
4 * http://www.uq.edu.au
5 *
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 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 * Development since 2012 by School of Earth Sciences
12 *
13 *****************************************************************************/
14
15 /************************************************************************************/
16
17 /* Dudley: Mesh */
18
19 /************************************************************************************/
20
21 #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, */
26 /* the most appropriate order is selected indepently. */
27
28 Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info)
29 {
30 Dudley_Mesh *out;
31
32 /* allocate the return value */
33
34 out = new Dudley_Mesh;
35 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 out->MPIInfo = Esys_MPIInfo_getReference(mpi_info);
50 if (!Dudley_noError())
51 {
52 Dudley_Mesh_free(out);
53 return NULL;
54 }
55 /* copy name: */
56
57 out->Name = new char[strlen(name) + 1];
58 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 }
83
84 /* returns a reference to Dudley_Mesh in */
85
86 Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh * in)
87 {
88 if (in != NULL)
89 ++(in->reference_counter);
90 return in;
91 }
92
93 /* frees a mesh: */
94
95 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 delete[] in->Name;
103 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 Esys_MPIInfo_free(in->MPIInfo);
113 delete in;
114 }
115 }
116 }
117
118 /************************************************************************************/
119
120 /* returns the spatial dimension of the mesh: */
121
122 dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
123 {
124 return in->Nodes->numDim;
125 }
126
127 void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
128 {
129 Dudley_ElementFile_free(self->Elements);
130 self->Elements = elements;
131 }
132
133 void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
134 {
135 Dudley_ElementFile_free(self->FaceElements);
136 self->FaceElements = elements;
137 }
138
139 void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements)
140 {
141 Dudley_ElementFile_free(self->Points);
142 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
168 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26