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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2856 - (show annotations)
Mon Jan 18 04:14:37 2010 UTC (9 years, 7 months ago) by gross
File MIME type: text/plain
File size: 7373 byte(s)
FunctionSpaces provide now some information about their approximation order.
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 \brief returns the approximation order used for this function space
121 */
122
123 ESCRIPT_DLL_API
124 int
125 getApproximationOrder() const;
126
127 /**
128 \brief assigns new tag newTag to all samples with a positive
129 value of mask for any its sample point.
130 */
131 ESCRIPT_DLL_API
132 void setTags(const int newTag, const escript::Data& mask) const;
133
134
135 ESCRIPT_DLL_API
136 void setTagsByString(const std::string& name, const escript::Data& mask) const;
137
138
139 /**
140 \brief
141 Return the shape of the data needed to represent the function space.
142 */
143 ESCRIPT_DLL_API
144 std::pair<int,int>
145 getDataShape() const;
146
147 /**
148 \brief
149 Comparison operator.
150 Return true if function spaces are equal.
151 ie: Same domain and same function space type.
152 */
153 ESCRIPT_DLL_API
154 bool
155 operator==(const FunctionSpace& other) const;
156
157 ESCRIPT_DLL_API
158 bool
159 operator!=(const FunctionSpace& other) const;
160
161 /**
162 \brief
163 Return a text description of the function space.
164 */
165 ESCRIPT_DLL_API
166 std::string
167 toString() const;
168
169 //#define DEBUG_PY_STRINGS
170
171 #ifdef DEBUG_PY_STRINGS
172 /**
173 \brief
174 Return a text description of the function space
175 as a python string.
176 NOTE: This code was used to debug a conversion of
177 std::string to python string problem on windows.
178 An alternative approach was sought.
179 */
180 ESCRIPT_DLL_API
181 PyObject *
182 toPyString() const;
183 #endif
184
185 /**
186 \brief
187 Return the tag associated with the given sample number.
188 */
189 ESCRIPT_DLL_API
190 int
191 getTagFromSampleNo(int sampleNo) const;
192
193 /**
194 \brief
195 Return the tag associated with the given data-point number.
196 */
197 ESCRIPT_DLL_API
198 int
199 getTagFromDataPointNo(int dataPointNo) const;
200
201 /**
202 \brief
203 Return the reference number associated with the given data-point number.
204 */
205 ESCRIPT_DLL_API
206 int getReferenceIDFromDataPointNo(int dataPointNo) const;
207
208 /**
209 \brief
210 Return the reference number associated with the given sample number.
211 This function is not efficient. It is better to first call
212 borrowSampleReferenceIDs and then when iterating over sampleNo to use sampleNo as an offset.
213 */
214 ESCRIPT_DLL_API
215 inline
216 int
217 getReferenceIDOfSample(int sampleNo) const
218 {
219 return borrowSampleReferenceIDs()[sampleNo];
220 }
221
222 /**
223 \brief Does this process own the sample?
224 For non-MPI builds will always return true
225 */
226 ESCRIPT_DLL_API
227 inline
228 bool
229 ownSample(int sampleNo) const
230 {
231 return m_domain->ownSample(m_functionSpaceType, sampleNo);
232 }
233
234 /**
235 \brief
236 Return a borrowed reference to the list of sample reference IDs
237 */
238 ESCRIPT_DLL_API
239 const int*
240 borrowSampleReferenceIDs() const;
241
242 /**
243 \brief
244 Return the spatial locations of the data points.
245 */
246 ESCRIPT_DLL_API
247 escript::Data
248 getX() const;
249
250 /**
251 \brief
252 Return the surface normal field.
253 */
254 ESCRIPT_DLL_API
255 escript::Data
256 getNormal() const;
257
258 /**
259 \brief
260 Return the sample size (e.g. the diameter of elements, radius of particles).
261 */
262 ESCRIPT_DLL_API
263 escript::Data
264 getSize() const;
265
266 /**
267 \brief
268 Return the number of samples.
269 */
270 ESCRIPT_DLL_API
271 inline
272 int
273 getNumSamples() const {
274 return getDataShape().second;
275 }
276
277 /**
278 \brief
279 Return the number of data points per sample.
280 */
281 ESCRIPT_DLL_API
282 inline
283 int
284 getNumDPPSample() const {
285 return getNumDataPointsPerSample();
286 }
287
288 ESCRIPT_DLL_API
289 inline
290 int
291 getNumDataPointsPerSample() const {
292 return getDataShape().first;
293 }
294
295 /**
296 \brief
297 Return the spatial dimension of the underlying domain.
298 */
299 ESCRIPT_DLL_API
300 inline
301 int
302 getDim() const {
303 return getDomain()->getDim();
304 }
305 /**
306 \brief
307 Returns a list of the tags used in this function space
308 */
309 ESCRIPT_DLL_API
310 boost::python::list
311 getListOfTags() const;
312 /**
313 \brief
314 Returns an stl::list of the tags used in this function space
315 */
316 ESCRIPT_DLL_API
317 std::list<int>
318 getListOfTagsSTL() const;
319
320 /**
321 \brief
322 return the number of tags in use and a pointer to an array with the number of tags in use
323 */
324 ESCRIPT_DLL_API
325 int getNumberOfTagsInUse() const;
326
327 ESCRIPT_DLL_API
328 const int* borrowListOfTagsInUse() const;
329
330 ESCRIPT_DLL_API
331 bool
332 probeInterpolation(const FunctionSpace& other) const
333 {
334 if (*this==other) {
335 return true;
336 } else {
337 const_Domain_ptr domain=getDomain();
338 if (*domain==*other.getDomain()) {
339 return domain->probeInterpolationOnDomain(getTypeCode(),other.getTypeCode());
340 } else {
341 return domain->probeInterpolationACross(getTypeCode(),*(other.getDomain()),other.getTypeCode());
342 }
343 }
344 }
345
346
347 protected:
348
349 private:
350 /**
351 \brief
352 Assignment operator.
353 This method is only defined (private) to prevent people from using it.
354 */
355 ESCRIPT_DLL_API
356 FunctionSpace&
357 operator=(const FunctionSpace& other);
358
359 //
360 // function space domain
361
362 // const AbstractDomain* m_domain;
363 const_Domain_ptr m_domain;
364
365
366 //
367 // function space type code.
368 int m_functionSpaceType;
369
370 };
371
372 } // end of namespace
373
374 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26