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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1801 - (hide annotations)
Fri Sep 19 01:37:09 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/plain
File size: 10754 byte(s)
Fixed serialization of I/O for MPI...code didn't compile without MPI

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26