1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2009 by University of Queensland |
5 |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* http://www.uq.edu.au/esscc |
7 |
* |
8 |
* Primary Business: Queensland, Australia |
9 |
* Licensed under the Open Software License version 3.0 |
10 |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
* |
12 |
*******************************************************/ |
13 |
|
14 |
|
15 |
#if !defined escript_FunctionSpace_20040323_H |
16 |
#define escript_FunctionSpace_20040323_H |
17 |
#include "system_dep.h" |
18 |
|
19 |
#include "AbstractDomain.h" |
20 |
#include "NullDomain.h" |
21 |
|
22 |
#include <string> |
23 |
#include <list> |
24 |
|
25 |
namespace escript { |
26 |
|
27 |
// |
28 |
// Forward declaration for class Data. |
29 |
class Data; |
30 |
|
31 |
/** |
32 |
\brief |
33 |
Give a short description of what FunctionSpace does. |
34 |
|
35 |
Description: |
36 |
Give a detailed description of FunctionSpace. |
37 |
|
38 |
Template Parameters: |
39 |
For templates describe any conditions that the parameters used in the |
40 |
template must satisfy. |
41 |
*/ |
42 |
|
43 |
class FunctionSpace |
44 |
{ |
45 |
public: |
46 |
/** |
47 |
\brief |
48 |
Default constructor for FunctionSpace. |
49 |
|
50 |
Description: |
51 |
Default constructor for FunctionSpace |
52 |
Generates a function space with a null domain. |
53 |
|
54 |
Preconditions: |
55 |
Describe any preconditions. |
56 |
|
57 |
Throws: |
58 |
Describe any exceptions thrown. |
59 |
*/ |
60 |
ESCRIPT_DLL_API |
61 |
FunctionSpace(); |
62 |
|
63 |
/** |
64 |
\brief |
65 |
Constructor for FunctionSpace. |
66 |
|
67 |
Description: |
68 |
Constructor for FunctionSpace. |
69 |
*/ |
70 |
ESCRIPT_DLL_API |
71 |
FunctionSpace(const_Domain_ptr domain, |
72 |
int functionSpaceType); |
73 |
|
74 |
|
75 |
ESCRIPT_DLL_API |
76 |
FunctionSpace(const FunctionSpace& other); |
77 |
|
78 |
/** |
79 |
\brief |
80 |
Return the function space type code. |
81 |
|
82 |
Note: The meaning of the code depends on the domain object the FunctionSpace is built on. |
83 |
*/ |
84 |
ESCRIPT_DLL_API |
85 |
int |
86 |
getTypeCode() const; |
87 |
|
88 |
/** |
89 |
\brief |
90 |
Return the function space domain. |
91 |
*/ |
92 |
ESCRIPT_DLL_API |
93 |
// const |
94 |
// AbstractDomain& |
95 |
const_Domain_ptr |
96 |
getDomain() const; |
97 |
|
98 |
/** |
99 |
\brief |
100 |
Return the function space domain. |
101 |
Internal use only! This gets around some python difficulties by |
102 |
casting away the const. Do not use this in c++. |
103 |
*/ |
104 |
ESCRIPT_DLL_API |
105 |
// const |
106 |
// AbstractDomain& |
107 |
Domain_ptr |
108 |
getDomainPython() const; |
109 |
|
110 |
|
111 |
|
112 |
/** |
113 |
\brief Checks if this functionspace support tags |
114 |
*/ |
115 |
ESCRIPT_DLL_API |
116 |
bool |
117 |
canTag() const; |
118 |
|
119 |
|
120 |
/** |
121 |
\brief assigns new tag newTag to all samples with a positive |
122 |
value of mask for any its sample point. |
123 |
|
124 |
*/ |
125 |
ESCRIPT_DLL_API |
126 |
void setTags(const int newTag, const escript::Data& mask) const; |
127 |
|
128 |
|
129 |
/** |
130 |
\brief |
131 |
Return the shape of the data needed to represent the function space. |
132 |
*/ |
133 |
ESCRIPT_DLL_API |
134 |
std::pair<int,int> |
135 |
getDataShape() const; |
136 |
|
137 |
/** |
138 |
\brief |
139 |
Comparison operator. |
140 |
Return true if function spaces are equal. |
141 |
ie: Same domain and same function space type. |
142 |
*/ |
143 |
ESCRIPT_DLL_API |
144 |
bool |
145 |
operator==(const FunctionSpace& other) const; |
146 |
|
147 |
ESCRIPT_DLL_API |
148 |
bool |
149 |
operator!=(const FunctionSpace& other) const; |
150 |
|
151 |
/** |
152 |
\brief |
153 |
Return a text description of the function space. |
154 |
*/ |
155 |
ESCRIPT_DLL_API |
156 |
std::string |
157 |
toString() const; |
158 |
|
159 |
//#define DEBUG_PY_STRINGS |
160 |
|
161 |
#ifdef DEBUG_PY_STRINGS |
162 |
/** |
163 |
\brief |
164 |
Return a text description of the function space |
165 |
as a python string. |
166 |
NOTE: This code was used to debug a conversion of |
167 |
std::string to python string problem on windows. |
168 |
An alternative approach was sought. |
169 |
*/ |
170 |
ESCRIPT_DLL_API |
171 |
PyObject * |
172 |
toPyString() const; |
173 |
#endif |
174 |
|
175 |
/** |
176 |
\brief |
177 |
Return the tag associated with the given sample number. |
178 |
*/ |
179 |
ESCRIPT_DLL_API |
180 |
int |
181 |
getTagFromSampleNo(int sampleNo) const; |
182 |
|
183 |
/** |
184 |
\brief |
185 |
Return the tag associated with the given data-point number. |
186 |
*/ |
187 |
ESCRIPT_DLL_API |
188 |
int |
189 |
getTagFromDataPointNo(int dataPointNo) const; |
190 |
|
191 |
/** |
192 |
\brief |
193 |
Return the reference number associated with the given data-point number. |
194 |
*/ |
195 |
ESCRIPT_DLL_API |
196 |
int getReferenceIDFromDataPointNo(int dataPointNo) const; |
197 |
|
198 |
/** |
199 |
\brief |
200 |
Return the reference number associated with the given sample number. |
201 |
This function is not efficient. It is better to first call |
202 |
borrowSampleReferenceIDs and then when iterating over sampleNo to use sampleNo as an offset. |
203 |
*/ |
204 |
ESCRIPT_DLL_API |
205 |
inline |
206 |
int |
207 |
getReferenceIDOfSample(int sampleNo) const |
208 |
{ |
209 |
return borrowSampleReferenceIDs()[sampleNo]; |
210 |
} |
211 |
/** |
212 |
\brief |
213 |
Return a borrowed reference to the list of sample reference IDs |
214 |
*/ |
215 |
ESCRIPT_DLL_API |
216 |
const int* |
217 |
borrowSampleReferenceIDs() const; |
218 |
|
219 |
/** |
220 |
\brief |
221 |
Return the spatial locations of the data points. |
222 |
*/ |
223 |
ESCRIPT_DLL_API |
224 |
escript::Data |
225 |
getX() const; |
226 |
|
227 |
/** |
228 |
\brief |
229 |
Return the surface normal field. |
230 |
*/ |
231 |
ESCRIPT_DLL_API |
232 |
escript::Data |
233 |
getNormal() const; |
234 |
|
235 |
/** |
236 |
\brief |
237 |
Return the sample size (e.g. the diameter of elements, radius of particles). |
238 |
*/ |
239 |
ESCRIPT_DLL_API |
240 |
escript::Data |
241 |
getSize() const; |
242 |
|
243 |
/** |
244 |
\brief |
245 |
Return the number of samples. |
246 |
*/ |
247 |
ESCRIPT_DLL_API |
248 |
inline |
249 |
int |
250 |
getNumSamples() const { |
251 |
return getDataShape().second; |
252 |
} |
253 |
|
254 |
/** |
255 |
\brief |
256 |
Return the number of data points per sample. |
257 |
*/ |
258 |
ESCRIPT_DLL_API |
259 |
inline |
260 |
int |
261 |
getNumDPPSample() const { |
262 |
return getNumDataPointsPerSample(); |
263 |
} |
264 |
|
265 |
ESCRIPT_DLL_API |
266 |
inline |
267 |
int |
268 |
getNumDataPointsPerSample() const { |
269 |
return getDataShape().first; |
270 |
} |
271 |
|
272 |
/** |
273 |
\brief |
274 |
Return the spatial dimension of the underlying domain. |
275 |
*/ |
276 |
ESCRIPT_DLL_API |
277 |
inline |
278 |
int |
279 |
getDim() const { |
280 |
return getDomain()->getDim(); |
281 |
} |
282 |
/** |
283 |
\brief |
284 |
Returns a list of the tags used in this function space |
285 |
*/ |
286 |
ESCRIPT_DLL_API |
287 |
boost::python::list |
288 |
getListOfTags() const; |
289 |
/** |
290 |
\brief |
291 |
Returns an stl::list of the tags used in this function space |
292 |
*/ |
293 |
ESCRIPT_DLL_API |
294 |
std::list<int> |
295 |
getListOfTagsSTL() const; |
296 |
|
297 |
/** |
298 |
\brief |
299 |
return the number of tags in use and a pointer to an array with the number of tags in use |
300 |
*/ |
301 |
ESCRIPT_DLL_API |
302 |
int getNumberOfTagsInUse() const; |
303 |
|
304 |
ESCRIPT_DLL_API |
305 |
const int* borrowListOfTagsInUse() const; |
306 |
|
307 |
ESCRIPT_DLL_API |
308 |
bool |
309 |
probeInterpolation(const FunctionSpace& other) const |
310 |
{ |
311 |
if (*this==other) { |
312 |
return true; |
313 |
} else { |
314 |
const_Domain_ptr domain=getDomain(); |
315 |
if (*domain==*other.getDomain()) { |
316 |
return domain->probeInterpolationOnDomain(getTypeCode(),other.getTypeCode()); |
317 |
} else { |
318 |
return domain->probeInterpolationACross(getTypeCode(),*(other.getDomain()),other.getTypeCode()); |
319 |
} |
320 |
} |
321 |
} |
322 |
|
323 |
|
324 |
protected: |
325 |
|
326 |
private: |
327 |
/** |
328 |
\brief |
329 |
Assignment operator. |
330 |
This method is only defined (private) to prevent people from using it. |
331 |
*/ |
332 |
ESCRIPT_DLL_API |
333 |
FunctionSpace& |
334 |
operator=(const FunctionSpace& other); |
335 |
|
336 |
// |
337 |
// function space domain |
338 |
|
339 |
// const AbstractDomain* m_domain; |
340 |
const_Domain_ptr m_domain; |
341 |
|
342 |
|
343 |
// |
344 |
// function space type code. |
345 |
int m_functionSpaceType; |
346 |
|
347 |
}; |
348 |
|
349 |
} // end of namespace |
350 |
|
351 |
#endif |