/[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

revision 615 by elspeth, Wed Mar 22 02:12:00 2006 UTC revision 2881 by jfenwick, Thu Jan 28 02:03:15 2010 UTC
# Line 1  Line 1 
 // $Id$  
 /*  
  ************************************************************  
  *          Copyright 2006 by ACcESS MNRF                   *  
  *                                                          *  
  *              http://www.access.edu.au                    *  
  *       Primary Business: Queensland, Australia            *  
  *  Licensed under the Open Software License version 3.0    *  
  *     http://www.opensource.org/licenses/osl-3.0.php       *  
  *                                                          *  
  ************************************************************  
1    
2  */  /*******************************************************
3    *
4    * Copyright (c) 2003-2010 by University of Queensland
5    * 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    
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 <vector>
21  #include <string>  #include <string>
22    #include <map>
23  #include <boost/python/dict.hpp>  #include <boost/python/dict.hpp>
24    #include <boost/python/list.hpp>
25    #include "paso/Paso_MPI.h"
26    
 namespace escript {  
27    
28  //  #include "Pointers.h"
 // forward declarations  
 class Data;  
 //class AbstractSystemMatrix;  
 //class FunctionSpace;  
29    
30    namespace escript {
31    // class forward declarations
32    class Data;
33  /**  /**
34     \brief     \brief
35     Base class for all escript domains.     Base class for all escript domains.
# Line 34  class Data; Line 38  class Data;
38     Base class for all escript domains.     Base class for all escript domains.
39  */  */
40    
41  class AbstractDomain {  class AbstractDomain;
42    
43    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   public:   public:
49    
50    /**
51    \brief Returns smart pointer which is managing this object.
52    If one does not exist yet it creates one.
53    
54    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       // structure holding values for X, size and normal
62       typedef int StatusType;
63       struct ValueBuffer
64       {
65           StatusType m_status;
66           boost::shared_ptr<Data> m_data;
67       };
68       typedef struct ValueBuffer ValueBuffer;
69    
70       //
71       // map from function space type code to value buffer
72       typedef std::map<int, ValueBuffer> BufferMapType;
73    
74    
75    /**    /**
76       \brief       \brief
77       Default constructor for AbstractDomain.       Default constructor for AbstractDomain.
# Line 58  class AbstractDomain { Line 92  class AbstractDomain {
92       Throws:       Throws:
93       Describe any exceptions thrown.       Describe any exceptions thrown.
94    */    */
95      ESCRIPT_DLL_API
96    AbstractDomain();    AbstractDomain();
97    
98    /**    /**
# Line 67  class AbstractDomain { Line 102  class AbstractDomain {
102       Description:       Description:
103       Destructor for AbstractDomain.       Destructor for AbstractDomain.
104    */    */
105      ESCRIPT_DLL_API
106    virtual ~AbstractDomain();    virtual ~AbstractDomain();
107    
108    /**    /**
109       \brief       \brief
110         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      /**
123         \brief
124         If compiled for MPI then execute an MPI_Barrier, else do nothing
125      */
126    
127      ESCRIPT_DLL_API
128      virtual void MPIBarrier() const;
129      /**
130         \brief
131         Return true if on MPI master, else false
132      */
133    
134      ESCRIPT_DLL_API
135      virtual bool onMasterProcessor() const;
136    
137      /**
138      \brief get the communicator for this domain.
139      Returns 0 on non-MPI builds
140      Routine must be implemented by the DomainAdapter
141      */
142      ESCRIPT_DLL_API
143      virtual
144    #ifdef PASO_MPI
145      MPI_Comm
146    #else
147      unsigned int
148    #endif
149      getMPIComm() const;
150    
151      /**
152         \brief
153       Returns true if the given integer is a valid function space type       Returns true if the given integer is a valid function space type
154       for this domain.       for this domain.
155    */    */
156      ESCRIPT_DLL_API
157    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
158    
159    /**    /**
160       \brief       \brief
161       Return a description for this domain.       Return a description for this domain.
162    */    */
163      ESCRIPT_DLL_API
164    virtual std::string getDescription() const;    virtual std::string getDescription() const;
165    
166    /**    /**
167       \brief       \brief
168       Return a description for the given function space type code.       Return a description for the given function space type code.
169    */    */
170      ESCRIPT_DLL_API
171    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
172    
173    /**    /**
# Line 94  class AbstractDomain { Line 176  class AbstractDomain {
176    
177        This has to be implemented by the actual Domain adapter.        This has to be implemented by the actual Domain adapter.
178    */    */
179      ESCRIPT_DLL_API
180    virtual int getDim() const;    virtual int getDim() const;
181    
182    /**    /**
183       \brief       \brief
184       Return true if given domains are equal.       Return true if given domains are equal.
185    */    */
186      ESCRIPT_DLL_API
187    virtual bool operator==(const AbstractDomain& other) const;    virtual bool operator==(const AbstractDomain& other) const;
188      ESCRIPT_DLL_API
189    virtual bool operator!=(const AbstractDomain& other) const;    virtual bool operator!=(const AbstractDomain& other) const;
190    
191    /**    /**
# Line 109  class AbstractDomain { Line 194  class AbstractDomain {
194    
195       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
196    */    */
197      ESCRIPT_DLL_API
198    virtual void write(const std::string& filename) const;    virtual void write(const std::string& filename) const;
199    
200    /**    /**
201       \brief       \brief
202         dumps the domain to an external file filename.
203    
204         This has to be implemented by the actual Domain adapter.
205      */
206      ESCRIPT_DLL_API
207      virtual void dump(const std::string& filename) const;
208    
209      /**
210         \brief
211       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.
212    
213       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
# Line 120  class AbstractDomain { Line 215  class AbstractDomain {
215       \param functionSpaceCode Input - Code for the function space type.       \param functionSpaceCode Input - Code for the function space type.
216       \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
217    */    */
218      ESCRIPT_DLL_API
219    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
220    
221    /**    /**
# Line 128  class AbstractDomain { Line 224  class AbstractDomain {
224       \param functionSpaceType Input - The function space type.       \param functionSpaceType Input - The function space type.
225       \param sampleNo Input - The sample number.       \param sampleNo Input - The sample number.
226    */    */
227      ESCRIPT_DLL_API
228    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;    virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
229    
230    /**    /**
231       \brief       \brief
232       Return the reference number of the given sample number.       sets a map from a clear tag name to a tag key
233         \param name Input - tag name.
234         \param tag Input - tag key.
235      */
236      ESCRIPT_DLL_API
237      virtual void setTagMap(const std::string& name,  int tag);
238    
239      /**
240         \brief
241         Return the tag key for tag name.
242         \param name Input - tag name
243      */
244      ESCRIPT_DLL_API
245      virtual int getTag(const std::string& name) const;
246    
247      /**
248         \brief
249         Returns True if name is a defined tag name
250         \param name Input - tag name
251      */
252      ESCRIPT_DLL_API
253      virtual bool isValidTagName(const std::string& name) const;
254    
255      /**
256         \brief
257         Returns all tag names in a single string sperated by commas
258      */
259      ESCRIPT_DLL_API
260      virtual std::string showTagNames() const;
261    
262      /**
263         \brief
264         Return a borrowed pointer to the sample reference number id list
265       \param functionSpaceType Input - The function space type.       \param functionSpaceType Input - The function space type.
      \param sampleNo Input - The sample number.  
266    */    */
267    virtual int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const;    ESCRIPT_DLL_API
268      virtual const int* borrowSampleReferenceIDs(int functionSpaceType) const;
269    
270    /**    /**
271       \brief       \brief
# Line 144  class AbstractDomain { Line 273  class AbstractDomain {
273    
274       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
275    */    */
276      ESCRIPT_DLL_API
277    virtual void setNewX(const escript::Data& arg);    virtual void setNewX(const escript::Data& arg);
278    
279    /**    /**
# Line 152  class AbstractDomain { Line 282  class AbstractDomain {
282    
283       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
284    */    */
285      ESCRIPT_DLL_API
286    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
287      ESCRIPT_DLL_API
288    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
289    
290    /**    /**
291        \brief given a vector of FunctionSpace type codes, pass back a code which then can all be interpolated to.
292        \note This method must be called on the domain which the FunctionSpaces point to
293        \return true is result is valid, false if not
294      */
295      ESCRIPT_DLL_API
296      virtual
297      bool
298      commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
299    
300      /**
301       \brief       \brief
302       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.
303    
304       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
305    */    */
306      ESCRIPT_DLL_API
307    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
308      ESCRIPT_DLL_API
309    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;
310    
311    /**    /**
312       \brief       \brief
313       Returns locations in the domain. The function space is chosen appropriately.       Returns locations in the domain. The function space is chosen appropriately.
314    */    */
315      ESCRIPT_DLL_API
316    virtual escript::Data getX() const;    virtual escript::Data getX() const;
317    
318    /**    /**
319       \brief       \brief
320       Return boundary normals. The function space is chosen appropriately.       Return boundary normals. The function space is chosen appropriately.
321    */    */
322      ESCRIPT_DLL_API
323    virtual escript::Data getNormal() const;    virtual escript::Data getNormal() const;
324    
325    /**    /**
326       \brief       \brief
327       Returns the local size of samples. The function space is chosen appropriately.       Returns the local size of samples. The function space is chosen appropriately.
328    */    */
329      ESCRIPT_DLL_API
330    virtual escript::Data getSize() const;    virtual escript::Data getSize() const;
331        
332    /**    /**
# Line 190  class AbstractDomain { Line 337  class AbstractDomain {
337    
338       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
339    */    */
340      ESCRIPT_DLL_API
341    virtual void setToX(escript::Data& out) const;    virtual void setToX(escript::Data& out) const;
342    
343    /**    /**
# Line 200  class AbstractDomain { Line 348  class AbstractDomain {
348    
349       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
350    */    */
351      ESCRIPT_DLL_API
352    virtual void setToNormal(escript::Data& out) const;    virtual void setToNormal(escript::Data& out) const;
353    
354    /**    /**
# Line 210  class AbstractDomain { Line 359  class AbstractDomain {
359    
360       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
361    */    */
362      ESCRIPT_DLL_API
363    virtual void setToSize(escript::Data& out) const;    virtual void setToSize(escript::Data& out) const;
364    
365    /**    /**
# Line 219  class AbstractDomain { Line 369  class AbstractDomain {
369    
370       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
371    */    */
372      ESCRIPT_DLL_API
373    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;    virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const;
374    /**    /**
375       \brief       \brief
# Line 226  class AbstractDomain { Line 377  class AbstractDomain {
377    
378       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
379    */    */
380      ESCRIPT_DLL_API
381    virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;    virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
382    
383    /**    /**
384       \brief       \brief
385       Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier       Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier.
386         metadata is string representing some meta data to be added. metadata_schema assign schema to namespaces used in the meta data.
387    
388       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
389    */    */
390    virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;    ESCRIPT_DLL_API
391      virtual void saveVTK(const std::string& filename,const boost::python::dict& arg, const std::string& metadata, const std::string& metadata_schema) const;
392    
393    /**    /**
394       \brief    \brief True if this rank owns the sample(id)
395       returns the function space representation of the type functionSpaceCode on this domain    Must be implemented by the Domain adapter
396       as a vtkObject.    */
397      ESCRIPT_DLL_API
398      virtual bool ownSample(int fs_code, index_t id) const;
399    
400      /**
401         \brief assigns new tag newTag to all samples of functionspace with a positive
402         value of mask for any its sample point.
403    
      This has to be implemented by the actual Domain adapter.  
404    */    */
405    //virtual vtkObject createVtkObject(int functionSpaceCode) const;    ESCRIPT_DLL_API
406      virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
407    
408    /**    /**
409       \brief       \brief
# Line 252  class AbstractDomain { Line 412  class AbstractDomain {
412    
413       This has to be implemented by the actual Domain adapter.       This has to be implemented by the actual Domain adapter.
414    */    */
415      ESCRIPT_DLL_API
416    virtual bool isCellOriented(int functionSpaceCode) const;    virtual bool isCellOriented(int functionSpaceCode) const;
417    
418    /**    /**
419       \brief       \brief
420          Returns a status indicator of the domain. The status identifier should be unique over
421          the live time if the object but may be updated if changes to the domain happen, e.g.
422          modifications to its geometry.
423    
424         This has to be implemented by the actual Domain adapter.
425      */
426      ESCRIPT_DLL_API
427      virtual StatusType getStatus() const;
428    
429      /**
430         \brief
431       Throw a standard exception. This function is called if any attempt       Throw a standard exception. This function is called if any attempt
432       is made to use a base class function.       is made to use a base class function.
433    */    */
434      ESCRIPT_DLL_API
435    void throwStandardException(const std::string& functionName) const;    void throwStandardException(const std::string& functionName) const;
436    
437      /**
438            \brief
439                      return the number of tags in use and a pointer to an array with the number of tags in use
440      */
441      ESCRIPT_DLL_API
442      virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
443    
444      ESCRIPT_DLL_API
445      virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
446    
447      /**
448        \brief Checks if this domain allows tags for the specified functionSpaceCode.
449      */
450      ESCRIPT_DLL_API
451      virtual bool canTag(int functionspacecode) const;
452    
453       /**
454       \brief returns the approximation order used for a function space functionSpaceCode
455       */
456    
457       ESCRIPT_DLL_API
458       virtual int getApproximationOrder(const int functionSpaceCode) const;
459    
460    
461   protected:   protected:
462    
463   private:   private:
464    
465       // buffer for coordinates used by function spaces
466       BufferMapType m_x_buffer;
467    
468       // buffer for normal vectors used by function spaces
469       BufferMapType m_normal_buffer;
470    
471       // buffer for normal element size used by function spaces
472       BufferMapType m_size_buffer;
473    
474  };  };
475    
476  } // end of namespace  } // end of namespace

Legend:
Removed from v.615  
changed lines
  Added in v.2881

  ViewVC Help
Powered by ViewVC 1.1.26