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