/[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 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (8 years, 5 months ago) by jfenwick
Original Path: trunk/dudley/src/Mesh.c
File MIME type: text/plain
File size: 4113 byte(s)
Merging dudley and scons updates from branches

1 /*******************************************************
2 *
3 * Copyright (c) 2003-2010 by University of Queensland
4 * Earth Systems Science Computational Center (ESSCC)
5 * http://www.uq.edu.au/esscc
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 *******************************************************/
12
13 /**************************************************************/
14
15 /* Dudley: Mesh */
16
17 /**************************************************************/
18
19 #include "Mesh.h"
20
21 /**************************************************************/
22
23 /* 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. */
25
26 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 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 if (in != NULL)
87 ++(in->reference_counter);
88 return in;
89 }
90
91 /* frees a mesh: */
92
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 spatial dimension of the mesh: */
119
120 dim_t Dudley_Mesh_getDim(Dudley_Mesh * in)
121 {
122 return in->Nodes->numDim;
123 }
124
125 void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
126 {
127 Dudley_ElementFile_free(self->Elements);
128 self->Elements = elements;
129 }
130
131 void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements)
132 {
133 Dudley_ElementFile_free(self->FaceElements);
134 self->FaceElements = elements;
135 }
136
137 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
166 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26