escript  Revision_
FunctionSpace.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2018 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 #ifndef __ESCRIPT_FUNCTIONSPACE_H__
19 #define __ESCRIPT_FUNCTIONSPACE_H__
20 
21 #include "system_dep.h"
22 
23 #include "AbstractDomain.h"
24 
25 #include <boost/python/list.hpp>
26 #include <list>
27 
28 namespace escript {
29 
30 //
31 // Forward declaration for class Data.
32 class Data;
33 
34 class ESCRIPT_DLL_API FunctionSpace
35 {
36 public:
37  FunctionSpace();
38 
39  FunctionSpace(const_Domain_ptr domain, int functionSpaceType);
40 
41  FunctionSpace(const FunctionSpace& other);
42 
48  int getTypeCode() const;
49 
53  const_Domain_ptr getDomain() const;
54 
60  Domain_ptr getDomainPython() const;
61 
65  bool canTag() const;
66 
70  int getApproximationOrder() const;
71 
76  void setTags(const int newTag, const escript::Data& mask) const;
77 
78  void setTagsByString(const std::string& name, const escript::Data& mask) const;
79 
84  std::pair<int,DataTypes::dim_t> getDataShape() const;
85 
90  bool operator==(const FunctionSpace& other) const;
91 
92  bool operator!=(const FunctionSpace& other) const;
93 
97  std::string toString() const;
98 
102  int getTagFromSampleNo(DataTypes::dim_t sampleNo) const;
103 
107  int getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const;
108 
113  DataTypes::dim_t getReferenceIDFromDataPointNo(DataTypes::dim_t dataPointNo) const;
114 
121  inline
122  DataTypes::dim_t getReferenceIDOfSample(DataTypes::dim_t sampleNo) const {
123  return borrowSampleReferenceIDs()[sampleNo];
124  }
125 
130  inline
131  bool ownSample(DataTypes::dim_t sampleNo) const {
132  return m_domain->ownSample(m_functionSpaceType, sampleNo);
133  }
134 
138  const DataTypes::dim_t* borrowSampleReferenceIDs() const;
139 
143  escript::Data getX() const;
144 
148  escript::Data getNormal() const;
149 
154  escript::Data getSize() const;
155 
159  inline
160  DataTypes::dim_t getNumSamples() const { return getDataShape().second; }
161 
165  inline
166  int getNumDPPSample() const { return getNumDataPointsPerSample(); }
167 
168  inline
169  int getNumDataPointsPerSample() const { return getDataShape().first; }
170 
174  inline
175  int getDim() const { return getDomain()->getDim(); }
176 
180  boost::python::list getListOfTags() const;
181 
185  std::list<int> getListOfTagsSTL() const;
186 
190  int getNumberOfTagsInUse() const;
191 
192  const int* borrowListOfTagsInUse() const;
193 
194  inline
195  bool probeInterpolation(const FunctionSpace& other) const
196  {
197  if (*this == other)
198  return true;
199  const_Domain_ptr domain(getDomain());
200  if (*domain == *other.getDomain()) {
201  return domain->probeInterpolationOnDomain(
202  getTypeCode(), other.getTypeCode());
203  }
204  return domain->probeInterpolationAcross(
205  getTypeCode(), *(other.getDomain()), other.getTypeCode());
206  }
207 
208 private:
214  FunctionSpace& operator=(const FunctionSpace& other);
215 
216  const_Domain_ptr m_domain;
217 
218  int m_functionSpaceType;
219 };
220 
221 bool canInterpolate(FunctionSpace src, FunctionSpace dest);
222 
223 } // end of namespace
224 
225 #endif // __ESCRIPT_FUNCTIONSPACE_H__
226 
escript::FunctionSpace::getReferenceIDFromDataPointNo
DataTypes::dim_t getReferenceIDFromDataPointNo(DataTypes::dim_t dataPointNo) const
Returns the reference number associated with the given data-point number.
Definition: FunctionSpace.cpp:177
DataFactory.h
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:28
escript::FunctionSpace::getTagFromSampleNo
int getTagFromSampleNo(DataTypes::dim_t sampleNo) const
Returns the tag associated with the given sample number.
Definition: FunctionSpace.cpp:142
escript::FunctionSpace::getSize
escript::Data getSize() const
Returns the sample size (e.g. the diameter of elements, radius of particles).
Definition: FunctionSpace.cpp:245
escript::FunctionSpace::getDomainPython
Domain_ptr getDomainPython() const
Return the function space domain. Internal use only! This gets around some python difficulties by cas...
Definition: FunctionSpace.cpp:107
escript::FunctionSpace::m_functionSpaceType
int m_functionSpaceType
Definition: FunctionSpace.h:229
escript::NullDomain
NullDomain provides a null value for domain. Needed for the construction of a default FunctionSpace.
Definition: NullDomain.h:50
escript::FunctionSpace::getDataShape
std::pair< int, DataTypes::dim_t > getDataShape() const
Returns the shape of the data needed to represent the function space.
Definition: FunctionSpace.cpp:87
escript::FunctionSpace::getNumSamples
DataTypes::dim_t getNumSamples() const
Returns the number of samples.
Definition: FunctionSpace.h:171
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:47
escript::FunctionSpace::operator=
FunctionSpace & operator=(const FunctionSpace &other)
Assignment operator. This method is only defined (private) to prevent people from using it.
Definition: FunctionSpace.cpp:205
escript::FunctionSpace
Definition: FunctionSpace.h:45
escript::FunctionSpace::getListOfTagsSTL
std::list< int > getListOfTagsSTL() const
Returns an stl list of the tags used in this function space.
Definition: FunctionSpace.cpp:285
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:461
escript::FunctionSpace::canTag
bool canTag() const
Returns true if this function space support tags.
Definition: FunctionSpace.cpp:303
escript::FunctionSpace::getDomain
const_Domain_ptr getDomain() const
Returns the function space domain.
Definition: FunctionSpace.cpp:101
system_dep.h
escript::FunctionSpace::getNormal
escript::Data getNormal() const
Returns the surface normal field.
Definition: FunctionSpace.cpp:236
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:62
escript::DataException
Definition: DataException.h:37
escript::FunctionSpace::m_domain
const_Domain_ptr m_domain
Definition: FunctionSpace.h:227
escript::FunctionSpace::getX
escript::Data getX() const
Returns the spatial locations of the data points.
Definition: FunctionSpace.cpp:227
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:87
escript::FunctionSpace::setTags
void setTags(const int newTag, const escript::Data &mask) const
Assigns new tag newTag to all samples with a positive value of mask for any of its sample points.
Definition: FunctionSpace.cpp:254
escript::FunctionSpace::getNumDPPSample
int getNumDPPSample() const
Returns the number of data points per sample.
Definition: FunctionSpace.h:177
escript::FunctionSpace::getApproximationOrder
int getApproximationOrder() const
Returns the approximation order used for this function space.
Definition: FunctionSpace.cpp:309
AbstractDomain.h
escript::FunctionSpace::getListOfTags
boost::python::list getListOfTags() const
Returns a list of the tags used in this function space.
Definition: FunctionSpace.cpp:293
escript::FunctionSpaceException
Definition: FunctionSpaceException.h:38
escript::FunctionSpace::borrowListOfTagsInUse
const int * borrowListOfTagsInUse() const
Definition: FunctionSpace.cpp:280
escript::canInterpolate
bool canInterpolate(FunctionSpace src, FunctionSpace dest)
Definition: FunctionSpace.cpp:32
FunctionSpaceException.h
escript
Definition: AbstractContinuousDomain.cpp:22
escript::FunctionSpace::setTagsByString
void setTagsByString(const std::string &name, const escript::Data &mask) const
Definition: FunctionSpace.cpp:264
NullDomain.h
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:93
escript::FunctionSpace::toString
std::string toString() const
Returns a text description of the function space.
Definition: FunctionSpace.cpp:116
escript::Vector
Data Vector(double value, const FunctionSpace &what, bool expanded)
Return a Data object containing vector data-points. ie: rank 1 data-points.
Definition: DataFactory.cpp:96
escript::FunctionSpace::borrowSampleReferenceIDs
const DataTypes::dim_t * borrowSampleReferenceIDs() const
Returns a borrowed reference to the list of sample reference IDs.
Definition: FunctionSpace.cpp:197
Data.h
escript::FunctionSpace::operator!=
bool operator!=(const FunctionSpace &other) const
Definition: FunctionSpace.cpp:221
escript::Scalar
Data Scalar(double value, const FunctionSpace &what, bool expanded)
A collection of factory functions for creating Data objects which contain data points of various shap...
Definition: DataFactory.cpp:60
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:50
escript::FunctionSpace::FunctionSpace
FunctionSpace()
Definition: FunctionSpace.cpp:45
escript::Data::setProtection
void setProtection()
switches on update protection
Definition: Data.cpp:1169
escript::FunctionSpace::operator==
bool operator==(const FunctionSpace &other) const
Comparison operator. Returns true if function spaces are equal. (i.e. same domain and same function s...
Definition: FunctionSpace.cpp:215
escript::FunctionSpace::getNumberOfTagsInUse
int getNumberOfTagsInUse() const
Returns the number of tags in use.
Definition: FunctionSpace.cpp:275
escript::FunctionSpace::getTagFromDataPointNo
int getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const
Returns the tag associated with the given data-point number.
Definition: FunctionSpace.cpp:148
FunctionSpace.h