ESYS13  Revision_
FunctionSpace.h
Go to the documentation of this file.
00001 
00002 /*******************************************************
00003 *
00004 * Copyright (c) 2003-2012 by University of Queensland
00005 * Earth Systems Science Computational Center (ESSCC)
00006 * http://www.uq.edu.au/esscc
00007 *
00008 * Primary Business: Queensland, Australia
00009 * Licensed under the Open Software License version 3.0
00010 * http://www.opensource.org/licenses/osl-3.0.php
00011 *
00012 *******************************************************/
00013 
00014 
00015 #if !defined escript_FunctionSpace_20040323_H
00016 #define escript_FunctionSpace_20040323_H
00017 #include "system_dep.h"
00018 
00019 #include "AbstractDomain.h"
00020 #include "NullDomain.h"
00021 
00022 #include <string>
00023 #include <list>
00024 
00025 namespace escript {
00026 
00027 //
00028 // Forward declaration for class Data.
00029 class Data;
00030 
00043 class FunctionSpace 
00044 {
00045 public:
00060   ESCRIPT_DLL_API
00061   FunctionSpace();
00062 
00070   ESCRIPT_DLL_API
00071   FunctionSpace(const_Domain_ptr domain,
00072                 int functionSpaceType);
00073 
00074 
00075   ESCRIPT_DLL_API
00076   FunctionSpace(const FunctionSpace& other);
00077 
00084   ESCRIPT_DLL_API
00085   int
00086   getTypeCode() const;
00087 
00092   ESCRIPT_DLL_API
00093 //   const
00094 //   AbstractDomain&
00095   const_Domain_ptr
00096   getDomain() const;
00097 
00104   ESCRIPT_DLL_API
00105 //   const
00106 //   AbstractDomain&
00107   Domain_ptr
00108   getDomainPython() const;
00109 
00110 
00111 
00115   ESCRIPT_DLL_API
00116   bool
00117   canTag() const;
00118 
00123     ESCRIPT_DLL_API
00124     int
00125     getApproximationOrder() const;
00126 
00131   ESCRIPT_DLL_API
00132   void setTags(const int newTag, const escript::Data& mask) const;
00133 
00134 
00135   ESCRIPT_DLL_API
00136   void setTagsByString(const std::string& name, const escript::Data& mask) const;
00137   
00138 
00143   ESCRIPT_DLL_API
00144   std::pair<int,int>
00145   getDataShape() const;
00146 
00153   ESCRIPT_DLL_API
00154   bool
00155   operator==(const FunctionSpace& other) const;
00156 
00157   ESCRIPT_DLL_API
00158   bool
00159   operator!=(const FunctionSpace& other) const;
00160 
00165   ESCRIPT_DLL_API
00166   std::string
00167   toString() const;
00168 
00169    //#define DEBUG_PY_STRINGS
00170 
00171 #ifdef DEBUG_PY_STRINGS
00172 
00180   ESCRIPT_DLL_API
00181   PyObject *
00182   toPyString() const;
00183 #endif
00184 
00189   ESCRIPT_DLL_API
00190   int
00191   getTagFromSampleNo(int sampleNo) const;
00192 
00197   ESCRIPT_DLL_API
00198   int
00199   getTagFromDataPointNo(int dataPointNo) const;
00200 
00205   ESCRIPT_DLL_API
00206   int getReferenceIDFromDataPointNo(int dataPointNo) const;
00207 
00214   ESCRIPT_DLL_API
00215   inline
00216   int
00217   getReferenceIDOfSample(int sampleNo) const
00218   {
00219       return borrowSampleReferenceIDs()[sampleNo];
00220   }
00221 
00226   ESCRIPT_DLL_API
00227   inline
00228   bool 
00229   ownSample(int sampleNo) const
00230   {
00231       return m_domain->ownSample(m_functionSpaceType, sampleNo);
00232   }
00233 
00238   ESCRIPT_DLL_API
00239   const int*
00240   borrowSampleReferenceIDs() const;
00241 
00246   ESCRIPT_DLL_API
00247   escript::Data
00248   getX() const;
00249  
00254   ESCRIPT_DLL_API
00255   escript::Data
00256   getNormal() const;
00257 
00262   ESCRIPT_DLL_API
00263   escript::Data
00264   getSize() const;
00265 
00270   ESCRIPT_DLL_API
00271   inline
00272   int
00273   getNumSamples() const {
00274      return getDataShape().second;
00275   }
00276 
00281   ESCRIPT_DLL_API
00282   inline
00283   int
00284   getNumDPPSample() const {
00285      return getNumDataPointsPerSample();
00286   }
00287 
00288   ESCRIPT_DLL_API
00289   inline
00290   int
00291   getNumDataPointsPerSample() const {
00292      return getDataShape().first;
00293   }
00294 
00299   ESCRIPT_DLL_API
00300   inline
00301   int
00302   getDim() const {
00303       return getDomain()->getDim();
00304   }
00309   ESCRIPT_DLL_API
00310   boost::python::list
00311   getListOfTags() const;
00316   ESCRIPT_DLL_API
00317   std::list<int>
00318   getListOfTagsSTL() const;
00319 
00324   ESCRIPT_DLL_API
00325   int getNumberOfTagsInUse() const;
00326 
00327   ESCRIPT_DLL_API
00328   const int* borrowListOfTagsInUse() const;
00329 
00330   ESCRIPT_DLL_API
00331   bool
00332   probeInterpolation(const FunctionSpace& other) const
00333   {
00334     if (*this==other) {
00335       return true;
00336     } else {
00337       const_Domain_ptr domain=getDomain();
00338       if  (*domain==*other.getDomain()) {
00339         return domain->probeInterpolationOnDomain(getTypeCode(),other.getTypeCode());
00340       } else {
00341         return domain->probeInterpolationACross(getTypeCode(),*(other.getDomain()),other.getTypeCode());
00342       }
00343     }
00344   }
00345 
00346 
00347  protected:
00348 
00349  private:
00355   ESCRIPT_DLL_API
00356   FunctionSpace&
00357   operator=(const FunctionSpace& other);
00358 
00359   //
00360   // function space domain
00361   
00362 //   const AbstractDomain*  m_domain;
00363    const_Domain_ptr m_domain;
00364 
00365 
00366   //
00367   // function space type code.
00368   int m_functionSpaceType;
00369 
00370 };
00371 
00372 } // end of namespace
00373 
00374 #endif