escript  Revision_
FunctionSpace.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 
19 #ifndef __ESCRIPT_FUNCTIONSPACE_H__
20 #define __ESCRIPT_FUNCTIONSPACE_H__
21 
22 #include "system_dep.h"
23 
24 #include "AbstractDomain.h"
25 
26 #include <boost/python/list.hpp>
27 #include <list>
28 
29 namespace escript {
30 
31 //
32 // Forward declaration for class Data.
33 class Data;
34 
35 class ESCRIPT_DLL_API FunctionSpace
36 {
37 public:
38  FunctionSpace();
39 
40  FunctionSpace(const_Domain_ptr domain, int functionSpaceType);
41 
42  FunctionSpace(const FunctionSpace& other);
43 
49  int getTypeCode() const;
50 
54  const_Domain_ptr getDomain() const;
55 
61  Domain_ptr getDomainPython() const;
62 
66  bool canTag() const;
67 
71  int getApproximationOrder() const;
72 
77  void setTags(const int newTag, const escript::Data& mask) const;
78 
79  void setTagsByString(const std::string& name, const escript::Data& mask) const;
80 
85  std::pair<int,DataTypes::dim_t> getDataShape() const;
86 
91  bool operator==(const FunctionSpace& other) const;
92 
93  bool operator!=(const FunctionSpace& other) const;
94 
98  std::string toString() const;
99 
103  int getTagFromSampleNo(DataTypes::dim_t sampleNo) const;
104 
108  int getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const;
109 
114  DataTypes::dim_t getReferenceIDFromDataPointNo(DataTypes::dim_t dataPointNo) const;
115 
122  inline
123  DataTypes::dim_t getReferenceIDOfSample(DataTypes::dim_t sampleNo) const {
124  return borrowSampleReferenceIDs()[sampleNo];
125  }
126 
131  inline
132  bool ownSample(DataTypes::dim_t sampleNo) const {
133  return m_domain->ownSample(m_functionSpaceType, sampleNo);
134  }
135 
139  const DataTypes::dim_t* borrowSampleReferenceIDs() const;
140 
144  escript::Data getX() const;
145 
146 #ifdef ESYS_HAVE_BOOST_NUMPY
147 
150  boost::python::numpy::ndarray getNumpyX() const;
151 #endif
152 
156  escript::Data getNormal() const;
157 
162  escript::Data getSize() const;
163 
167  inline
168  DataTypes::dim_t getNumSamples() const { return getDataShape().second; }
169 
173  inline
174  int getNumDPPSample() const { return getNumDataPointsPerSample(); }
175 
176  inline
177  int getNumDataPointsPerSample() const { return getDataShape().first; }
178 
182  inline
183  int getDim() const { return getDomain()->getDim(); }
184 
188  boost::python::list getListOfTags() const;
189 
193  std::list<int> getListOfTagsSTL() const;
194 
198  int getNumberOfTagsInUse() const;
199 
200  const int* borrowListOfTagsInUse() const;
201 
202  inline
203  bool probeInterpolation(const FunctionSpace& other) const
204  {
205  if (*this == other)
206  return true;
207  const_Domain_ptr domain(getDomain());
208  if (*domain == *other.getDomain()) {
209  return domain->probeInterpolationOnDomain(
210  getTypeCode(), other.getTypeCode());
211  }
212  return domain->probeInterpolationAcross(
213  getTypeCode(), *(other.getDomain()), other.getTypeCode());
214  }
215 
216 private:
222  FunctionSpace& operator=(const FunctionSpace& other);
223 
224  const_Domain_ptr m_domain;
225 
226  int m_functionSpaceType;
227 };
228 
230 
231 } // end of namespace
232 
233 #endif // __ESCRIPT_FUNCTIONSPACE_H__
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:178
DataFactory.h
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
escript::Data::getNumDataPointsPerSample
int getNumDataPointsPerSample() const
Return the number of data points per sample.
Definition: Data.h:543
escript::FunctionSpace::getTagFromSampleNo
int getTagFromSampleNo(DataTypes::dim_t sampleNo) const
Returns the tag associated with the given sample number.
Definition: FunctionSpace.cpp:143
escript::FunctionSpace::getSize
escript::Data getSize() const
Returns the sample size (e.g. the diameter of elements, radius of particles).
Definition: FunctionSpace.cpp:294
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:108
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:76
escript::FunctionSpace::m_functionSpaceType
int m_functionSpaceType
Definition: FunctionSpace.h:238
escript::NullDomain
NullDomain provides a null value for domain. Needed for the construction of a default FunctionSpace.
Definition: NullDomain.h:52
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:88
escript::FunctionSpace::getNumSamples
DataTypes::dim_t getNumSamples() const
Returns the number of samples.
Definition: FunctionSpace.h:180
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:704
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:53
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:206
escript::FunctionSpace
Definition: FunctionSpace.h:47
escript::FunctionSpace::getListOfTagsSTL
std::list< int > getListOfTagsSTL() const
Returns an stl list of the tags used in this function space.
Definition: FunctionSpace.cpp:334
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:462
escript::FunctionSpace::canTag
bool canTag() const
Returns true if this function space support tags.
Definition: FunctionSpace.cpp:352
escript::FunctionSpace::getDomain
const_Domain_ptr getDomain() const
Returns the function space domain.
Definition: FunctionSpace.cpp:102
weipa::VisItControl::initialize
bool initialize(const std::string &simFile, const std::string &comment)
Definition: VisItControl.cpp:203
system_dep.h
escript::Data::getNumSamples
int getNumSamples() const
Return the number of samples.
Definition: Data.h:532
escript::FunctionSpace::getNormal
escript::Data getNormal() const
Returns the surface normal field.
Definition: FunctionSpace.cpp:285
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:63
escript::DataException
Definition: DataException.h:39
escript::FunctionSpace::m_domain
const_Domain_ptr m_domain
Definition: FunctionSpace.h:236
escript::FunctionSpace::getX
escript::Data getX() const
Returns the spatial locations of the data points.
Definition: FunctionSpace.cpp:228
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:90
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:303
escript::Data::getSampleDataRW
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample no. Please do not use this unless you NEED to access samp...
Definition: Data.h:1953
escript::FunctionSpace::getNumDPPSample
int getNumDPPSample() const
Returns the number of data points per sample.
Definition: FunctionSpace.h:186
escript::FunctionSpace::getApproximationOrder
int getApproximationOrder() const
Returns the approximation order used for this function space.
Definition: FunctionSpace.cpp:358
AbstractDomain.h
escript::FunctionSpace::getListOfTags
boost::python::list getListOfTags() const
Returns a list of the tags used in this function space.
Definition: FunctionSpace.cpp:342
escript::FunctionSpaceException
Definition: FunctionSpaceException.h:40
escript::FunctionSpace::borrowListOfTagsInUse
const int * borrowListOfTagsInUse() const
Definition: FunctionSpace.cpp:329
escript::canInterpolate
bool canInterpolate(FunctionSpace src, FunctionSpace dest)
Definition: FunctionSpace.cpp:33
FunctionSpaceException.h
escript
Definition: AbstractContinuousDomain.cpp:23
escript::FunctionSpace::setTagsByString
void setTagsByString(const std::string &name, const escript::Data &mask) const
Definition: FunctionSpace.cpp:313
NullDomain.h
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:94
escript::FunctionSpace::toString
std::string toString() const
Returns a text description of the function space.
Definition: FunctionSpace.cpp:117
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:138
escript::Data::getShapeProduct
long getShapeProduct() const
Returns the product of the data point shapes.
Definition: Data.cpp:749
escript::FunctionSpace::borrowSampleReferenceIDs
const DataTypes::dim_t * borrowSampleReferenceIDs() const
Returns a borrowed reference to the list of sample reference IDs.
Definition: FunctionSpace.cpp:198
Data.h
escript::FunctionSpace::operator!=
bool operator!=(const FunctionSpace &other) const
Definition: FunctionSpace.cpp:222
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:62
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:56
escript::FunctionSpace::FunctionSpace
FunctionSpace()
Definition: FunctionSpace.cpp:46
escript::Data::setProtection
void setProtection()
switches on update protection
Definition: Data.cpp:1170
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:216
escript::FunctionSpace::getNumberOfTagsInUse
int getNumberOfTagsInUse() const
Returns the number of tags in use.
Definition: FunctionSpace.cpp:324
escript::FunctionSpace::getTagFromDataPointNo
int getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const
Returns the tag associated with the given data-point number.
Definition: FunctionSpace.cpp:149
FunctionSpace.h