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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1426 - (hide annotations)
Wed Feb 27 06:12:15 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 6214 byte(s)
Merge the changes to these few files with the windows port branch to test just these changes under linux and altix.
1 jgs 115
2 ksteube 1312 /* $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 jgs 115 #if !defined escript_FunctionSpace_20040323_H
17 jgs 82 #define escript_FunctionSpace_20040323_H
18 woo409 757 #include "system_dep.h"
19 jgs 82
20 jgs 474 #include "AbstractDomain.h"
21     #include "NullDomain.h"
22 jgs 82
23     #include <string>
24    
25 trankine 1426 class FunctionSpaceTestCase;
26    
27 jgs 82 namespace escript {
28    
29 jgs 117 //
30     // Forward declaration for class Data.
31     class Data;
32 jgs 82
33     /**
34     \brief
35     Give a short description of what FunctionSpace does.
36    
37     Description:
38 jgs 117 Give a detailed description of FunctionSpace.
39 jgs 82
40     Template Parameters:
41     For templates describe any conditions that the parameters used in the
42 jgs 117 template must satisfy.
43 jgs 82 */
44    
45 trankine 1426 class FunctionSpace {
46 jgs 82
47 trankine 1426 // These are using operator=()
48     friend class AbstractSystemMatrix;
49     friend class AbstractTransportProblem;
50     friend class ::FunctionSpaceTestCase;
51    
52 jgs 82 public:
53     /**
54     \brief
55 jgs 117 Default constructor for FunctionSpace.
56 jgs 82
57     Description:
58     Default constructor for FunctionSpace
59     Generates a function space with a null domain.
60    
61     Preconditions:
62 jgs 117 Describe any preconditions.
63 jgs 82
64     Throws:
65 jgs 117 Describe any exceptions thrown.
66 jgs 82 */
67 trankine 1426 ESCRIPT_DLL_API
68 jgs 82 FunctionSpace();
69    
70     /**
71     \brief
72 jgs 117 Constructor for FunctionSpace.
73 jgs 82
74     Description:
75     Constructor for FunctionSpace.
76 jgs 115
77 jgs 82 NOTE: The FunctionSpace class relies on the domain existing
78 jgs 115 for the lifetime of the FunctionSpace object. ie: domain must
79     be an externally managed object (!).
80 jgs 82 */
81 trankine 1426 ESCRIPT_DLL_API
82 jgs 117 FunctionSpace(const AbstractDomain& domain,
83     int functionSpaceType);
84 jgs 82
85     /**
86     \brief
87     Return the function space type code.
88     */
89 trankine 1426 ESCRIPT_DLL_API
90 jgs 117 int
91     getTypeCode() const;
92 jgs 82
93     /**
94     \brief
95     Return the function space domain.
96     */
97 trankine 1426 ESCRIPT_DLL_API
98 jgs 117 const
99     AbstractDomain&
100     getDomain() const;
101 jgs 82
102    
103 gross 767
104 jgs 82 /**
105 gross 767 \brief assigns new tag newTag to all samples with a positive
106     value of mask for any its sample point.
107    
108     */
109 trankine 1426 ESCRIPT_DLL_API
110 gross 767 void setTags(const int newTag, const escript::Data& mask) const;
111    
112    
113     /**
114 jgs 82 \brief
115     Return the shape of the data needed to represent the function space.
116     */
117 trankine 1426 ESCRIPT_DLL_API
118 jgs 117 std::pair<int,int>
119     getDataShape() const;
120 jgs 82
121     /**
122     \brief
123     Comparison operator.
124     Return true if function spaces are equal.
125     ie: Same domain and same function space type.
126     */
127 trankine 1426 ESCRIPT_DLL_API
128 jgs 117 bool
129     operator==(const FunctionSpace& other) const;
130 jgs 82
131 trankine 1426 ESCRIPT_DLL_API
132 jgs 117 bool
133     operator!=(const FunctionSpace& other) const;
134    
135 jgs 82 /**
136     \brief
137 jgs 115 Return a text description of the function space.
138 jgs 82 */
139 trankine 1426 ESCRIPT_DLL_API
140     const std::string &
141 jgs 117 toString() const;
142 ksteube 1312
143 trankine 1426 //#define DEBUG_PY_STRINGS
144    
145     #ifdef DEBUG_PY_STRINGS
146 jgs 82 /**
147     \brief
148 trankine 1426 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 jgs 82 Return the tag associated with the given sample number.
162     */
163 trankine 1426 ESCRIPT_DLL_API
164 jgs 117 int
165     getTagFromSampleNo(int sampleNo) const;
166 jgs 115
167 jgs 110 /**
168     \brief
169 jgs 149 Return the tag associated with the given data-point number.
170 jgs 110 */
171 trankine 1426 ESCRIPT_DLL_API
172 jgs 117 int
173 jgs 149 getTagFromDataPointNo(int dataPointNo) const;
174    
175     /**
176     \brief
177     Return the reference number associated with the given sample number.
178 gross 964 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 jgs 149 */
181 trankine 1426 ESCRIPT_DLL_API
182 gross 964 inline
183 jgs 149 int
184 gross 964 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 trankine 1426 ESCRIPT_DLL_API
193 gross 964 int*
194     borrowSampleReferenceIDs() const;
195 jgs 82
196     /**
197     \brief
198 jgs 149 Return the spatial locations of the data points.
199 jgs 82 */
200 trankine 1426 ESCRIPT_DLL_API
201 jgs 117 escript::Data
202     getX() const;
203 jgs 149
204 jgs 82 /**
205     \brief
206     Return the surface normal field.
207     */
208 trankine 1426 ESCRIPT_DLL_API
209 jgs 117 escript::Data
210     getNormal() const;
211 jgs 82
212     /**
213     \brief
214     Return the sample size (e.g. the diameter of elements, radius of particles).
215     */
216 trankine 1426 ESCRIPT_DLL_API
217 jgs 117 escript::Data
218     getSize() const;
219 jgs 82
220     /**
221     \brief
222 jgs 115 Return the number of samples.
223 jgs 82 */
224 trankine 1426 ESCRIPT_DLL_API
225 jgs 117 inline
226     int
227     getNumSamples() const {
228 jgs 82 return getDataShape().second;
229     }
230    
231     /**
232     \brief
233     Return the number of data points per sample.
234     */
235 trankine 1426 ESCRIPT_DLL_API
236 jgs 117 inline
237     int
238     getNumDPPSample() const {
239 jgs 82 return getNumDataPointsPerSample();
240     }
241 jgs 149
242 trankine 1426 ESCRIPT_DLL_API
243 jgs 117 inline
244     int
245     getNumDataPointsPerSample() const {
246 jgs 82 return getDataShape().first;
247     }
248    
249     /**
250     \brief
251     Return the spatial dimension of the underlying domain.
252     */
253 trankine 1426 ESCRIPT_DLL_API
254 jgs 117 inline
255     int
256     getDim() const {
257 jgs 82 return getDomain().getDim();
258     }
259 jgs 115
260 jgs 82 protected:
261    
262     private:
263 trankine 1426 /**
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 jgs 82
280     //
281     // static null domain value
282 trankine 1426 static const NullDomain nullDomainValue;
283 jgs 82
284     //
285     // function space domain
286     const AbstractDomain* m_domain;
287 jgs 149
288 jgs 82 //
289     // function space type code.
290     int m_functionSpaceType;
291    
292 trankine 1426 //
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 jgs 82 };
300    
301     } // end of namespace
302 jgs 117
303 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26