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

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

  ViewVC Help
Powered by ViewVC 1.1.26