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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 5 months ago) by ksteube
File MIME type: text/plain
File size: 7140 byte(s)
Copyright updated in all files

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26