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