/[escript]/branches/more_shared_ptrs_from_1812/escript/src/FunctionSpace.h
ViewVC logotype

Contents of /branches/more_shared_ptrs_from_1812/escript/src/FunctionSpace.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1821 - (show annotations)
Wed Oct 1 04:46:59 2008 UTC (11 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 7552 byte(s)
Branch commit.
Fixed some issues.
runs c++ unit tests and run_simplesolve successfully.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26