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 
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
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 
225 
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:179
escript::FunctionSpace::ownSample
bool ownSample(DataTypes::dim_t sampleNo) const
Does this process own the sample? For non-MPI builds will always return true.
Definition: FunctionSpace.h:132
DataFactory.h
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::Data::getNumDataPointsPerSample
int getNumDataPointsPerSample() const
Return the number of data points per sample.
Definition: Data.h:544
escript::FunctionSpace::getTagFromSampleNo
int getTagFromSampleNo(DataTypes::dim_t sampleNo) const
Returns the tag associated with the given sample number.
Definition: FunctionSpace.cpp:144
escript::FunctionSpace::getSize
escript::Data getSize() const
Returns the sample size (e.g. the diameter of elements, radius of particles).
Definition: FunctionSpace.cpp:295
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:109
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:51
escript::FunctionSpace::m_functionSpaceType
int m_functionSpaceType
Definition: FunctionSpace.h:226
escript::NullDomain
NullDomain provides a null value for domain. Needed for the construction of a default FunctionSpace.
Definition: NullDomain.h:41
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:89
escript::FunctionSpace::getNumSamples
DataTypes::dim_t getNumSamples() const
Returns the number of samples.
Definition: FunctionSpace.h:168
escript::FunctionSpace::getReferenceIDOfSample
DataTypes::dim_t getReferenceIDOfSample(DataTypes::dim_t sampleNo) const
Returns the reference number associated with the given sample number. This function is not efficient....
Definition: FunctionSpace.h:123
escript::Data::getDataPointShape
const DataTypes::ShapeType & getDataPointShape() const
Return a reference to the data point shape.
Definition: Data.h:705
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:41
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:207
escript::FunctionSpace
Definition: FunctionSpace.h:36
escript::FunctionSpace::getListOfTagsSTL
std::list< int > getListOfTagsSTL() const
Returns an stl list of the tags used in this function space.
Definition: FunctionSpace.cpp:335
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
escript::FunctionSpace::canTag
bool canTag() const
Returns true if this function space support tags.
Definition: FunctionSpace.cpp:353
escript::FunctionSpace::getDomain
const_Domain_ptr getDomain() const
Returns the function space domain.
Definition: FunctionSpace.cpp:103
weipa::VisItControl::initialize
bool initialize(const std::string &simFile, const std::string &comment)
Definition: VisItControl.cpp:178
escript::Data::getNumSamples
int getNumSamples() const
Return the number of samples.
Definition: Data.h:533
escript::FunctionSpace::getNormal
escript::Data getNormal() const
Returns the surface normal field.
Definition: FunctionSpace.cpp:286
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::DataException
Definition: DataException.h:28
escript::FunctionSpace::getNumDataPointsPerSample
int getNumDataPointsPerSample() const
Definition: FunctionSpace.h:177
escript::FunctionSpace::m_domain
const_Domain_ptr m_domain
Definition: FunctionSpace.h:224
escript::FunctionSpace::getX
escript::Data getX() const
Returns the spatial locations of the data points.
Definition: FunctionSpace.cpp:229
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:65
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:304
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:1954
escript::FunctionSpace::getNumDPPSample
int getNumDPPSample() const
Returns the number of data points per sample.
Definition: FunctionSpace.h:174
escript::FunctionSpace::getApproximationOrder
int getApproximationOrder() const
Returns the approximation order used for this function space.
Definition: FunctionSpace.cpp:359
AbstractDomain.h
escript::FunctionSpace::getListOfTags
boost::python::list getListOfTags() const
Returns a list of the tags used in this function space.
Definition: FunctionSpace.cpp:343
escript::FunctionSpaceException
Definition: FunctionSpaceException.h:29
escript::FunctionSpace::borrowListOfTagsInUse
const int * borrowListOfTagsInUse() const
Definition: FunctionSpace.cpp:330
escript::canInterpolate
bool canInterpolate(FunctionSpace src, FunctionSpace dest)
Definition: FunctionSpace.cpp:34
FunctionSpaceException.h
escript
Definition: AbstractContinuousDomain.cpp:23
escript::FunctionSpace::setTagsByString
void setTagsByString(const std::string &name, const escript::Data &mask) const
Definition: FunctionSpace.cpp:314
NullDomain.h
escript::FunctionSpace::getTypeCode
int getTypeCode() const
Returns the function space type code.
Definition: FunctionSpace.cpp:95
escript::FunctionSpace::getDim
int getDim() const
Return the number of spatial dimensions of the underlying domain.
Definition: FunctionSpace.h:183
escript::FunctionSpace::toString
std::string toString() const
Returns a text description of the function space.
Definition: FunctionSpace.cpp:118
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:125
escript::Data::getShapeProduct
long getShapeProduct() const
Returns the product of the data point shapes.
Definition: Data.cpp:745
escript::FunctionSpace::borrowSampleReferenceIDs
const DataTypes::dim_t * borrowSampleReferenceIDs() const
Returns a borrowed reference to the list of sample reference IDs.
Definition: FunctionSpace.cpp:199
Data.h
system_dep.h
escript::FunctionSpace::operator!=
bool operator!=(const FunctionSpace &other) const
Definition: FunctionSpace.cpp:223
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:49
escript::const_Domain_ptr
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:44
escript::FunctionSpace::FunctionSpace
FunctionSpace()
Definition: FunctionSpace.cpp:47
escript::Data::setProtection
void setProtection()
switches on update protection
Definition: Data.cpp:1166
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:217
escript::FunctionSpace::probeInterpolation
bool probeInterpolation(const FunctionSpace &other) const
Definition: FunctionSpace.h:203
escript::FunctionSpace::getNumberOfTagsInUse
int getNumberOfTagsInUse() const
Returns the number of tags in use.
Definition: FunctionSpace.cpp:325
escript::FunctionSpace::getTagFromDataPointNo
int getTagFromDataPointNo(DataTypes::dim_t dataPointNo) const
Returns the tag associated with the given data-point number.
Definition: FunctionSpace.cpp:150
FunctionSpace.h