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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2635 - (hide annotations)
Thu Aug 27 04:54:41 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 12152 byte(s)
A bunch of changes related to saveDataCSV.
[Not completed or unit tested yet]

Added saveDataCSV to util.py
AbstractDomain (and MeshAdapter) have a commonFunctionSpace method to 
take a group of FunctionSpaces and return something they can all be interpolated to.

Added pointToStream() in DataTypes to help print points.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26