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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1872 - (show annotations)
Mon Oct 13 00:18:55 2008 UTC (10 years, 9 months ago) by jfenwick
File MIME type: text/plain
File size: 11360 byte(s)
Closing the moreshared branch

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26