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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 jgs 115
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 jgs 115 #if !defined escript_FunctionSpace_20040323_H
16 jgs 82 #define escript_FunctionSpace_20040323_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19 jgs 474 #include "AbstractDomain.h"
20     #include "NullDomain.h"
21 jgs 82
22     #include <string>
23 jfenwick 1802 #include <list>
24 jgs 82
25 phornby 1455 // This stops the friend declaration below from looking like a
26     // declaration of escript::FunctionSpaceTestCase.
27    
28 trankine 1426 class FunctionSpaceTestCase;
29    
30 jgs 82 namespace escript {
31    
32 jgs 117 //
33     // Forward declaration for class Data.
34     class Data;
35 jgs 82
36     /**
37     \brief
38     Give a short description of what FunctionSpace does.
39    
40     Description:
41 jgs 117 Give a detailed description of FunctionSpace.
42 jgs 82
43     Template Parameters:
44     For templates describe any conditions that the parameters used in the
45 jgs 117 template must satisfy.
46 jgs 82 */
47    
48 trankine 1426 class FunctionSpace {
49 jgs 82
50 trankine 1426 // These are using operator=()
51     friend class AbstractSystemMatrix;
52     friend class AbstractTransportProblem;
53     friend class ::FunctionSpaceTestCase;
54    
55 jgs 82 public:
56     /**
57     \brief
58 jgs 117 Default constructor for FunctionSpace.
59 jgs 82
60     Description:
61     Default constructor for FunctionSpace
62     Generates a function space with a null domain.
63    
64     Preconditions:
65 jgs 117 Describe any preconditions.
66 jgs 82
67     Throws:
68 jgs 117 Describe any exceptions thrown.
69 jgs 82 */
70 trankine 1426 ESCRIPT_DLL_API
71 jgs 82 FunctionSpace();
72    
73     /**
74     \brief
75 jgs 117 Constructor for FunctionSpace.
76 jgs 82
77     Description:
78     Constructor for FunctionSpace.
79 jgs 115
80 jgs 82 NOTE: The FunctionSpace class relies on the domain existing
81 jgs 115 for the lifetime of the FunctionSpace object. ie: domain must
82     be an externally managed object (!).
83 jgs 82 */
84 trankine 1426 ESCRIPT_DLL_API
85 jgs 117 FunctionSpace(const AbstractDomain& domain,
86     int functionSpaceType);
87 jgs 82
88     /**
89     \brief
90     Return the function space type code.
91 jfenwick 1802
92     Note: The meaning of the code depends on the domain object the FunctionSpace is built on.
93 jgs 82 */
94 trankine 1426 ESCRIPT_DLL_API
95 jgs 117 int
96     getTypeCode() const;
97 jgs 82
98     /**
99     \brief
100     Return the function space domain.
101     */
102 trankine 1426 ESCRIPT_DLL_API
103 jgs 117 const
104     AbstractDomain&
105     getDomain() const;
106 jgs 82
107 jfenwick 1802 /**
108     \brief Checks if this functionspace support tags
109     */
110     ESCRIPT_DLL_API
111     bool
112     canTag() const;
113 jgs 82
114 gross 767
115 jgs 82 /**
116 gross 767 \brief assigns new tag newTag to all samples with a positive
117     value of mask for any its sample point.
118    
119     */
120 trankine 1426 ESCRIPT_DLL_API
121 gross 767 void setTags(const int newTag, const escript::Data& mask) const;
122    
123    
124     /**
125 jgs 82 \brief
126     Return the shape of the data needed to represent the function space.
127     */
128 trankine 1426 ESCRIPT_DLL_API
129 jgs 117 std::pair<int,int>
130     getDataShape() const;
131 jgs 82
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 trankine 1426 ESCRIPT_DLL_API
139 jgs 117 bool
140     operator==(const FunctionSpace& other) const;
141 jgs 82
142 trankine 1426 ESCRIPT_DLL_API
143 jgs 117 bool
144     operator!=(const FunctionSpace& other) const;
145    
146 jgs 82 /**
147     \brief
148 jgs 115 Return a text description of the function space.
149 phornby 1455 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 jgs 82 */
157 trankine 1426 ESCRIPT_DLL_API
158 phornby 1628 std::string
159 jgs 117 toString() const;
160 ksteube 1312
161 trankine 1426 //#define DEBUG_PY_STRINGS
162    
163     #ifdef DEBUG_PY_STRINGS
164 jgs 82 /**
165     \brief
166 trankine 1426 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 jgs 82 Return the tag associated with the given sample number.
180     */
181 trankine 1426 ESCRIPT_DLL_API
182 jgs 117 int
183     getTagFromSampleNo(int sampleNo) const;
184 jgs 115
185 jgs 110 /**
186     \brief
187 jgs 149 Return the tag associated with the given data-point number.
188 jgs 110 */
189 trankine 1426 ESCRIPT_DLL_API
190 jgs 117 int
191 jgs 149 getTagFromDataPointNo(int dataPointNo) const;
192    
193     /**
194     \brief
195 gross 1718 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 jgs 149 Return the reference number associated with the given sample number.
203 gross 964 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 jgs 149 */
206 trankine 1426 ESCRIPT_DLL_API
207 gross 964 inline
208 jgs 149 int
209 gross 964 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 trankine 1426 ESCRIPT_DLL_API
218 gross 964 int*
219     borrowSampleReferenceIDs() const;
220 jgs 82
221     /**
222     \brief
223 jgs 149 Return the spatial locations of the data points.
224 jgs 82 */
225 trankine 1426 ESCRIPT_DLL_API
226 jgs 117 escript::Data
227     getX() const;
228 jgs 149
229 jgs 82 /**
230     \brief
231     Return the surface normal field.
232     */
233 trankine 1426 ESCRIPT_DLL_API
234 jgs 117 escript::Data
235     getNormal() const;
236 jgs 82
237     /**
238     \brief
239     Return the sample size (e.g. the diameter of elements, radius of particles).
240     */
241 trankine 1426 ESCRIPT_DLL_API
242 jgs 117 escript::Data
243     getSize() const;
244 jgs 82
245     /**
246     \brief
247 jgs 115 Return the number of samples.
248 jgs 82 */
249 trankine 1426 ESCRIPT_DLL_API
250 jgs 117 inline
251     int
252     getNumSamples() const {
253 jgs 82 return getDataShape().second;
254     }
255    
256     /**
257     \brief
258     Return the number of data points per sample.
259     */
260 trankine 1426 ESCRIPT_DLL_API
261 jgs 117 inline
262     int
263     getNumDPPSample() const {
264 jgs 82 return getNumDataPointsPerSample();
265     }
266 jgs 149
267 trankine 1426 ESCRIPT_DLL_API
268 jgs 117 inline
269     int
270     getNumDataPointsPerSample() const {
271 jgs 82 return getDataShape().first;
272     }
273    
274     /**
275     \brief
276     Return the spatial dimension of the underlying domain.
277     */
278 trankine 1426 ESCRIPT_DLL_API
279 jgs 117 inline
280     int
281     getDim() const {
282 jgs 82 return getDomain().getDim();
283     }
284 gross 1716 /**
285     \brief
286 jfenwick 1802 Returns a list of the tags used in this function space
287 gross 1716 */
288     ESCRIPT_DLL_API
289     boost::python::list
290     getListOfTags() const;
291 jfenwick 1802 /**
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 jgs 115
299 gross 1716 /**
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 jgs 82 protected:
312    
313     private:
314 trankine 1426 /**
315     \brief
316     Assignment operator.
317     NOTE: Assignment copies the domain object pointer
318     as this object is managed externally to this class.
319 phornby 1455 Also, breaks the non-mutability of FunctionSpace
320     assumed by toString().
321 trankine 1426 */
322     ESCRIPT_DLL_API
323     FunctionSpace&
324     operator=(const FunctionSpace& other);
325 jgs 82
326     //
327     // static null domain value
328 trankine 1426 static const NullDomain nullDomainValue;
329 jgs 82
330     //
331     // function space domain
332     const AbstractDomain* m_domain;
333 jgs 149
334 jgs 82 //
335     // function space type code.
336     int m_functionSpaceType;
337    
338     };
339    
340     } // end of namespace
341 jgs 117
342 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26