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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1800 - (hide annotations)
Thu Sep 18 05:28:20 2008 UTC (10 years, 10 months ago) by ksteube
File MIME type: text/plain
File size: 10868 byte(s)
Serialized parallel I/O when writing mesh or data to NetCDF file on multiple MPI processors.
Added domain method getMPIComm() to complement getMPISize() and getMPIRank().

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 ksteube 1800 /**
104     \brief
105     return the MPI communicator
106     */
107 ksteube 1312
108 ksteube 1800 ESCRIPT_DLL_API
109     virtual MPI_Comm getMPIComm() const;
110 ksteube 1312
111    
112 ksteube 1800
113 ksteube 1312 /**
114     \brief
115 jgs 82 Returns true if the given integer is a valid function space type
116     for this domain.
117     */
118 woo409 757 ESCRIPT_DLL_API
119 jgs 82 virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
120 jgs 115
121 jgs 82 /**
122     \brief
123 jgs 117 Return a description for this domain.
124 jgs 82 */
125 woo409 757 ESCRIPT_DLL_API
126 jgs 82 virtual std::string getDescription() const;
127 jgs 115
128 jgs 82 /**
129     \brief
130 jgs 117 Return a description for the given function space type code.
131 jgs 82 */
132 woo409 757 ESCRIPT_DLL_API
133 jgs 82 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
134 jgs 115
135 jgs 82 /**
136     \brief
137 jgs 117 Returns the spatial dimension of the domain.
138 jgs 115
139 jgs 117 This has to be implemented by the actual Domain adapter.
140 jgs 82 */
141 woo409 757 ESCRIPT_DLL_API
142 jgs 82 virtual int getDim() const;
143    
144     /**
145 jgs 117 \brief
146     Return true if given domains are equal.
147 jgs 82 */
148 woo409 757 ESCRIPT_DLL_API
149 jgs 121 virtual bool operator==(const AbstractDomain& other) const;
150 woo409 757 ESCRIPT_DLL_API
151 jgs 121 virtual bool operator!=(const AbstractDomain& other) const;
152 jgs 115
153 jgs 82 /**
154     \brief
155 jgs 117 Writes the domain to an external file filename.
156    
157 jgs 115 This has to be implemented by the actual Domain adapter.
158 jgs 82 */
159 woo409 757 ESCRIPT_DLL_API
160 jgs 82 virtual void write(const std::string& filename) const;
161    
162     /**
163     \brief
164 ksteube 1312 dumps the domain to an external file filename.
165    
166     This has to be implemented by the actual Domain adapter.
167     */
168     ESCRIPT_DLL_API
169     virtual void dump(const std::string& filename) const;
170    
171     /**
172     \brief
173 jgs 82 Return the number of data points per sample, and the number of samples as a pair.
174 jgs 117
175     This has to be implemented by the actual Domain adapter.
176    
177 jgs 82 \param functionSpaceCode Input - Code for the function space type.
178     \return pair, first - number of data points per sample, second - number of samples
179     */
180 woo409 757 ESCRIPT_DLL_API
181 jgs 82 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
182    
183     /**
184     \brief
185     Return the tag key for the given sample number.
186     \param functionSpaceType Input - The function space type.
187     \param sampleNo Input - The sample number.
188     */
189 woo409 757 ESCRIPT_DLL_API
190 jgs 82 virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
191 jgs 115
192 jgs 82 /**
193     \brief
194 gross 1044 sets a map from a clear tag name to a tag key
195     \param name Input - tag name.
196     \param tag Input - tag key.
197     */
198     ESCRIPT_DLL_API
199     virtual void setTagMap(const std::string& name, int tag);
200    
201     /**
202     \brief
203     Return the tag key for tag name.
204     \param name Input - tag name
205     */
206     ESCRIPT_DLL_API
207     virtual int getTag(const std::string& name) const;
208    
209     /**
210     \brief
211     Returns True if name is a defined tag name
212     \param name Input - tag name
213     */
214     ESCRIPT_DLL_API
215     virtual bool isValidTagName(const std::string& name) const;
216    
217     /**
218     \brief
219     Returns all tag names in a single string sperated by commas
220     */
221     ESCRIPT_DLL_API
222     virtual std::string showTagNames() const;
223    
224     /**
225     \brief
226 gross 964 Return a borrowed pointer to the sample reference number id list
227 jgs 110 \param functionSpaceType Input - The function space type.
228     */
229 woo409 757 ESCRIPT_DLL_API
230 gross 964 virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
231 jgs 115
232 jgs 110 /**
233     \brief
234 jgs 117 Assigns new location to the domain.
235    
236     This has to be implemented by the actual Domain adapter.
237 jgs 82 */
238 woo409 757 ESCRIPT_DLL_API
239 jgs 82 virtual void setNewX(const escript::Data& arg);
240    
241     /**
242     \brief
243 jgs 115 Interpolates data given on source onto target where source and target have to be given on the same domain.
244 jgs 117
245     This has to be implemented by the actual Domain adapter.
246 jgs 82 */
247 woo409 757 ESCRIPT_DLL_API
248 jgs 82 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
249 woo409 757 ESCRIPT_DLL_API
250 jgs 82 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
251 jgs 115
252 jgs 82 /**
253     \brief
254 jgs 115 Interpolates data given on source onto target where source and target are given on different domains.
255 jgs 117
256     This has to be implemented by the actual Domain adapter.
257 jgs 82 */
258 woo409 757 ESCRIPT_DLL_API
259 jgs 82 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
260 woo409 757 ESCRIPT_DLL_API
261 jgs 82 virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
262    
263     /**
264 jgs 117 \brief
265     Returns locations in the domain. The function space is chosen appropriately.
266 jgs 102 */
267 woo409 757 ESCRIPT_DLL_API
268 jgs 102 virtual escript::Data getX() const;
269 jgs 115
270 jgs 102 /**
271 jgs 117 \brief
272     Return boundary normals. The function space is chosen appropriately.
273 jgs 102 */
274 woo409 757 ESCRIPT_DLL_API
275 jgs 102 virtual escript::Data getNormal() const;
276 jgs 115
277 jgs 102 /**
278 jgs 117 \brief
279     Returns the local size of samples. The function space is chosen appropriately.
280 jgs 102 */
281 woo409 757 ESCRIPT_DLL_API
282 jgs 102 virtual escript::Data getSize() const;
283    
284     /**
285 jgs 82 \brief
286 jgs 115 Copies the location of data points on the domain into out.
287     The actual function space to be considered
288 jgs 82 is defined by out. out has to be defined on this.
289 jgs 117
290     This has to be implemented by the actual Domain adapter.
291 jgs 82 */
292 woo409 757 ESCRIPT_DLL_API
293 jgs 82 virtual void setToX(escript::Data& out) const;
294 jgs 115
295 jgs 82 /**
296     \brief
297 jgs 115 Copies the surface normals at data points into out.
298     The actual function space to be considered
299 jgs 82 is defined by out. out has to be defined on this.
300 jgs 117
301     This has to be implemented by the actual Domain adapter.
302 jgs 82 */
303 woo409 757 ESCRIPT_DLL_API
304 jgs 82 virtual void setToNormal(escript::Data& out) const;
305 jgs 115
306 jgs 82 /**
307     \brief
308 jgs 115 Copies the size of samples into out. The actual
309     function space to be considered
310 jgs 82 is defined by out. out has to be defined on this.
311 jgs 117
312     This has to be implemented by the actual Domain adapter.
313 jgs 82 */
314 woo409 757 ESCRIPT_DLL_API
315 jgs 82 virtual void setToSize(escript::Data& out) const;
316    
317     /**
318     \brief
319 jgs 115 Copies the gradient of arg into grad. The actual function space to be considered
320 jgs 82 for the gradient is defined by grad. arg and grad have 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 setToGradient(escript::Data& grad, const escript::Data& arg) const;
326     /**
327     \brief
328 jgs 153 Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
329 jgs 117
330     This has to be implemented by the actual Domain adapter.
331 jgs 82 */
332 woo409 757 ESCRIPT_DLL_API
333 jgs 153 virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
334 jgs 110
335 jgs 82 /**
336     \brief
337 jgs 153 Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
338 jgs 117
339     This has to be implemented by the actual Domain adapter.
340 jgs 110 */
341 woo409 757 ESCRIPT_DLL_API
342 jgs 153 virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
343 jgs 110
344     /**
345     \brief
346 jgs 82 returns the function space representation of the type functionSpaceCode on this domain
347     as a vtkObject.
348 jgs 117
349     This has to be implemented by the actual Domain adapter.
350 jgs 82 */
351     //virtual vtkObject createVtkObject(int functionSpaceCode) const;
352    
353 jgs 115 /**
354 gross 767 \brief assigns new tag newTag to all samples of functionspace with a positive
355     value of mask for any its sample point.
356    
357     */
358     ESCRIPT_DLL_API
359     virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
360    
361     /**
362 jgs 82 \brief
363     returns true if data on this domain and a function space of type functionSpaceCode has to
364     considered as cell centered data.
365 jgs 117
366     This has to be implemented by the actual Domain adapter.
367 jgs 82 */
368 woo409 757 ESCRIPT_DLL_API
369 jgs 82 virtual bool isCellOriented(int functionSpaceCode) const;
370    
371 jgs 117 /**
372     \brief
373 gross 797 returns status of the domain.
374    
375     This has to be implemented by the actual Domain adapter.
376     */
377     ESCRIPT_DLL_API
378     virtual StatusType getStatus() const;
379    
380     /**
381     \brief
382 jgs 117 Throw a standard exception. This function is called if any attempt
383     is made to use a base class function.
384     */
385 woo409 757 ESCRIPT_DLL_API
386 jgs 117 void throwStandardException(const std::string& functionName) const;
387    
388 gross 1716 /**
389     \brief
390     return the number of tags in use and a pointer to an array with the number of tags in use
391     */
392     ESCRIPT_DLL_API
393     virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
394    
395     ESCRIPT_DLL_API
396     virtual int* borrowListOfTagsInUse(int functionSpaceCode) const;
397    
398    
399    
400 jgs 82 protected:
401    
402     private:
403 jgs 115
404 gross 797 // buffer for coordinates used by function spaces
405 ksteube 1312 BufferMapType m_x_buffer;
406 gross 797
407     // buffer for normal vectors used by function spaces
408 ksteube 1312 BufferMapType m_normal_buffer;
409 gross 797
410     // buffer for normal element size used by function spaces
411 ksteube 1312 BufferMapType m_size_buffer;
412 gross 797
413 jgs 82 };
414    
415     } // end of namespace
416 jgs 117
417 jgs 82 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26