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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 elspeth 615
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 jgs 115 #if !defined escript_AbstractDomain_20040609_H
16 jgs 82 #define escript_AbstractDomain_20040609_H
17 jgs 115
18 woo409 757 #include "system_dep.h"
19    
20 jgs 82 #include <string>
21 gross 797 #include <map>
22 jgs 153 #include <boost/python/dict.hpp>
23 gross 1716 #include <boost/python/list.hpp>
24 ksteube 1800 #include "paso/Paso_MPI.h"
25 jgs 82
26 jfenwick 1872
27     #include "Pointers.h"
28    
29 jgs 82 namespace escript {
30 gross 797 // class forward declarations
31 jgs 117 class Data;
32 jgs 82 /**
33     \brief
34     Base class for all escript domains.
35    
36     Description:
37     Base class for all escript domains.
38     */
39 jgs 115
40 jfenwick 1872 class AbstractDomain;
41 jgs 82
42 jfenwick 1872 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 jgs 82 public:
48    
49 jfenwick 1872 /**
50     \brief Returns smart pointer which is managing this object.
51     If one does not exist yet it creates one.
52 ksteube 1312
53 jfenwick 1872 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 gross 797 // structure holding values for X, size and normal
61     typedef int StatusType;
62 ksteube 1312 struct ValueBuffer
63     {
64     StatusType m_status;
65     boost::shared_ptr<Data> m_data;
66     };
67     typedef struct ValueBuffer ValueBuffer;
68 gross 797
69     //
70     // map from function space type code to value buffer
71 ksteube 1312 typedef std::map<int, ValueBuffer> BufferMapType;
72 gross 797
73    
74 jgs 82 /**
75     \brief
76 jgs 117 Default constructor for AbstractDomain.
77 jgs 82
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 jgs 117 constructable we avoid a boost.python wrapper class. A call to
82 jgs 82 almost any of the base class functions will throw an exception
83 jgs 115 as they are not intended to be used directly, but are overridden
84 jgs 117 by the underlying solver package which escript is linked to.
85 jgs 82
86 jgs 115 By default, this class is overridden by the class NullDomain.
87    
88 jgs 82 Preconditions:
89 jgs 117 Describe any preconditions.
90 jgs 82
91     Throws:
92 jgs 117 Describe any exceptions thrown.
93 jgs 82 */
94 woo409 757 ESCRIPT_DLL_API
95 jgs 82 AbstractDomain();
96 jgs 115
97 jgs 82 /**
98     \brief
99 jgs 117 Destructor for AbstractDomain.
100 jgs 82
101     Description:
102 jgs 117 Destructor for AbstractDomain.
103 jgs 82 */
104 woo409 757 ESCRIPT_DLL_API
105 jgs 82 virtual ~AbstractDomain();
106 jgs 115
107 jgs 82 /**
108     \brief
109 ksteube 1312 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 jgs 82 Returns true if the given integer is a valid function space type
126     for this domain.
127     */
128 woo409 757 ESCRIPT_DLL_API
129 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
130 jgs 115
131 jgs 82 /**
132     \brief
133 jgs 117 Return a description for this domain.
134 jgs 82 */
135 woo409 757 ESCRIPT_DLL_API
136 jgs 82 virtual std::string getDescription() const;
137 jgs 115
138 jgs 82 /**
139     \brief
140 jgs 117 Return a description for the given function space type code.
141 jgs 82 */
142 woo409 757 ESCRIPT_DLL_API
143 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
144 jgs 115
145 jgs 82 /**
146     \brief
147 jgs 117 Returns the spatial dimension of the domain.
148 jgs 115
149 jgs 117 This has to be implemented by the actual Domain adapter.
150 jgs 82 */
151 woo409 757 ESCRIPT_DLL_API
152 jgs 82 virtual int getDim() const;
153    
154     /**
155 jgs 117 \brief
156     Return true if given domains are equal.
157 jgs 82 */
158 woo409 757 ESCRIPT_DLL_API
159 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
160 woo409 757 ESCRIPT_DLL_API
161 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
162 jgs 115
163 jgs 82 /**
164     \brief
165 jgs 117 Writes the domain to an external file filename.
166    
167 jgs 115 This has to be implemented by the actual Domain adapter.
168 jgs 82 */
169 woo409 757 ESCRIPT_DLL_API
170 jgs 82 virtual void write(const std::string& filename) const;
171    
172     /**
173     \brief
174 ksteube 1312 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 jgs 82 Return the number of data points per sample, and the number of samples as a pair.
184 jgs 117
185     This has to be implemented by the actual Domain adapter.
186    
187 jgs 82 \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 woo409 757 ESCRIPT_DLL_API
191 jgs 82 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 woo409 757 ESCRIPT_DLL_API
200 jgs 82 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
201 jgs 115
202 jgs 82 /**
203     \brief
204 gross 1044 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 gross 964 Return a borrowed pointer to the sample reference number id list
237 jgs 110 \param functionSpaceType Input - The function space type.
238     */
239 woo409 757 ESCRIPT_DLL_API
240 gross 964 virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
241 jgs 115
242 jgs 110 /**
243     \brief
244 jgs 117 Assigns new location to the domain.
245    
246     This has to be implemented by the actual Domain adapter.
247 jgs 82 */
248 woo409 757 ESCRIPT_DLL_API
249 jgs 82 virtual void setNewX(const escript::Data& arg);
250    
251     /**
252     \brief
253 jgs 115 Interpolates data given on source onto target where source and target have to be given on the same domain.
254 jgs 117
255     This has to be implemented by the actual Domain adapter.
256 jgs 82 */
257 woo409 757 ESCRIPT_DLL_API
258 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
259 woo409 757 ESCRIPT_DLL_API
260 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
261 jgs 115
262 jgs 82 /**
263     \brief
264 jgs 115 Interpolates data given on source onto target where source and target are given on different domains.
265 jgs 117
266     This has to be implemented by the actual Domain adapter.
267 jgs 82 */
268 woo409 757 ESCRIPT_DLL_API
269 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
270 woo409 757 ESCRIPT_DLL_API
271 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
272    
273     /**
274 jgs 117 \brief
275     Returns locations in the domain. The function space is chosen appropriately.
276 jgs 102 */
277 woo409 757 ESCRIPT_DLL_API
278 jgs 102 virtual escript::Data getX() const;
279 jgs 115
280 jgs 102 /**
281 jgs 117 \brief
282     Return boundary normals. The function space is chosen appropriately.
283 jgs 102 */
284 woo409 757 ESCRIPT_DLL_API
285 jgs 102 virtual escript::Data getNormal() const;
286 jgs 115
287 jgs 102 /**
288 jgs 117 \brief
289     Returns the local size of samples. The function space is chosen appropriately.
290 jgs 102 */
291 woo409 757 ESCRIPT_DLL_API
292 jgs 102 virtual escript::Data getSize() const;
293    
294     /**
295 jgs 82 \brief
296 jgs 115 Copies the location of data points on the domain into out.
297     The actual function space to be considered
298 jgs 82 is defined by out. out has to be defined on this.
299 jgs 117
300     This has to be implemented by the actual Domain adapter.
301 jgs 82 */
302 woo409 757 ESCRIPT_DLL_API
303 jgs 82 virtual void setToX(escript::Data& out) const;
304 jgs 115
305 jgs 82 /**
306     \brief
307 jgs 115 Copies the surface normals at data points into out.
308     The actual function space to be considered
309 jgs 82 is defined by out. out has to be defined on this.
310 jgs 117
311     This has to be implemented by the actual Domain adapter.
312 jgs 82 */
313 woo409 757 ESCRIPT_DLL_API
314 jgs 82 virtual void setToNormal(escript::Data& out) const;
315 jgs 115
316 jgs 82 /**
317     \brief
318 jgs 115 Copies the size of samples into out. The actual
319     function space to be considered
320 jgs 82 is defined by out. out has to be defined on this.
321 jgs 117
322     This has to be implemented by the actual Domain adapter.
323 jgs 82 */
324 woo409 757 ESCRIPT_DLL_API
325 jgs 82 virtual void setToSize(escript::Data& out) const;
326    
327     /**
328     \brief
329 jgs 115 Copies the gradient of arg into grad. The actual function space to be considered
330 jgs 82 for the gradient is defined by grad. arg and grad have to be defined on this.
331 jgs 117
332     This has to be implemented by the actual Domain adapter.
333 jgs 82 */
334 woo409 757 ESCRIPT_DLL_API
335 jgs 82 virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
336     /**
337     \brief
338 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
339 jgs 117
340     This has to be implemented by the actual Domain adapter.
341 jgs 82 */
342 woo409 757 ESCRIPT_DLL_API
343 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
344 jgs 110
345 jgs 82 /**
346     \brief
347 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
348 jgs 117
349     This has to be implemented by the actual Domain adapter.
350 jgs 110 */
351 woo409 757 ESCRIPT_DLL_API
352 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
353 jgs 110
354     /**
355     \brief
356 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
357     as a vtkObject.
358 jgs 117
359     This has to be implemented by the actual Domain adapter.
360 jgs 82 */
361     //virtual vtkObject createVtkObject(int functionSpaceCode) const;
362    
363 jgs 115 /**
364 gross 767 \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 jgs 82 \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 jgs 117
376     This has to be implemented by the actual Domain adapter.
377 jgs 82 */
378 woo409 757 ESCRIPT_DLL_API
379 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
380    
381 jgs 117 /**
382     \brief
383 gross 797 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 jgs 117 Throw a standard exception. This function is called if any attempt
393     is made to use a base class function.
394     */
395 woo409 757 ESCRIPT_DLL_API
396 jgs 117 void throwStandardException(const std::string& functionName) const;
397    
398 gross 1716 /**
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 jfenwick 1802 /**
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 gross 1716
414 jgs 82 protected:
415    
416     private:
417 jgs 115
418 gross 797 // buffer for coordinates used by function spaces
419 ksteube 1312 BufferMapType m_x_buffer;
420 gross 797
421     // buffer for normal vectors used by function spaces
422 ksteube 1312 BufferMapType m_normal_buffer;
423 gross 797
424     // buffer for normal element size used by function spaces
425 ksteube 1312 BufferMapType m_size_buffer;
426 gross 797
427 jgs 82 };
428    
429     } // end of namespace
430 jgs 117
431 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26