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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1
2 /*******************************************************
3 *
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
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 #include <boost/python/list.hpp>
24 #include "paso/Paso_MPI.h"
25
26 namespace escript {
27 // class forward declarations
28 class Data;
29 /**
30 \brief
31 Base class for all escript domains.
32
33 Description:
34 Base class for all escript domains.
35 */
36
37 class AbstractDomain {
38
39 public:
40
41
42 // structure holding values for X, size and normal
43 typedef int StatusType;
44 struct ValueBuffer
45 {
46 StatusType m_status;
47 boost::shared_ptr<Data> m_data;
48 };
49 typedef struct ValueBuffer ValueBuffer;
50
51 //
52 // map from function space type code to value buffer
53 typedef std::map<int, ValueBuffer> BufferMapType;
54
55
56 /**
57 \brief
58 Default constructor for AbstractDomain.
59
60 Description:
61 Default constructor for AbstractDomain. As the name suggests
62 this is intended to be an abstract base class but by making it
63 constructable we avoid a boost.python wrapper class. A call to
64 almost any of the base class functions will throw an exception
65 as they are not intended to be used directly, but are overridden
66 by the underlying solver package which escript is linked to.
67
68 By default, this class is overridden by the class NullDomain.
69
70 Preconditions:
71 Describe any preconditions.
72
73 Throws:
74 Describe any exceptions thrown.
75 */
76 ESCRIPT_DLL_API
77 AbstractDomain();
78
79 /**
80 \brief
81 Destructor for AbstractDomain.
82
83 Description:
84 Destructor for AbstractDomain.
85 */
86 ESCRIPT_DLL_API
87 virtual ~AbstractDomain();
88
89 /**
90 \brief
91 return the number of processors used for this domain
92 */
93 ESCRIPT_DLL_API
94 virtual int getMPISize() const;
95 /**
96 \brief
97 return the number MPI rank of this processor
98 */
99
100 ESCRIPT_DLL_API
101 virtual int getMPIRank() const;
102
103
104
105 /**
106 \brief
107 Returns true if the given integer is a valid function space type
108 for this domain.
109 */
110 ESCRIPT_DLL_API
111 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
112
113 /**
114 \brief
115 Return a description for this domain.
116 */
117 ESCRIPT_DLL_API
118 virtual std::string getDescription() const;
119
120 /**
121 \brief
122 Return a description for the given function space type code.
123 */
124 ESCRIPT_DLL_API
125 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
126
127 /**
128 \brief
129 Returns the spatial dimension of the domain.
130
131 This has to be implemented by the actual Domain adapter.
132 */
133 ESCRIPT_DLL_API
134 virtual int getDim() const;
135
136 /**
137 \brief
138 Return true if given domains are equal.
139 */
140 ESCRIPT_DLL_API
141 virtual bool operator==(const AbstractDomain& other) const;
142 ESCRIPT_DLL_API
143 virtual bool operator!=(const AbstractDomain& other) const;
144
145 /**
146 \brief
147 Writes the domain to an external file filename.
148
149 This has to be implemented by the actual Domain adapter.
150 */
151 ESCRIPT_DLL_API
152 virtual void write(const std::string& filename) const;
153
154 /**
155 \brief
156 dumps the domain to an external file filename.
157
158 This has to be implemented by the actual Domain adapter.
159 */
160 ESCRIPT_DLL_API
161 virtual void dump(const std::string& filename) const;
162
163 /**
164 \brief
165 Return the number of data points per sample, and the number of samples as a pair.
166
167 This has to be implemented by the actual Domain adapter.
168
169 \param functionSpaceCode Input - Code for the function space type.
170 \return pair, first - number of data points per sample, second - number of samples
171 */
172 ESCRIPT_DLL_API
173 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
174
175 /**
176 \brief
177 Return the tag key for the given sample number.
178 \param functionSpaceType Input - The function space type.
179 \param sampleNo Input - The sample number.
180 */
181 ESCRIPT_DLL_API
182 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
183
184 /**
185 \brief
186 sets a map from a clear tag name to a tag key
187 \param name Input - tag name.
188 \param tag Input - tag key.
189 */
190 ESCRIPT_DLL_API
191 virtual void setTagMap(const std::string& name, int tag);
192
193 /**
194 \brief
195 Return the tag key for tag name.
196 \param name Input - tag name
197 */
198 ESCRIPT_DLL_API
199 virtual int getTag(const std::string& name) const;
200
201 /**
202 \brief
203 Returns True if name is a defined tag name
204 \param name Input - tag name
205 */
206 ESCRIPT_DLL_API
207 virtual bool isValidTagName(const std::string& name) const;
208
209 /**
210 \brief
211 Returns all tag names in a single string sperated by commas
212 */
213 ESCRIPT_DLL_API
214 virtual std::string showTagNames() const;
215
216 /**
217 \brief
218 Return a borrowed pointer to the sample reference number id list
219 \param functionSpaceType Input - The function space type.
220 */
221 ESCRIPT_DLL_API
222 virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
223
224 /**
225 \brief
226 Assigns new location to the domain.
227
228 This has to be implemented by the actual Domain adapter.
229 */
230 ESCRIPT_DLL_API
231 virtual void setNewX(const escript::Data& arg);
232
233 /**
234 \brief
235 Interpolates data given on source onto target where source and target have to be given on the same domain.
236
237 This has to be implemented by the actual Domain adapter.
238 */
239 ESCRIPT_DLL_API
240 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
241 ESCRIPT_DLL_API
242 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
243
244 /**
245 \brief
246 Interpolates data given on source onto target where source and target are given on different domains.
247
248 This has to be implemented by the actual Domain adapter.
249 */
250 ESCRIPT_DLL_API
251 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
252 ESCRIPT_DLL_API
253 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
254
255 /**
256 \brief
257 Returns locations in the domain. The function space is chosen appropriately.
258 */
259 ESCRIPT_DLL_API
260 virtual escript::Data getX() const;
261
262 /**
263 \brief
264 Return boundary normals. The function space is chosen appropriately.
265 */
266 ESCRIPT_DLL_API
267 virtual escript::Data getNormal() const;
268
269 /**
270 \brief
271 Returns the local size of samples. The function space is chosen appropriately.
272 */
273 ESCRIPT_DLL_API
274 virtual escript::Data getSize() const;
275
276 /**
277 \brief
278 Copies the location of data points on the domain into out.
279 The actual function space to be considered
280 is defined by out. out has to be defined on this.
281
282 This has to be implemented by the actual Domain adapter.
283 */
284 ESCRIPT_DLL_API
285 virtual void setToX(escript::Data& out) const;
286
287 /**
288 \brief
289 Copies the surface normals at data points into out.
290 The actual function space to be considered
291 is defined by out. out has to be defined on this.
292
293 This has to be implemented by the actual Domain adapter.
294 */
295 ESCRIPT_DLL_API
296 virtual void setToNormal(escript::Data& out) const;
297
298 /**
299 \brief
300 Copies the size of samples into out. The actual
301 function space to be considered
302 is defined by out. out has to be defined on this.
303
304 This has to be implemented by the actual Domain adapter.
305 */
306 ESCRIPT_DLL_API
307 virtual void setToSize(escript::Data& out) const;
308
309 /**
310 \brief
311 Copies the gradient of arg into grad. The actual function space to be considered
312 for the gradient is defined by grad. arg and grad have to be defined on this.
313
314 This has to be implemented by the actual Domain adapter.
315 */
316 ESCRIPT_DLL_API
317 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
318 /**
319 \brief
320 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
321
322 This has to be implemented by the actual Domain adapter.
323 */
324 ESCRIPT_DLL_API
325 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
326
327 /**
328 \brief
329 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
330
331 This has to be implemented by the actual Domain adapter.
332 */
333 ESCRIPT_DLL_API
334 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
335
336 /**
337 \brief
338 returns the function space representation of the type functionSpaceCode on this domain
339 as a vtkObject.
340
341 This has to be implemented by the actual Domain adapter.
342 */
343 //virtual vtkObject createVtkObject(int functionSpaceCode) const;
344
345 /**
346 \brief assigns new tag newTag to all samples of functionspace with a positive
347 value of mask for any its sample point.
348
349 */
350 ESCRIPT_DLL_API
351 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
352
353 /**
354 \brief
355 returns true if data on this domain and a function space of type functionSpaceCode has to
356 considered as cell centered data.
357
358 This has to be implemented by the actual Domain adapter.
359 */
360 ESCRIPT_DLL_API
361 virtual bool isCellOriented(int functionSpaceCode) const;
362
363 /**
364 \brief
365 returns status of the domain.
366
367 This has to be implemented by the actual Domain adapter.
368 */
369 ESCRIPT_DLL_API
370 virtual StatusType getStatus() const;
371
372 /**
373 \brief
374 Throw a standard exception. This function is called if any attempt
375 is made to use a base class function.
376 */
377 ESCRIPT_DLL_API
378 void throwStandardException(const std::string& functionName) const;
379
380 /**
381 \brief
382 return the number of tags in use and a pointer to an array with the number of tags in use
383 */
384 ESCRIPT_DLL_API
385 virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
386
387 ESCRIPT_DLL_API
388 virtual int* borrowListOfTagsInUse(int functionSpaceCode) const;
389
390 /**
391 \brief Checks if this domain allows tags for the specified functionSpaceCode.
392 */
393 ESCRIPT_DLL_API
394 virtual bool canTag(int functionspacecode) const;
395
396 protected:
397
398 private:
399
400 // buffer for coordinates used by function spaces
401 BufferMapType m_x_buffer;
402
403 // buffer for normal vectors used by function spaces
404 BufferMapType m_normal_buffer;
405
406 // buffer for normal element size used by function spaces
407 BufferMapType m_size_buffer;
408
409 };
410
411 } // end of namespace
412
413 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26