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