1 |
// $Id$ |
2 |
/* |
3 |
************************************************************ |
4 |
* Copyright 2006 by ACcESS MNRF * |
5 |
* * |
6 |
* http://www.access.edu.au * |
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 |
#if !defined bruce_Bruce_20050829_H |
15 |
#define bruce_Bruce_20050829_H |
16 |
#include "system_dep.h" |
17 |
#include "escript/AbstractDomain.h" |
18 |
#include "escript/AbstractContinuousDomain.h" |
19 |
#include "escript/FunctionSpace.h" |
20 |
#include "escript/Data.h" |
21 |
|
22 |
|
23 |
#include <string> |
24 |
#include <vector> |
25 |
|
26 |
namespace bruce { |
27 |
|
28 |
/** |
29 |
\brief |
30 |
Bruce implements a structured AbstractContinuousDomain. |
31 |
|
32 |
Description: |
33 |
Bruce implements a structured AbstractContinuousDomain. |
34 |
*/ |
35 |
|
36 |
class Bruce : public escript::AbstractContinuousDomain { |
37 |
|
38 |
public: |
39 |
|
40 |
// |
41 |
// Codes for function space types supported |
42 |
BRUCE_DLL_API |
43 |
static const int ContinuousFunction; // data is on the nodes |
44 |
BRUCE_DLL_API |
45 |
static const int Function; // data is on the cell centres |
46 |
|
47 |
// |
48 |
// Type of FunctionSpaceNamesMap |
49 |
typedef std::map<int, std::string> FunctionSpaceNamesMapType; |
50 |
|
51 |
// |
52 |
// Types for the dimension vectors |
53 |
typedef std::vector<double> DimVec; |
54 |
|
55 |
/** |
56 |
\brief |
57 |
Default constructor for Bruce. |
58 |
|
59 |
Description: |
60 |
Default constructor for Bruce. |
61 |
Creates a null Bruce object. |
62 |
*/ |
63 |
BRUCE_DLL_API |
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_DLL_API |
87 |
Bruce(DimVec v0, DimVec v1, DimVec v2, |
88 |
int n0, int n1, int n2, |
89 |
DimVec origin); |
90 |
|
91 |
/** |
92 |
\brief |
93 |
Copy constructor. |
94 |
*/ |
95 |
BRUCE_DLL_API |
96 |
Bruce(const Bruce& other); |
97 |
|
98 |
/** |
99 |
\brief |
100 |
Destructor for Bruce. |
101 |
*/ |
102 |
BRUCE_DLL_API |
103 |
~Bruce(); |
104 |
|
105 |
/** |
106 |
\brief |
107 |
Return this as an AbstractContinuousDomain. |
108 |
*/ |
109 |
BRUCE_DLL_API |
110 |
inline |
111 |
const AbstractContinuousDomain& |
112 |
asAbstractContinuousDomain() const |
113 |
{ |
114 |
return *(static_cast<const AbstractContinuousDomain*>(this)); |
115 |
} |
116 |
|
117 |
/** |
118 |
\brief |
119 |
Return this as an AbstractDomain. |
120 |
*/ |
121 |
BRUCE_DLL_API |
122 |
inline |
123 |
const AbstractDomain& |
124 |
asAbstractDomain() const |
125 |
{ |
126 |
return *(static_cast<const AbstractDomain*>(this)); |
127 |
} |
128 |
|
129 |
/** |
130 |
\brief |
131 |
Return a description for this domain. |
132 |
*/ |
133 |
BRUCE_DLL_API |
134 |
virtual |
135 |
inline |
136 |
std::string |
137 |
getDescription() const |
138 |
{ |
139 |
return "Bruce"; |
140 |
} |
141 |
|
142 |
/** |
143 |
\brief |
144 |
Returns true if the given integer is a valid function space type |
145 |
for this domain. |
146 |
*/ |
147 |
BRUCE_DLL_API |
148 |
virtual |
149 |
bool |
150 |
isValidFunctionSpaceType(int functionSpaceCode) const; |
151 |
|
152 |
/** |
153 |
\brief |
154 |
Return a description for the given function space type code. |
155 |
*/ |
156 |
BRUCE_DLL_API |
157 |
virtual |
158 |
std::string |
159 |
functionSpaceTypeAsString(int functionSpaceCode) const; |
160 |
|
161 |
/** |
162 |
\brief |
163 |
Return a continuous FunctionSpace code. |
164 |
*/ |
165 |
BRUCE_DLL_API |
166 |
virtual |
167 |
inline |
168 |
int |
169 |
getContinuousFunctionCode() const |
170 |
{ |
171 |
return ContinuousFunction; |
172 |
} |
173 |
|
174 |
/** |
175 |
\brief |
176 |
Return a function FunctionSpace code. |
177 |
*/ |
178 |
BRUCE_DLL_API |
179 |
virtual |
180 |
inline |
181 |
int |
182 |
getFunctionCode() const |
183 |
{ |
184 |
return Function; |
185 |
} |
186 |
|
187 |
/** |
188 |
\brief |
189 |
Return the spatial dimension of the mesh. |
190 |
*/ |
191 |
BRUCE_DLL_API |
192 |
virtual |
193 |
inline |
194 |
int |
195 |
getDim() const |
196 |
{ |
197 |
return m_origin.size(); |
198 |
} |
199 |
|
200 |
/** |
201 |
\brief |
202 |
Return the number of data points per sample, and the number of samples |
203 |
needed to represent data on parts of the mesh. |
204 |
*/ |
205 |
BRUCE_DLL_API |
206 |
virtual |
207 |
std::pair<int,int> |
208 |
getDataShape(int functionSpaceCode) const; |
209 |
|
210 |
/** |
211 |
\brief |
212 |
Return the number of samples |
213 |
needed to represent data on parts of the mesh. |
214 |
*/ |
215 |
BRUCE_DLL_API |
216 |
int |
217 |
getNumSamples(int functionSpaceCode) const; |
218 |
|
219 |
/** |
220 |
\brief |
221 |
Return the number of data-points per sample |
222 |
needed to represent data on parts of the mesh. |
223 |
*/ |
224 |
BRUCE_DLL_API |
225 |
inline |
226 |
int |
227 |
getNumDataPointsPerSample(int functionSpaceCode) const |
228 |
{ |
229 |
return 1; |
230 |
} |
231 |
|
232 |
/** |
233 |
\brief |
234 |
Returns the locations in the domain of the FEM nodes. |
235 |
*/ |
236 |
BRUCE_DLL_API |
237 |
virtual |
238 |
escript::Data |
239 |
getX() const; |
240 |
|
241 |
/** |
242 |
\brief |
243 |
Copies the location of data points on the domain into out. |
244 |
*/ |
245 |
BRUCE_DLL_API |
246 |
virtual |
247 |
void |
248 |
setToX(escript::Data& out) const; |
249 |
|
250 |
/** |
251 |
\brief |
252 |
Returns the element size. |
253 |
*/ |
254 |
BRUCE_DLL_API |
255 |
virtual |
256 |
escript::Data |
257 |
getSize() const; |
258 |
|
259 |
/** |
260 |
\brief |
261 |
Copies the size of samples into out. |
262 |
*/ |
263 |
BRUCE_DLL_API |
264 |
virtual |
265 |
void |
266 |
setToSize(escript::Data& out) const; |
267 |
|
268 |
/** |
269 |
\brief |
270 |
Copies the gradient of arg into grad. The actual function space to be considered |
271 |
for the gradient is defined by grad. arg and grad have to be defined on this. |
272 |
*/ |
273 |
BRUCE_DLL_API |
274 |
virtual |
275 |
void |
276 |
setToGradient(escript::Data& grad, |
277 |
const escript::Data& arg) const; |
278 |
|
279 |
/** |
280 |
\brief |
281 |
Comparison operators. |
282 |
*/ |
283 |
BRUCE_DLL_API |
284 |
virtual bool operator==(const AbstractDomain& other) const; |
285 |
BRUCE_DLL_API |
286 |
virtual bool operator!=(const AbstractDomain& other) const; |
287 |
|
288 |
/* |
289 |
\brief |
290 |
Return the tag key for the given sample number. |
291 |
NB: tags are not implemented on Bruce, so this method always returns 0. |
292 |
*/ |
293 |
BRUCE_DLL_API |
294 |
virtual |
295 |
inline |
296 |
int |
297 |
getTagFromSampleNo(int functionSpaceCode, |
298 |
int sampleNo) const |
299 |
{ |
300 |
return 0; |
301 |
} |
302 |
|
303 |
/** |
304 |
\brief |
305 |
Return the reference number of the given sample number. |
306 |
*/ |
307 |
BRUCE_DLL_API |
308 |
virtual |
309 |
int |
310 |
getReferenceNoFromSampleNo(int functionSpaceCode, |
311 |
int sampleNo) const; |
312 |
|
313 |
/** |
314 |
\brief |
315 |
Saves a dictionary of Data objects to a VTK XML input file. |
316 |
The dictionary consists of pairs of Data objects plus a name |
317 |
for each. Each Data object must be defined on this domain. |
318 |
*/ |
319 |
BRUCE_DLL_API |
320 |
virtual |
321 |
void |
322 |
saveVTK(const std::string& filename, |
323 |
const boost::python::dict& dataDict) const; |
324 |
|
325 |
/** |
326 |
\brief |
327 |
Interpolates data given on source onto target where source and target |
328 |
have to be given on the same domain. |
329 |
*/ |
330 |
BRUCE_DLL_API |
331 |
virtual |
332 |
void |
333 |
interpolateOnDomain(escript::Data& target, |
334 |
const escript::Data& source) const; |
335 |
|
336 |
BRUCE_DLL_API |
337 |
virtual |
338 |
bool |
339 |
probeInterpolationOnDomain(int functionSpaceType_source, |
340 |
int functionSpaceType_target) const; |
341 |
|
342 |
/** |
343 |
\brief |
344 |
Interpolates data given on source onto target where source and target |
345 |
are given on different domains. |
346 |
*/ |
347 |
BRUCE_DLL_API |
348 |
virtual |
349 |
void |
350 |
interpolateACross(escript::Data& target, |
351 |
const escript::Data& source) const; |
352 |
|
353 |
BRUCE_DLL_API |
354 |
virtual |
355 |
bool |
356 |
probeInterpolationACross(int functionSpaceType_source, |
357 |
const AbstractDomain& targetDomain, |
358 |
int functionSpaceType_target) const; |
359 |
|
360 |
protected: |
361 |
|
362 |
/** |
363 |
\brief |
364 |
Build the table of function space type names. |
365 |
*/ |
366 |
BRUCE_DLL_API |
367 |
void |
368 |
setFunctionSpaceTypeNames(); |
369 |
|
370 |
/** |
371 |
\brief |
372 |
Ensure the parameters supplied to the constructor are valid. |
373 |
*/ |
374 |
BRUCE_DLL_API |
375 |
bool |
376 |
checkParameters(); |
377 |
|
378 |
/** |
379 |
\brief |
380 |
Check if all components of vector are zero. |
381 |
*/ |
382 |
BRUCE_DLL_API |
383 |
static |
384 |
bool |
385 |
isZero(DimVec vec); |
386 |
|
387 |
private: |
388 |
|
389 |
// |
390 |
// vectors describing axis of the domain |
391 |
DimVec m_v0, m_v1, m_v2; |
392 |
|
393 |
// |
394 |
// number of data points in each axial direction of the domain |
395 |
int m_n0, m_n1, m_n2; |
396 |
|
397 |
// |
398 |
// the coordinates of the origin of the domain |
399 |
DimVec m_origin; |
400 |
|
401 |
// |
402 |
// map from FunctionSpace codes to names |
403 |
static FunctionSpaceNamesMapType m_functionSpaceTypeNames; |
404 |
|
405 |
}; |
406 |
|
407 |
} // end of namespace |
408 |
|
409 |
#endif |