/[escript]/trunk/escript/src/FunctionSpace.h
ViewVC logotype

Contents of /trunk/escript/src/FunctionSpace.h

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26