1 |
// $Id$ |
2 |
/* |
3 |
****************************************************************************** |
4 |
* * |
5 |
* COPYRIGHT ACcESS 2005 - All Rights Reserved * |
6 |
* * |
7 |
* This software is the property of ACcESS. No part of this code * |
8 |
* may be copied in any form or by any means without the expressed written * |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
10 |
* by any unauthorised person is illegal unless that person has a software * |
11 |
* license agreement with ACcESS. * |
12 |
* * |
13 |
****************************************************************************** |
14 |
*/ |
15 |
|
16 |
#if !defined bruce_Bruce_20050829_H |
17 |
#define bruce_Bruce_20050829_H |
18 |
|
19 |
#include "escript/Data/AbstractContinuousDomain.h" |
20 |
#include "escript/Data/FunctionSpaceFactory.h" |
21 |
#include "escript/Data/FunctionSpace.h" |
22 |
#include "escript/Data/Data.h" |
23 |
|
24 |
#include <string> |
25 |
#include <vector> |
26 |
|
27 |
namespace bruce { |
28 |
|
29 |
/** |
30 |
\brief |
31 |
Bruce implements the AbstractContinuousDomain |
32 |
interface for the Bruce library. |
33 |
|
34 |
Description: |
35 |
Bruce implements the AbstractContinuousDomain |
36 |
interface for the Bruce library. |
37 |
*/ |
38 |
|
39 |
class Bruce : public escript::AbstractContinuousDomain { |
40 |
|
41 |
public: |
42 |
|
43 |
// |
44 |
// Codes for function space types supported |
45 |
static const int ContinuousFunction; |
46 |
static const int Function; |
47 |
|
48 |
// |
49 |
// Type of FunctionSpaceNamesMap |
50 |
typedef std::map<int, std::string> FunctionSpaceNamesMapType; |
51 |
|
52 |
// |
53 |
// Types for the dimension vectors |
54 |
typedef std::vector<double> DimVec; |
55 |
|
56 |
/** |
57 |
\brief |
58 |
Default constructor for Bruce. |
59 |
|
60 |
Description: |
61 |
Default constructor for Bruce. |
62 |
Creates a null Bruce object. |
63 |
*/ |
64 |
Bruce(); |
65 |
|
66 |
/** |
67 |
\brief |
68 |
Constructor for Bruce. |
69 |
|
70 |
Description: |
71 |
Constructor for Bruce. |
72 |
|
73 |
The point "origin" specifies the location of the origin |
74 |
of the domain specified by this object. The dimensionality of this |
75 |
point determines the dimensionality of the space the domain occupies. |
76 |
|
77 |
The vectors v0,v1,v2 specify the axis in |
78 |
of the domain of this Bruce object. If v2 is an empty vector, this |
79 |
object is a two dimensional domain. If v1 is also an empty vector, |
80 |
this object is a one dimensional domain. If v0 is also an empty |
81 |
vector, this is a point domain. |
82 |
|
83 |
The integers n0,n1,n2 specify the dumber of data-points along each |
84 |
axis in the domain. |
85 |
*/ |
86 |
Bruce(DimVec v0, DimVec v1, DimVec v2, |
87 |
int n0, int n1, int n2, |
88 |
DimVec origin); |
89 |
|
90 |
/** |
91 |
\brief |
92 |
Copy constructor. |
93 |
*/ |
94 |
Bruce(const Bruce& other); |
95 |
|
96 |
/** |
97 |
\brief |
98 |
Destructor for Bruce. |
99 |
*/ |
100 |
~Bruce(); |
101 |
|
102 |
/** |
103 |
\brief |
104 |
Return this as an AbstractContinuousDomain. |
105 |
*/ |
106 |
inline |
107 |
const AbstractContinuousDomain& |
108 |
asAbstractContinuousDomain() const |
109 |
{ |
110 |
return *(static_cast<const AbstractContinuousDomain*>(this)); |
111 |
} |
112 |
|
113 |
/** |
114 |
\brief |
115 |
Return this as an AbstractDomain. |
116 |
*/ |
117 |
inline |
118 |
const AbstractDomain& |
119 |
asAbstractDomain() const |
120 |
{ |
121 |
return *(static_cast<const AbstractDomain*>(this)); |
122 |
} |
123 |
|
124 |
/** |
125 |
\brief |
126 |
Return a description for this domain. |
127 |
*/ |
128 |
virtual |
129 |
std::string |
130 |
getDescription() const; |
131 |
|
132 |
/** |
133 |
\brief |
134 |
Returns true if the given integer is a valid function space type |
135 |
for this domain. |
136 |
*/ |
137 |
virtual |
138 |
bool |
139 |
isValidFunctionSpaceType(int functionSpaceCode) const; |
140 |
|
141 |
/** |
142 |
\brief |
143 |
Return a description for the given function space type code. |
144 |
*/ |
145 |
virtual |
146 |
std::string |
147 |
functionSpaceTypeAsString(int functionSpaceCode) const; |
148 |
|
149 |
/** |
150 |
\brief |
151 |
Return a continuous FunctionSpace code. |
152 |
*/ |
153 |
virtual |
154 |
int |
155 |
getContinuousFunctionCode() const; |
156 |
|
157 |
/** |
158 |
\brief |
159 |
Return a function FunctionSpace code. |
160 |
*/ |
161 |
virtual |
162 |
int |
163 |
getFunctionCode() const; |
164 |
|
165 |
/** |
166 |
\brief |
167 |
Return the spatial dimension of the mesh. |
168 |
*/ |
169 |
virtual |
170 |
int |
171 |
getDim() const; |
172 |
|
173 |
/** |
174 |
\brief |
175 |
Return the number of data points per sample, and the number of samples |
176 |
needed to represent data on parts of the mesh. |
177 |
*/ |
178 |
virtual |
179 |
std::pair<int,int> |
180 |
getDataShape(int functionSpaceCode) const; |
181 |
|
182 |
/** |
183 |
\brief |
184 |
Returns the locations in the domain of the FEM nodes. |
185 |
*/ |
186 |
virtual |
187 |
escript::Data |
188 |
getX() const; |
189 |
|
190 |
/** |
191 |
\brief |
192 |
Copies the location of data points on the domain into out. |
193 |
*/ |
194 |
virtual |
195 |
void |
196 |
setToX(escript::Data& out) const; |
197 |
|
198 |
/** |
199 |
\brief |
200 |
Returns the element size. |
201 |
*/ |
202 |
virtual |
203 |
escript::Data |
204 |
getSize() const; |
205 |
|
206 |
/** |
207 |
\brief |
208 |
Copies the size of samples into out. |
209 |
*/ |
210 |
virtual |
211 |
void |
212 |
setToSize(escript::Data& out) const; |
213 |
|
214 |
/** |
215 |
\brief |
216 |
Comparison operators. |
217 |
*/ |
218 |
virtual bool operator==(const AbstractDomain& other) const; |
219 |
virtual bool operator!=(const AbstractDomain& other) const; |
220 |
|
221 |
protected: |
222 |
|
223 |
/** |
224 |
\brief |
225 |
Build the table of function space type names. |
226 |
*/ |
227 |
void |
228 |
setFunctionSpaceTypeNames(); |
229 |
|
230 |
/** |
231 |
\brief |
232 |
Ensure the parameters supplied to the constructor are valid. |
233 |
*/ |
234 |
bool |
235 |
checkParameters(); |
236 |
|
237 |
/** |
238 |
\brief |
239 |
Check if all components of vector are zero. |
240 |
*/ |
241 |
bool |
242 |
isZero(DimVec vec) const; |
243 |
|
244 |
private: |
245 |
|
246 |
// |
247 |
// vectors describing axis of the domain |
248 |
DimVec m_v0, m_v1, m_v2; |
249 |
|
250 |
// |
251 |
// number of data points in each axial direction of the domain |
252 |
int m_n0, m_n1, m_n2; |
253 |
|
254 |
// |
255 |
// the coordinates of the origin of the domain |
256 |
DimVec m_origin; |
257 |
|
258 |
// |
259 |
// map from FunctionSpace codes to names |
260 |
static FunctionSpaceNamesMapType m_functionSpaceTypeNames; |
261 |
|
262 |
}; |
263 |
|
264 |
} // end of namespace |
265 |
|
266 |
#endif |