00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2009 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 00119 00125 ESCRIPT_DLL_API 00126 void setTags(const int newTag, const escript::Data& mask) const; 00127 00128 00133 ESCRIPT_DLL_API 00134 std::pair<int,int> 00135 getDataShape() const; 00136 00143 ESCRIPT_DLL_API 00144 bool 00145 operator==(const FunctionSpace& other) const; 00146 00147 ESCRIPT_DLL_API 00148 bool 00149 operator!=(const FunctionSpace& other) const; 00150 00155 ESCRIPT_DLL_API 00156 std::string 00157 toString() const; 00158 00159 //#define DEBUG_PY_STRINGS 00160 00161 #ifdef DEBUG_PY_STRINGS 00162 00170 ESCRIPT_DLL_API 00171 PyObject * 00172 toPyString() const; 00173 #endif 00174 00179 ESCRIPT_DLL_API 00180 int 00181 getTagFromSampleNo(int sampleNo) const; 00182 00187 ESCRIPT_DLL_API 00188 int 00189 getTagFromDataPointNo(int dataPointNo) const; 00190 00195 ESCRIPT_DLL_API 00196 int getReferenceIDFromDataPointNo(int dataPointNo) const; 00197 00204 ESCRIPT_DLL_API 00205 inline 00206 int 00207 getReferenceIDOfSample(int sampleNo) const 00208 { 00209 return borrowSampleReferenceIDs()[sampleNo]; 00210 } 00215 ESCRIPT_DLL_API 00216 const int* 00217 borrowSampleReferenceIDs() const; 00218 00223 ESCRIPT_DLL_API 00224 escript::Data 00225 getX() const; 00226 00231 ESCRIPT_DLL_API 00232 escript::Data 00233 getNormal() const; 00234 00239 ESCRIPT_DLL_API 00240 escript::Data 00241 getSize() const; 00242 00247 ESCRIPT_DLL_API 00248 inline 00249 int 00250 getNumSamples() const { 00251 return getDataShape().second; 00252 } 00253 00258 ESCRIPT_DLL_API 00259 inline 00260 int 00261 getNumDPPSample() const { 00262 return getNumDataPointsPerSample(); 00263 } 00264 00265 ESCRIPT_DLL_API 00266 inline 00267 int 00268 getNumDataPointsPerSample() const { 00269 return getDataShape().first; 00270 } 00271 00276 ESCRIPT_DLL_API 00277 inline 00278 int 00279 getDim() const { 00280 return getDomain()->getDim(); 00281 } 00286 ESCRIPT_DLL_API 00287 boost::python::list 00288 getListOfTags() const; 00293 ESCRIPT_DLL_API 00294 std::list<int> 00295 getListOfTagsSTL() const; 00296 00301 ESCRIPT_DLL_API 00302 int getNumberOfTagsInUse() const; 00303 00304 ESCRIPT_DLL_API 00305 const int* borrowListOfTagsInUse() const; 00306 00307 ESCRIPT_DLL_API 00308 bool 00309 probeInterpolation(const FunctionSpace& other) const 00310 { 00311 if (*this==other) { 00312 return true; 00313 } else { 00314 const_Domain_ptr domain=getDomain(); 00315 if (*domain==*other.getDomain()) { 00316 return domain->probeInterpolationOnDomain(getTypeCode(),other.getTypeCode()); 00317 } else { 00318 return domain->probeInterpolationACross(getTypeCode(),*(other.getDomain()),other.getTypeCode()); 00319 } 00320 } 00321 } 00322 00323 00324 protected: 00325 00326 private: 00332 ESCRIPT_DLL_API 00333 FunctionSpace& 00334 operator=(const FunctionSpace& other); 00335 00336 // 00337 // function space domain 00338 00339 // const AbstractDomain* m_domain; 00340 const_Domain_ptr m_domain; 00341 00342 00343 // 00344 // function space type code. 00345 int m_functionSpaceType; 00346 00347 }; 00348 00349 } // end of namespace 00350 00351 #endif