/[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 797 by gross, Thu Aug 3 02:03:18 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
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    
24  namespace escript {  namespace escript {
25    // class forward declarations
26      class Data;  class Data;
     class AbstractSystemMatrix;  
     class FunctionSpace;  
27  /**  /**
28     \brief     \brief
29     Base class for all escript domains.     Base class for all escript domains.
# Line 31  namespace escript { Line 31  namespace escript {
31     Description:     Description:
32     Base class for all escript domains.     Base class for all escript domains.
33  */  */
34    
35  class AbstractDomain {  class AbstractDomain {
36    
37   public:   public:
38    
39    
40       // structure holding values for X, size and normal
41       typedef int StatusType;
42       struct ValueBuffer
43       {
44           StatusType m_status;
45           boost::shared_ptr<Data> m_data;
46       };
47       typedef struct ValueBuffer ValueBuffer;
48    
49       //
50       // map from function space type code to value buffer
51       typedef std::map<int, ValueBuffer> BufferMapType;
52    
53    
54    /**    /**
55       \brief       \brief
56       Default constructor for AbstractDomain       Default constructor for AbstractDomain.
57    
58       Description:       Description:
59       Default constructor for AbstractDomain. As the name suggests       Default constructor for AbstractDomain. As the name suggests
60       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
61       constructable avoid a boost.python wrapper class. A call to       constructable we avoid a boost.python wrapper class. A call to
62       almost any of the base class functions will throw an exception       almost any of the base class functions will throw an exception
63       as they are not intended to be used.       as they are not intended to be used directly, but are overridden
64         by the underlying solver package which escript is linked to.
65    
66         By default, this class is overridden by the class NullDomain.
67    
68       Preconditions:       Preconditions:
69       Describe any preconditions       Describe any preconditions.
70    
71       Throws:       Throws:
72       Describe any exceptions thrown       Describe any exceptions thrown.
73    */    */
74      ESCRIPT_DLL_API
75    AbstractDomain();    AbstractDomain();
76    
77    /**    /**
78       \brief       \brief
79       Destructor for AbstractDomain       Destructor for AbstractDomain.
80    
81       Description:       Description:
82       Destructor for AbstractDomain       Destructor for AbstractDomain.
83    */    */
84      ESCRIPT_DLL_API
85    virtual ~AbstractDomain();    virtual ~AbstractDomain();
86    
87    /**    /**
88       \brief       \brief
89       Returns true if the given integer is a valid function space type       Returns true if the given integer is a valid function space type
90       for this domain.       for this domain.
91    */    */
92      ESCRIPT_DLL_API
93    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
94    
95    /**    /**
96       \brief       \brief
97       Return a description for this domain       Return a description for this domain.
98    */    */
99      ESCRIPT_DLL_API
100    virtual std::string getDescription() const;    virtual std::string getDescription() const;
101    
102    /**    /**
103       \brief       \brief
104       Return a description for the given function space type code       Return a description for the given function space type code.
105    */    */
106      ESCRIPT_DLL_API
107    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
108    
109    /**    /**
110       \brief       \brief
111       Throw a standard exception. This function is called if any attempt        Returns the spatial dimension of the domain.
112       is made to use a base class function.  
113    */        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.  
114    */    */
115      ESCRIPT_DLL_API
116    virtual int getDim() const;    virtual int getDim() const;
117    
118    /**    /**
    \brief  
    Return true if domains equal.  
   */  
   bool operator==(const AbstractDomain& other) const;  
   bool operator!=(const AbstractDomain& other) const;  
   /**  
119       \brief       \brief
120       writes the doamin to an external file filename.       Return true if given domains are equal.
      has to be implemented by the actual Domain adapter.  
121    */    */
122    virtual void write(const std::string& filename) const;    ESCRIPT_DLL_API
123      virtual bool operator==(const AbstractDomain& other) const;
124      ESCRIPT_DLL_API
125      virtual bool operator!=(const AbstractDomain& other) const;
126    
127    /**    /**
128       \brief       \brief
129       sets the tagList pointer and length of tag list numTags.       Writes the domain to an external file filename.
130       *tagList may be null in which case on tags are used for functionSpaceType on the Domain.  
131       has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
132    */    */
133    virtual void getTagList(int functionSpaceType, int** tagList, int* numTags) const;    ESCRIPT_DLL_API
134      virtual void write(const std::string& filename) const;
135    
136   /**    /**
137       \brief       \brief
138       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.
139       has to be implemented by the actual Domain adapter.  
140         This has to be implemented by the actual Domain adapter.
141    
142       \param functionSpaceCode Input - Code for the function space type.       \param functionSpaceCode Input - Code for the function space type.
143       \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
144    */    */
145      ESCRIPT_DLL_API
146    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
147    
148    /**    /**
# Line 126  class AbstractDomain { Line 151  class AbstractDomain {
151       \param functionSpaceType Input - The function space type.       \param functionSpaceType Input - The function space type.
152       \param sampleNo Input - The sample number.       \param sampleNo Input - The sample number.
153    */    */
154      ESCRIPT_DLL_API
155    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
156    
157      /**
158         \brief
159         Return the reference number of the given sample number.
160         \param functionSpaceType Input - The function space type.
161         \param sampleNo Input - The sample number.
162      */
163      ESCRIPT_DLL_API
164      virtual int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const;
165    
166    /**    /**
167       \brief       \brief
168       assigns new location to the domain       Assigns new location to the domain.
169       has to be implemented by the actual Domain adapter.  
170         This has to be implemented by the actual Domain adapter.
171    */    */
172      ESCRIPT_DLL_API
173    virtual void setNewX(const escript::Data& arg);    virtual void setNewX(const escript::Data& arg);
174    
175    /**    /**
176       \brief       \brief
177       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.
178       has to be implemented by the actual Domain adapter.  
179         This has to be implemented by the actual Domain adapter.
180    */    */
181      ESCRIPT_DLL_API
182    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
183      ESCRIPT_DLL_API
184    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
185    
186    /**    /**
187       \brief       \brief
188       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.
189       has to be implemented by the actual Domain adapter.  
190         This has to be implemented by the actual Domain adapter.
191    */    */
192      ESCRIPT_DLL_API
193    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
194      ESCRIPT_DLL_API
195    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;
196    
197    /**    /**
198       \brief returns locations in the domain. The function space is chosen appropriatly.       \brief
199         Returns locations in the domain. The function space is chosen appropriately.
200    */    */
201      ESCRIPT_DLL_API
202    virtual escript::Data getX() const;    virtual escript::Data getX() const;
203    
204    /**    /**
205       \brief return boundary normals. The function space is chosen appropriatly.       \brief
206         Return boundary normals. The function space is chosen appropriately.
207    */    */
208      ESCRIPT_DLL_API
209    virtual escript::Data getNormal() const;    virtual escript::Data getNormal() const;
210    
211    /**    /**
212       \brief returns the local size od samples. The function space is chosen appropriatly.       \brief
213         Returns the local size of samples. The function space is chosen appropriately.
214    */    */
215      ESCRIPT_DLL_API
216    virtual escript::Data getSize() const;    virtual escript::Data getSize() const;
217        
218    /**    /**
219       \brief       \brief
220       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.
221         The actual function space to be considered
222       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
223       has to be implemented by the actual Domain adapter.  
224         This has to be implemented by the actual Domain adapter.
225    */    */
226      ESCRIPT_DLL_API
227    virtual void setToX(escript::Data& out) const;    virtual void setToX(escript::Data& out) const;
228    
229    /**    /**
230       \brief       \brief
231       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.
232         The actual function space to be considered
233       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
234       has to be implemented by the actual Domain adapter.  
235         This has to be implemented by the actual Domain adapter.
236    */    */
237      ESCRIPT_DLL_API
238    virtual void setToNormal(escript::Data& out) const;    virtual void setToNormal(escript::Data& out) const;
239    
240    /**    /**
241       \brief       \brief
242       copies the size of samples into out. The actual function space to be considered       Copies the size of samples into out. The actual
243         function space to be considered
244       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
245       has to be implemented by the actual Domain adapter.  
246         This has to be implemented by the actual Domain adapter.
247    */    */
248      ESCRIPT_DLL_API
249    virtual void setToSize(escript::Data& out) const;    virtual void setToSize(escript::Data& out) const;
250    
251    /**    /**
252       \brief       \brief
253       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
254       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.
255       has to be implemented by the actual Domain adapter.  
256         This has to be implemented by the actual Domain adapter.
257    */    */
258      ESCRIPT_DLL_API
259    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
260      /**
261         \brief
262         Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
263    
264         This has to be implemented by the actual Domain adapter.
265      */
266      ESCRIPT_DLL_API
267      virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
268    
269    /**    /**
270       \brief       \brief
271       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
272       considered as cell centered data.  
273       has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
274    */    */
275    virtual void saveDX(const std::string& filename,const escript::Data& arg) const;    ESCRIPT_DLL_API
276      virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
277    
278    /**    /**
279       \brief       \brief
280       returns the function space representation of the type functionSpaceCode on this domain       returns the function space representation of the type functionSpaceCode on this domain
281       as a vtkObject.       as a vtkObject.
282       has to be implemented by the actual Domain adapter.  
283         This has to be implemented by the actual Domain adapter.
284    */    */
285    //virtual vtkObject createVtkObject(int functionSpaceCode) const;    //virtual vtkObject createVtkObject(int functionSpaceCode) const;
286    
287      /**    /**
288         \brief assigns new tag newTag to all samples of functionspace with a positive
289         value of mask for any its sample point.
290    
291      */
292      ESCRIPT_DLL_API
293      virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
294    
295      /**
296       \brief       \brief
297       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
298       considered as cell centered data.       considered as cell centered data.
299       has to be implemented by the actual Domain adapter.  
300         This has to be implemented by the actual Domain adapter.
301    */    */
302      ESCRIPT_DLL_API
303    virtual bool isCellOriented(int functionSpaceCode) const;    virtual bool isCellOriented(int functionSpaceCode) const;
304    
305      /**
306         \brief
307         returns status of the domain.
308    
309         This has to be implemented by the actual Domain adapter.
310      */
311      ESCRIPT_DLL_API
312      virtual StatusType getStatus() const;
313    
314      /**
315         \brief
316         Throw a standard exception. This function is called if any attempt
317         is made to use a base class function.
318      */
319      ESCRIPT_DLL_API
320      void throwStandardException(const std::string& functionName) const;
321    
322   protected:   protected:
323    
324   private:   private:
325    
326       // buffer for coordinates used by function spaces
327       BufferMapType m_x_buffer;
328    
329       // buffer for normal vectors used by function spaces
330       BufferMapType m_normal_buffer;
331    
332       // buffer for normal element size used by function spaces
333       BufferMapType m_size_buffer;
334    
335  };  };
336    
337  } // end of namespace  } // end of namespace
338    
339  #endif  #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26