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

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

  ViewVC Help
Powered by ViewVC 1.1.26