/[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 1420 - (show annotations)
Tue Feb 26 07:30:08 2008 UTC (11 years, 5 months ago) by trankine
File MIME type: text/plain
File size: 5921 byte(s)
1. toString returns a cost ref to a string.
2. the return value is a member of the function space.
3. the string member is declared mutable so that toString can lazy init. it.
4. this assumes type_str is virtually non mutable for the life of a FunctionSpace.cpp
5. operator=() is now private and users are declared friend classes; This is temporary.
6. the nullDomainValue is now static const, and it's no longer allowed to have external linkage.
7. as a result of 6, methods of FunctionSpace that need to be exported outside a windows dll need to be individually dll_export/import'ed using the ESCRIPT_..... macro 
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 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 friend class AbstractSystemMatrix;
46 friend class AbstractTransportProblem;
47
48 public:
49 /**
50 \brief
51 Default constructor for FunctionSpace.
52
53 Description:
54 Default constructor for FunctionSpace
55 Generates a function space with a null domain.
56
57 Preconditions:
58 Describe any preconditions.
59
60 Throws:
61 Describe any exceptions thrown.
62 */
63 ESCRIPT_DLL_API
64 FunctionSpace();
65
66 /**
67 \brief
68 Constructor for FunctionSpace.
69
70 Description:
71 Constructor for FunctionSpace.
72
73 NOTE: The FunctionSpace class relies on the domain existing
74 for the lifetime of the FunctionSpace object. ie: domain must
75 be an externally managed object (!).
76 */
77 ESCRIPT_DLL_API
78 FunctionSpace(const AbstractDomain& domain,
79 int functionSpaceType);
80
81 /**
82 \brief
83 Return the function space type code.
84 */
85 ESCRIPT_DLL_API
86 int
87 getTypeCode() const;
88
89 /**
90 \brief
91 Return the function space domain.
92 */
93 ESCRIPT_DLL_API
94 const
95 AbstractDomain&
96 getDomain() const;
97
98
99
100 /**
101 \brief assigns new tag newTag to all samples with a positive
102 value of mask for any its sample point.
103
104 */
105 ESCRIPT_DLL_API
106 void setTags(const int newTag, const escript::Data& mask) const;
107
108
109 /**
110 \brief
111 Return the shape of the data needed to represent the function space.
112 */
113 ESCRIPT_DLL_API
114 std::pair<int,int>
115 getDataShape() const;
116
117 /**
118 \brief
119 Comparison operator.
120 Return true if function spaces are equal.
121 ie: Same domain and same function space type.
122 */
123 ESCRIPT_DLL_API
124 bool
125 operator==(const FunctionSpace& other) const;
126
127 ESCRIPT_DLL_API
128 bool
129 operator!=(const FunctionSpace& other) const;
130
131 /**
132 \brief
133 Return a text description of the function space.
134 */
135 ESCRIPT_DLL_API
136 const std::string &
137 toString() const;
138
139 #ifdef DEBUG
140 /**
141 \brief
142 Return a text description of the function space
143 as a python string.
144 NOTE: This code was used to debug a conversion of
145 std::string to python string problem on windows.
146 An alternative approach was sought.
147 */
148 ESCRIPT_DLL_API
149 PyObject *
150 toPyString() const;
151 #endif
152
153 /**
154 \brief
155 Return the tag associated with the given sample number.
156 */
157 ESCRIPT_DLL_API
158 int
159 getTagFromSampleNo(int sampleNo) const;
160
161 /**
162 \brief
163 Return the tag associated with the given data-point number.
164 */
165 ESCRIPT_DLL_API
166 int
167 getTagFromDataPointNo(int dataPointNo) const;
168
169 /**
170 \brief
171 Return the reference number associated with the given sample number.
172 This function is not efficient. It is better to first call
173 borrowSampleReferenceIDs and then when iterating over sampleNo to use sampleNo as an offset.
174 */
175 ESCRIPT_DLL_API
176 inline
177 int
178 getReferenceIDOfSample(int sampleNo) const
179 {
180 return borrowSampleReferenceIDs()[sampleNo];
181 }
182 /**
183 \brief
184 Return a borrowed reference to the list of sample reference IDs
185 */
186 ESCRIPT_DLL_API
187 int*
188 borrowSampleReferenceIDs() const;
189
190 /**
191 \brief
192 Return the spatial locations of the data points.
193 */
194 ESCRIPT_DLL_API
195 escript::Data
196 getX() const;
197
198 /**
199 \brief
200 Return the surface normal field.
201 */
202 ESCRIPT_DLL_API
203 escript::Data
204 getNormal() const;
205
206 /**
207 \brief
208 Return the sample size (e.g. the diameter of elements, radius of particles).
209 */
210 ESCRIPT_DLL_API
211 escript::Data
212 getSize() const;
213
214 /**
215 \brief
216 Return the number of samples.
217 */
218 ESCRIPT_DLL_API
219 inline
220 int
221 getNumSamples() const {
222 return getDataShape().second;
223 }
224
225 /**
226 \brief
227 Return the number of data points per sample.
228 */
229 ESCRIPT_DLL_API
230 inline
231 int
232 getNumDPPSample() const {
233 return getNumDataPointsPerSample();
234 }
235
236 ESCRIPT_DLL_API
237 inline
238 int
239 getNumDataPointsPerSample() const {
240 return getDataShape().first;
241 }
242
243 /**
244 \brief
245 Return the spatial dimension of the underlying domain.
246 */
247 ESCRIPT_DLL_API
248 inline
249 int
250 getDim() const {
251 return getDomain().getDim();
252 }
253
254 protected:
255
256 private:
257 /**
258 \brief
259 Assignment operator.
260 NOTE: Assignment copies the domain object pointer
261 as this object is managed externally to this class.
262 NOTE Also, breaks the non-mutability of FunctionSpace
263 assumed by toString(). Allowing this would also have
264 unknown effects at the python level, and could
265 leave python with an incorrect view of the object.
266 */
267 FunctionSpace&
268 operator=(const FunctionSpace& other);
269
270 //
271 // static null domain value
272 static const NullDomain nullDomainValue;
273
274 //
275 // function space domain
276 const AbstractDomain* m_domain;
277
278 //
279 // function space type code.
280 int m_functionSpaceType;
281
282 //
283 // return value of toString.
284 // made mutable for lazy initialisation in 1st call to toString.
285 // So, this is conceptually immutable, meaning it expects the FunctionSpace
286 // object to be immutable.
287 mutable std::string type_str;
288
289 };
290
291 } // end of namespace
292
293 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26