/[escript]/branches/more_shared_ptrs_from_1812/escript/src/AbstractDomain.h
ViewVC logotype

Contents of /branches/more_shared_ptrs_from_1812/escript/src/AbstractDomain.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1828 - (show annotations)
Thu Oct 2 04:52:11 2008 UTC (11 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 11322 byte(s)
Branch commit.
Added getPtr to DataAbstract.
Passes all unit tests.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26