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

Contents of /trunk/escript/src/AbstractDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 964 - (show annotations)
Tue Feb 13 05:10:26 2007 UTC (12 years, 10 months ago) by gross
File MIME type: text/plain
File size: 9322 byte(s)
The set/getRefVal functions of Data objects have been removed (mainly to avoid later problems with MPI).
Moreover, a faster access to the reference id of samples has been introduced. I don't think that anybody will
profit form this at this stage but it will allow a faster dump of data objects.


1 // $Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
7 * Primary Business: Queensland, Australia *
8 * Licensed under the Open Software License version 3.0 *
9 * http://www.opensource.org/licenses/osl-3.0.php *
10 * *
11 ************************************************************
12
13 */
14
15 #if !defined escript_AbstractDomain_20040609_H
16 #define escript_AbstractDomain_20040609_H
17
18 #include "system_dep.h"
19
20 #include <string>
21 #include <map>
22 #include <boost/python/dict.hpp>
23
24 namespace escript {
25 // class forward declarations
26 class Data;
27 /**
28 \brief
29 Base class for all escript domains.
30
31 Description:
32 Base class for all escript domains.
33 */
34
35 class AbstractDomain {
36
37 public:
38
39
40 // structure holding values for X, size and normal
41 typedef int StatusType;
42 struct ValueBuffer
43 {
44 StatusType m_status;
45 boost::shared_ptr<Data> m_data;
46 };
47 typedef struct ValueBuffer ValueBuffer;
48
49 //
50 // map from function space type code to value buffer
51 typedef std::map<int, ValueBuffer> BufferMapType;
52
53
54 /**
55 \brief
56 Default constructor for AbstractDomain.
57
58 Description:
59 Default constructor for AbstractDomain. As the name suggests
60 this is intended to be an abstract base class but by making it
61 constructable we avoid a boost.python wrapper class. A call to
62 almost any of the base class functions will throw an exception
63 as they are not intended to be used directly, but are overridden
64 by the underlying solver package which escript is linked to.
65
66 By default, this class is overridden by the class NullDomain.
67
68 Preconditions:
69 Describe any preconditions.
70
71 Throws:
72 Describe any exceptions thrown.
73 */
74 ESCRIPT_DLL_API
75 AbstractDomain();
76
77 /**
78 \brief
79 Destructor for AbstractDomain.
80
81 Description:
82 Destructor for AbstractDomain.
83 */
84 ESCRIPT_DLL_API
85 virtual ~AbstractDomain();
86
87 /**
88 \brief
89 Returns true if the given integer is a valid function space type
90 for this domain.
91 */
92 ESCRIPT_DLL_API
93 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
94
95 /**
96 \brief
97 Return a description for this domain.
98 */
99 ESCRIPT_DLL_API
100 virtual std::string getDescription() const;
101
102 /**
103 \brief
104 Return a description for the given function space type code.
105 */
106 ESCRIPT_DLL_API
107 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
108
109 /**
110 \brief
111 Returns the spatial dimension of the domain.
112
113 This has to be implemented by the actual Domain adapter.
114 */
115 ESCRIPT_DLL_API
116 virtual int getDim() const;
117
118 /**
119 \brief
120 Return true if given domains are equal.
121 */
122 ESCRIPT_DLL_API
123 virtual bool operator==(const AbstractDomain& other) const;
124 ESCRIPT_DLL_API
125 virtual bool operator!=(const AbstractDomain& other) const;
126
127 /**
128 \brief
129 Writes the domain to an external file filename.
130
131 This has to be implemented by the actual Domain adapter.
132 */
133 ESCRIPT_DLL_API
134 virtual void write(const std::string& filename) const;
135
136 /**
137 \brief
138 Return the number of data points per sample, and the number of samples as a pair.
139
140 This has to be implemented by the actual Domain adapter.
141
142 \param functionSpaceCode Input - Code for the function space type.
143 \return pair, first - number of data points per sample, second - number of samples
144 */
145 ESCRIPT_DLL_API
146 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
147
148 /**
149 \brief
150 Return the tag key for the given sample number.
151 \param functionSpaceType Input - The function space type.
152 \param sampleNo Input - The sample number.
153 */
154 ESCRIPT_DLL_API
155 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
156
157 /**
158 \brief
159 Return a borrowed pointer to the sample reference number id list
160 \param functionSpaceType Input - The function space type.
161 */
162 ESCRIPT_DLL_API
163 virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
164
165 /**
166 \brief
167 Assigns new location to the domain.
168
169 This has to be implemented by the actual Domain adapter.
170 */
171 ESCRIPT_DLL_API
172 virtual void setNewX(const escript::Data& arg);
173
174 /**
175 \brief
176 Interpolates data given on source onto target where source and target have to be given on the same domain.
177
178 This has to be implemented by the actual Domain adapter.
179 */
180 ESCRIPT_DLL_API
181 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
182 ESCRIPT_DLL_API
183 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
184
185 /**
186 \brief
187 Interpolates data given on source onto target where source and target are given on different domains.
188
189 This has to be implemented by the actual Domain adapter.
190 */
191 ESCRIPT_DLL_API
192 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
193 ESCRIPT_DLL_API
194 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
195
196 /**
197 \brief
198 Returns locations in the domain. The function space is chosen appropriately.
199 */
200 ESCRIPT_DLL_API
201 virtual escript::Data getX() const;
202
203 /**
204 \brief
205 Return boundary normals. The function space is chosen appropriately.
206 */
207 ESCRIPT_DLL_API
208 virtual escript::Data getNormal() const;
209
210 /**
211 \brief
212 Returns the local size of samples. The function space is chosen appropriately.
213 */
214 ESCRIPT_DLL_API
215 virtual escript::Data getSize() const;
216
217 /**
218 \brief
219 Copies the location of data points on the domain into out.
220 The actual function space to be considered
221 is defined by out. out has to be defined on this.
222
223 This has to be implemented by the actual Domain adapter.
224 */
225 ESCRIPT_DLL_API
226 virtual void setToX(escript::Data& out) const;
227
228 /**
229 \brief
230 Copies the surface normals at data points into out.
231 The actual function space to be considered
232 is defined by out. out has to be defined on this.
233
234 This has to be implemented by the actual Domain adapter.
235 */
236 ESCRIPT_DLL_API
237 virtual void setToNormal(escript::Data& out) const;
238
239 /**
240 \brief
241 Copies the size of samples into out. The actual
242 function space to be considered
243 is defined by out. out has to be defined on this.
244
245 This has to be implemented by the actual Domain adapter.
246 */
247 ESCRIPT_DLL_API
248 virtual void setToSize(escript::Data& out) const;
249
250 /**
251 \brief
252 Copies the gradient of arg into grad. The actual function space to be considered
253 for the gradient is defined by grad. arg and grad have to be defined on this.
254
255 This has to be implemented by the actual Domain adapter.
256 */
257 ESCRIPT_DLL_API
258 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
259 /**
260 \brief
261 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
262
263 This has to be implemented by the actual Domain adapter.
264 */
265 ESCRIPT_DLL_API
266 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
267
268 /**
269 \brief
270 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
271
272 This has to be implemented by the actual Domain adapter.
273 */
274 ESCRIPT_DLL_API
275 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
276
277 /**
278 \brief
279 returns the function space representation of the type functionSpaceCode on this domain
280 as a vtkObject.
281
282 This has to be implemented by the actual Domain adapter.
283 */
284 //virtual vtkObject createVtkObject(int functionSpaceCode) const;
285
286 /**
287 \brief assigns new tag newTag to all samples of functionspace with a positive
288 value of mask for any its sample point.
289
290 */
291 ESCRIPT_DLL_API
292 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
293
294 /**
295 \brief
296 returns true if data on this domain and a function space of type functionSpaceCode has to
297 considered as cell centered data.
298
299 This has to be implemented by the actual Domain adapter.
300 */
301 ESCRIPT_DLL_API
302 virtual bool isCellOriented(int functionSpaceCode) const;
303
304 /**
305 \brief
306 returns status of the domain.
307
308 This has to be implemented by the actual Domain adapter.
309 */
310 ESCRIPT_DLL_API
311 virtual StatusType getStatus() const;
312
313 /**
314 \brief
315 Throw a standard exception. This function is called if any attempt
316 is made to use a base class function.
317 */
318 ESCRIPT_DLL_API
319 void throwStandardException(const std::string& functionName) const;
320
321 protected:
322
323 private:
324
325 // buffer for coordinates used by function spaces
326 BufferMapType m_x_buffer;
327
328 // buffer for normal vectors used by function spaces
329 BufferMapType m_normal_buffer;
330
331 // buffer for normal element size used by function spaces
332 BufferMapType m_size_buffer;
333
334 };
335
336 } // end of namespace
337
338 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26