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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/AbstractDomain.h revision 104 by jgs, Fri Dec 17 07:43:12 2004 UTC trunk/escript/src/AbstractDomain.h revision 1877 by ksteube, Tue Oct 14 02:58:39 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   ******************************************************************************  *
4   *                                                                            *  * Copyright (c) 2003-2008 by University of Queensland
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Earth Systems Science Computational Center (ESSCC)
6   *                                                                            *  * http://www.uq.edu.au/esscc
7   * This software is the property of ACcESS. No part of this code              *  *
8   * may be copied in any form or by any means without the expressed written    *  * Primary Business: Queensland, Australia
9   * consent of ACcESS.  Copying, use or modification of this software          *  * Licensed under the Open Software License version 3.0
10   * by any unauthorised person is illegal unless that person has a software    *  * http://www.opensource.org/licenses/osl-3.0.php
11   * license agreement with ACcESS.                                             *  *
12   *                                                                            *  *******************************************************/
13   ******************************************************************************  
14  */  
15                                                                              #if !defined escript_AbstractDomain_20040609_H
 #if !defined  escript_AbstractDomain_20040609_H  
16  #define escript_AbstractDomain_20040609_H  #define escript_AbstractDomain_20040609_H
17                                                                                                                        
18    #include "system_dep.h"
19    
20  #include <string>  #include <string>
21  #include <utility>  #include <map>
22    #include <boost/python/dict.hpp>
23    #include <boost/python/list.hpp>
24    #include "paso/Paso_MPI.h"
25    
 namespace escript {  
26    
27      class Data;  #include "Pointers.h"
28      class AbstractSystemMatrix;  
29      class FunctionSpace;  namespace escript {
30    // class forward declarations
31    class Data;
32  /**  /**
33     \brief     \brief
34     Base class for all escript domains.     Base class for all escript domains.
# Line 31  namespace escript { Line 36  namespace escript {
36     Description:     Description:
37     Base class for all escript domains.     Base class for all escript domains.
38  */  */
39  class AbstractDomain {  
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:   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       ESCRIPT_DLL_API
56       Domain_ptr getPtr();
57       ESCRIPT_DLL_API
58       const_Domain_ptr getPtr() const;
59    
60       // structure holding values for X, size and normal
61       typedef int StatusType;
62       struct ValueBuffer
63       {
64           StatusType m_status;
65           boost::shared_ptr<Data> m_data;
66       };
67       typedef struct ValueBuffer ValueBuffer;
68    
69       //
70       // map from function space type code to value buffer
71       typedef std::map<int, ValueBuffer> BufferMapType;
72    
73    
74    /**    /**
75       \brief       \brief
76       Default constructor for AbstractDomain       Default constructor for AbstractDomain.
77    
78       Description:       Description:
79       Default constructor for AbstractDomain. As the name suggests       Default constructor for AbstractDomain. As the name suggests
80       this is intended to be an abstract base class but by making it       this is intended to be an abstract base class but by making it
81       constructable avoid a boost.python wrapper class. A call to       constructable we avoid a boost.python wrapper class. A call to
82       almost any of the base class functions will throw an exception       almost any of the base class functions will throw an exception
83       as they are not intended to be used.       as they are not intended to be used directly, but are overridden
84         by the underlying solver package which escript is linked to.
85    
86         By default, this class is overridden by the class NullDomain.
87    
88       Preconditions:       Preconditions:
89       Describe any preconditions       Describe any preconditions.
90    
91       Throws:       Throws:
92       Describe any exceptions thrown       Describe any exceptions thrown.
93    */    */
94      ESCRIPT_DLL_API
95    AbstractDomain();    AbstractDomain();
96    
97    /**    /**
98       \brief       \brief
99       Destructor for AbstractDomain       Destructor for AbstractDomain.
100    
101       Description:       Description:
102       Destructor for AbstractDomain       Destructor for AbstractDomain.
103    */    */
104      ESCRIPT_DLL_API
105    virtual ~AbstractDomain();    virtual ~AbstractDomain();
106    
107      /**
108         \brief
109         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         \brief
123         If compiled for MPI then execute an MPI_Barrier, else do nothing
124      */
125    
126      ESCRIPT_DLL_API
127      virtual void MPIBarrier() const;
128      /**
129         \brief
130         Return true if on MPI master, else false
131      */
132    
133      ESCRIPT_DLL_API
134      virtual bool onMasterProcessor() const;
135    
136    
137    
138    /**    /**
139       \brief       \brief
140       Returns true if the given integer is a valid function space type       Returns true if the given integer is a valid function space type
141       for this domain.       for this domain.
142    */    */
143      ESCRIPT_DLL_API
144    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
145    
146    /**    /**
147       \brief       \brief
148       Return a description for this domain       Return a description for this domain.
149    */    */
150      ESCRIPT_DLL_API
151    virtual std::string getDescription() const;    virtual std::string getDescription() const;
152    
153    /**    /**
154       \brief       \brief
155       Return a description for the given function space type code       Return a description for the given function space type code.
156    */    */
157      ESCRIPT_DLL_API
158    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
159    
160    /**    /**
161       \brief       \brief
162       Throw a standard exception. This function is called if any attempt        Returns the spatial dimension of the domain.
163       is made to use a base class function.  
164    */        This has to be implemented by the actual Domain adapter.
   void throwStandardException(const std::string& functionName) const;  
   /**  
      \brief  
       returns the spatial dimension of the domain.  
       has to be implemented by the actual Domain adapter.  
165    */    */
166      ESCRIPT_DLL_API
167    virtual int getDim() const;    virtual int getDim() const;
168    
169    /**    /**
170     \brief       \brief
171     Return true if domains equal.       Return true if given domains are equal.
172    */    */
173    bool operator==(const AbstractDomain& other) const;    ESCRIPT_DLL_API
174    bool operator!=(const AbstractDomain& other) const;    virtual bool operator==(const AbstractDomain& other) const;
175      ESCRIPT_DLL_API
176      virtual bool operator!=(const AbstractDomain& other) const;
177    
178    /**    /**
179       \brief       \brief
180       writes the doamin to an external file filename.       Writes the domain to an external file filename.
181       has to be implemented by the actual Domain adapter.  
182         This has to be implemented by the actual Domain adapter.
183    */    */
184      ESCRIPT_DLL_API
185    virtual void write(const std::string& filename) const;    virtual void write(const std::string& filename) const;
186    
187    /**    /**
188       \brief       \brief
189       sets the tagList pointer and length of tag list numTags.       dumps the domain to an external file filename.
190       *tagList may be null in which case on tags are used for functionSpaceType on the Domain.  
191       has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
192    */    */
193    virtual void getTagList(int functionSpaceType, int** tagList, int* numTags) const;    ESCRIPT_DLL_API
194      virtual void dump(const std::string& filename) const;
195    
196   /**    /**
197       \brief       \brief
198       Return the number of data points per sample, and the number of samples as a pair.       Return the number of data points per sample, and the number of samples as a pair.
199       has to be implemented by the actual Domain adapter.  
200         This has to be implemented by the actual Domain adapter.
201    
202       \param functionSpaceCode Input - Code for the function space type.       \param functionSpaceCode Input - Code for the function space type.
203       \return pair, first - number of data points per sample, second - number of samples       \return pair, first - number of data points per sample, second - number of samples
204    */    */
205      ESCRIPT_DLL_API
206    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
207    
208    /**    /**
# Line 126  class AbstractDomain { Line 211  class AbstractDomain {
211       \param functionSpaceType Input - The function space type.       \param functionSpaceType Input - The function space type.
212       \param sampleNo Input - The sample number.       \param sampleNo Input - The sample number.
213    */    */
214      ESCRIPT_DLL_API
215    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
216    
217      /**
218         \brief
219         sets a map from a clear tag name to a tag key
220         \param name Input - tag name.
221         \param tag Input - tag key.
222      */
223      ESCRIPT_DLL_API
224      virtual void setTagMap(const std::string& name,  int tag);
225    
226    /**    /**
227       \brief       \brief
228       assigns new location to the domain       Return the tag key for tag name.
229       has to be implemented by the actual Domain adapter.       \param name Input - tag name
230    */    */
231      ESCRIPT_DLL_API
232      virtual int getTag(const std::string& name) const;
233    
234      /**
235         \brief
236         Returns True if name is a defined tag name
237         \param name Input - tag name
238      */
239      ESCRIPT_DLL_API
240      virtual bool isValidTagName(const std::string& name) const;
241    
242      /**
243         \brief
244         Returns all tag names in a single string sperated by commas
245      */
246      ESCRIPT_DLL_API
247      virtual std::string showTagNames() const;
248    
249      /**
250         \brief
251         Return a borrowed pointer to the sample reference number id list
252         \param functionSpaceType Input - The function space type.
253      */
254      ESCRIPT_DLL_API
255      virtual int* borrowSampleReferenceIDs(int functionSpaceType) const;
256    
257      /**
258         \brief
259         Assigns new location to the domain.
260    
261         This has to be implemented by the actual Domain adapter.
262      */
263      ESCRIPT_DLL_API
264    virtual void setNewX(const escript::Data& arg);    virtual void setNewX(const escript::Data& arg);
265    
266    /**    /**
267       \brief       \brief
268       interpolates data given on source onto target where source and target have to be given on the same domain.       Interpolates data given on source onto target where source and target have to be given on the same domain.
269       has to be implemented by the actual Domain adapter.  
270         This has to be implemented by the actual Domain adapter.
271    */    */
272      ESCRIPT_DLL_API
273    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
274      ESCRIPT_DLL_API
275    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
276    
277    /**    /**
278       \brief       \brief
279       interpolates data given on source onto target where source and target are given on different domains.       Interpolates data given on source onto target where source and target are given on different domains.
280       has to be implemented by the actual Domain adapter.  
281         This has to be implemented by the actual Domain adapter.
282    */    */
283      ESCRIPT_DLL_API
284    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
285      ESCRIPT_DLL_API
286    virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;    virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
287    
288    /**    /**
289       \brief returns locations in the domain. The function space is chosen appropriatly.       \brief
290         Returns locations in the domain. The function space is chosen appropriately.
291    */    */
292      ESCRIPT_DLL_API
293    virtual escript::Data getX() const;    virtual escript::Data getX() const;
294    
295    /**    /**
296       \brief return boundary normals. The function space is chosen appropriatly.       \brief
297         Return boundary normals. The function space is chosen appropriately.
298    */    */
299      ESCRIPT_DLL_API
300    virtual escript::Data getNormal() const;    virtual escript::Data getNormal() const;
301    
302    /**    /**
303       \brief returns the local size od samples. The function space is chosen appropriatly.       \brief
304         Returns the local size of samples. The function space is chosen appropriately.
305    */    */
306      ESCRIPT_DLL_API
307    virtual escript::Data getSize() const;    virtual escript::Data getSize() const;
308        
309    /**    /**
310       \brief       \brief
311       copies the location of data points on the domain into out. The actual function space to be considered       Copies the location of data points on the domain into out.
312         The actual function space to be considered
313       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
314       has to be implemented by the actual Domain adapter.  
315         This has to be implemented by the actual Domain adapter.
316    */    */
317      ESCRIPT_DLL_API
318    virtual void setToX(escript::Data& out) const;    virtual void setToX(escript::Data& out) const;
319    
320    /**    /**
321       \brief       \brief
322       copies the surface normals at data points into out.  The actual function space to be considered       Copies the surface normals at data points into out.
323         The actual function space to be considered
324       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
325       has to be implemented by the actual Domain adapter.  
326         This has to be implemented by the actual Domain adapter.
327    */    */
328      ESCRIPT_DLL_API
329    virtual void setToNormal(escript::Data& out) const;    virtual void setToNormal(escript::Data& out) const;
330    
331    /**    /**
332       \brief       \brief
333       copies the size of samples into out. The actual function space to be considered       Copies the size of samples into out. The actual
334         function space to be considered
335       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
336       has to be implemented by the actual Domain adapter.  
337         This has to be implemented by the actual Domain adapter.
338    */    */
339      ESCRIPT_DLL_API
340    virtual void setToSize(escript::Data& out) const;    virtual void setToSize(escript::Data& out) const;
341    
342    /**    /**
343       \brief       \brief
344       copies the gradient of arg into grad. The actual function space to be considered       Copies the gradient of arg into grad. The actual function space to be considered
345       for the gradient is defined by grad. arg and grad have to be defined on this.       for the gradient is defined by grad. arg and grad have to be defined on this.
346       has to be implemented by the actual Domain adapter.  
347         This has to be implemented by the actual Domain adapter.
348    */    */
349      ESCRIPT_DLL_API
350    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
351      /**
352         \brief
353         Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
354    
355         This has to be implemented by the actual Domain adapter.
356      */
357      ESCRIPT_DLL_API
358      virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
359    
360    /**    /**
361       \brief       \brief
362       saves data arg to a OpenDX input file.       Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
363       considered as cell centered data.  
364       has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
365    */    */
366    virtual void saveDX(const std::string& filename,const escript::Data& arg) const;    ESCRIPT_DLL_API
367      virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
368    
369    /**    /**
370       \brief       \brief
371       returns the function space representation of the type functionSpaceCode on this domain       returns the function space representation of the type functionSpaceCode on this domain
372       as a vtkObject.       as a vtkObject.
373       has to be implemented by the actual Domain adapter.  
374         This has to be implemented by the actual Domain adapter.
375    */    */
376    //virtual vtkObject createVtkObject(int functionSpaceCode) const;    //virtual vtkObject createVtkObject(int functionSpaceCode) const;
377    
378      /**    /**
379         \brief assigns new tag newTag to all samples of functionspace with a positive
380         value of mask for any its sample point.
381    
382      */
383      ESCRIPT_DLL_API
384      virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
385    
386      /**
387       \brief       \brief
388       returns true if data on this domain and a function space of type functionSpaceCode has to       returns true if data on this domain and a function space of type functionSpaceCode has to
389       considered as cell centered data.       considered as cell centered data.
390       has to be implemented by the actual Domain adapter.  
391         This has to be implemented by the actual Domain adapter.
392    */    */
393      ESCRIPT_DLL_API
394    virtual bool isCellOriented(int functionSpaceCode) const;    virtual bool isCellOriented(int functionSpaceCode) const;
395    
396      /**
397         \brief
398         returns status of the domain.
399    
400         This has to be implemented by the actual Domain adapter.
401      */
402      ESCRIPT_DLL_API
403      virtual StatusType getStatus() const;
404    
405      /**
406         \brief
407         Throw a standard exception. This function is called if any attempt
408         is made to use a base class function.
409      */
410      ESCRIPT_DLL_API
411      void throwStandardException(const std::string& functionName) const;
412    
413      /**
414            \brief
415                      return the number of tags in use and a pointer to an array with the number of tags in use
416      */
417      ESCRIPT_DLL_API
418      virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
419    
420      ESCRIPT_DLL_API
421      virtual int* borrowListOfTagsInUse(int functionSpaceCode) const;
422    
423      /**
424        \brief Checks if this domain allows tags for the specified functionSpaceCode.
425      */
426      ESCRIPT_DLL_API
427      virtual bool canTag(int functionspacecode) const;
428    
429   protected:   protected:
430    
431   private:   private:
432    
433       // buffer for coordinates used by function spaces
434       BufferMapType m_x_buffer;
435    
436       // buffer for normal vectors used by function spaces
437       BufferMapType m_normal_buffer;
438    
439       // buffer for normal element size used by function spaces
440       BufferMapType m_size_buffer;
441    
442  };  };
443    
444  } // end of namespace  } // end of namespace
445    
446  #endif  #endif

Legend:
Removed from v.104  
changed lines
  Added in v.1877

  ViewVC Help
Powered by ViewVC 1.1.26