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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1421 - (show annotations)
Tue Feb 26 10:17:33 2008 UTC (12 years, 4 months ago) by trankine
File MIME type: text/plain
File size: 6209 byte(s)
In this version

1. with DEBUG_PY_STRINGS not defined, it succeeds to run repeated str(a_fn_space) 50000 times. However it fails run_tests and py_tests in the same way it did previously.
2. with DEBUG_PY_STRINGS it uses toPyString, and almost passes run_tests, and gets far further into py_tests, to a point that looks quite different.
1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #if !defined escript_FunctionSpace_20040323_H
17 #define escript_FunctionSpace_20040323_H
18 #include "system_dep.h"
19
20 #include "AbstractDomain.h"
21 #include "NullDomain.h"
22
23 #include <string>
24
25 #define DEBUG_PY_STRINGS
26
27 class FunctionSpaceTestCase;
28
29 namespace escript {
30
31 //
32 // Forward declaration for class Data.
33 class Data;
34
35 /**
36 \brief
37 Give a short description of what FunctionSpace does.
38
39 Description:
40 Give a detailed description of FunctionSpace.
41
42 Template Parameters:
43 For templates describe any conditions that the parameters used in the
44 template must satisfy.
45 */
46
47 class FunctionSpace {
48
49 // These are using operator=()
50 friend class AbstractSystemMatrix;
51 friend class AbstractTransportProblem;
52 friend class ::FunctionSpaceTestCase;
53
54 public:
55 /**
56 \brief
57 Default constructor for FunctionSpace.
58
59 Description:
60 Default constructor for FunctionSpace
61 Generates a function space with a null domain.
62
63 Preconditions:
64 Describe any preconditions.
65
66 Throws:
67 Describe any exceptions thrown.
68 */
69 ESCRIPT_DLL_API
70 FunctionSpace();
71
72 /**
73 \brief
74 Constructor for FunctionSpace.
75
76 Description:
77 Constructor for FunctionSpace.
78
79 NOTE: The FunctionSpace class relies on the domain existing
80 for the lifetime of the FunctionSpace object. ie: domain must
81 be an externally managed object (!).
82 */
83 ESCRIPT_DLL_API
84 FunctionSpace(const AbstractDomain& domain,
85 int functionSpaceType);
86
87 /**
88 \brief
89 Return the function space type code.
90 */
91 ESCRIPT_DLL_API
92 int
93 getTypeCode() const;
94
95 /**
96 \brief
97 Return the function space domain.
98 */
99 ESCRIPT_DLL_API
100 const
101 AbstractDomain&
102 getDomain() const;
103
104
105
106 /**
107 \brief assigns new tag newTag to all samples with a positive
108 value of mask for any its sample point.
109
110 */
111 ESCRIPT_DLL_API
112 void setTags(const int newTag, const escript::Data& mask) const;
113
114
115 /**
116 \brief
117 Return the shape of the data needed to represent the function space.
118 */
119 ESCRIPT_DLL_API
120 std::pair<int,int>
121 getDataShape() const;
122
123 /**
124 \brief
125 Comparison operator.
126 Return true if function spaces are equal.
127 ie: Same domain and same function space type.
128 */
129 ESCRIPT_DLL_API
130 bool
131 operator==(const FunctionSpace& other) const;
132
133 ESCRIPT_DLL_API
134 bool
135 operator!=(const FunctionSpace& other) const;
136
137 /**
138 \brief
139 Return a text description of the function space.
140 */
141 ESCRIPT_DLL_API
142 const std::string &
143 toString() const;
144
145 #ifdef DEBUG_PY_STRINGS
146 /**
147 \brief
148 Return a text description of the function space
149 as a python string.
150 NOTE: This code was used to debug a conversion of
151 std::string to python string problem on windows.
152 An alternative approach was sought.
153 */
154 ESCRIPT_DLL_API
155 PyObject *
156 toPyString() const;
157 #endif
158
159 /**
160 \brief
161 Return the tag associated with the given sample number.
162 */
163 ESCRIPT_DLL_API
164 int
165 getTagFromSampleNo(int sampleNo) const;
166
167 /**
168 \brief
169 Return the tag associated with the given data-point number.
170 */
171 ESCRIPT_DLL_API
172 int
173 getTagFromDataPointNo(int dataPointNo) const;
174
175 /**
176 \brief
177 Return the reference number associated with the given sample number.
178 This function is not efficient. It is better to first call
179 borrowSampleReferenceIDs and then when iterating over sampleNo to use sampleNo as an offset.
180 */
181 ESCRIPT_DLL_API
182 inline
183 int
184 getReferenceIDOfSample(int sampleNo) const
185 {
186 return borrowSampleReferenceIDs()[sampleNo];
187 }
188 /**
189 \brief
190 Return a borrowed reference to the list of sample reference IDs
191 */
192 ESCRIPT_DLL_API
193 int*
194 borrowSampleReferenceIDs() const;
195
196 /**
197 \brief
198 Return the spatial locations of the data points.
199 */
200 ESCRIPT_DLL_API
201 escript::Data
202 getX() const;
203
204 /**
205 \brief
206 Return the surface normal field.
207 */
208 ESCRIPT_DLL_API
209 escript::Data
210 getNormal() const;
211
212 /**
213 \brief
214 Return the sample size (e.g. the diameter of elements, radius of particles).
215 */
216 ESCRIPT_DLL_API
217 escript::Data
218 getSize() const;
219
220 /**
221 \brief
222 Return the number of samples.
223 */
224 ESCRIPT_DLL_API
225 inline
226 int
227 getNumSamples() const {
228 return getDataShape().second;
229 }
230
231 /**
232 \brief
233 Return the number of data points per sample.
234 */
235 ESCRIPT_DLL_API
236 inline
237 int
238 getNumDPPSample() const {
239 return getNumDataPointsPerSample();
240 }
241
242 ESCRIPT_DLL_API
243 inline
244 int
245 getNumDataPointsPerSample() const {
246 return getDataShape().first;
247 }
248
249 /**
250 \brief
251 Return the spatial dimension of the underlying domain.
252 */
253 ESCRIPT_DLL_API
254 inline
255 int
256 getDim() const {
257 return getDomain().getDim();
258 }
259
260 protected:
261
262 private:
263 /**
264 \brief
265 Assignment operator.
266 NOTE: Assignment copies the domain object pointer
267 as this object is managed externally to this class.
268 NOTE Also, breaks the non-mutability of FunctionSpace
269 assumed by toString(). Allowing this would also have
270 unknown effects at the python level, and could
271 leave python with an incorrect view of the object.
272 */
273 // yes, yes I know, but the test case is in another
274 // linkage unit external to the dll.
275 // This IS supposed to be temporary.
276 ESCRIPT_DLL_API
277 FunctionSpace&
278 operator=(const FunctionSpace& other);
279
280 //
281 // static null domain value
282 static const NullDomain nullDomainValue;
283
284 //
285 // function space domain
286 const AbstractDomain* m_domain;
287
288 //
289 // function space type code.
290 int m_functionSpaceType;
291
292 //
293 // return value of toString.
294 // made mutable for lazy initialisation in 1st call to toString.
295 // So, this is conceptually immutable, meaning it expects the FunctionSpace
296 // object to be immutable.
297 mutable std::string type_str;
298
299 };
300
301 } // end of namespace
302
303 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26