escript  Revision_4925
FunctionSpace.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
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 #if !defined escript_FunctionSpace_20040323_H
19 #define escript_FunctionSpace_20040323_H
20 #include "system_dep.h"
21 
22 #include "AbstractDomain.h"
23 #include "NullDomain.h"
24 
25 #include <string>
26 #include <list>
27 
28 namespace escript {
29 
30 //
31 // Forward declaration for class Data.
32 class Data;
33 
47 {
48 public:
64  FunctionSpace();
65 
75  int functionSpaceType);
76 
77 
79  FunctionSpace(const FunctionSpace& other);
80 
88  int
89  getTypeCode() const;
90 
96 // const
97 // AbstractDomain&
99  getDomain() const;
100 
108 // const
109 // AbstractDomain&
110  Domain_ptr
111  getDomainPython() const;
112 
113 
114 
119  bool
120  canTag() const;
121 
127  int
128  getApproximationOrder() const;
129 
135  void setTags(const int newTag, const escript::Data& mask) const;
136 
137 
139  void setTagsByString(const std::string& name, const escript::Data& mask) const;
140 
141 
147  std::pair<int,int>
148  getDataShape() const;
149 
157  bool
158  operator==(const FunctionSpace& other) const;
159 
161  bool
162  operator!=(const FunctionSpace& other) const;
163 
169  std::string
170  toString() const;
171 
172  //#define DEBUG_PY_STRINGS
173 
174 #ifdef DEBUG_PY_STRINGS
175 
184  PyObject *
185  toPyString() const;
186 #endif
187 
193  int
194  getTagFromSampleNo(int sampleNo) const;
195 
201  int
202  getTagFromDataPointNo(int dataPointNo) const;
203 
209  int getReferenceIDFromDataPointNo(int dataPointNo) const;
210 
218  inline
219  int
220  getReferenceIDOfSample(int sampleNo) const
221  {
222  return borrowSampleReferenceIDs()[sampleNo];
223  }
224 
230  inline
231  bool
232  ownSample(int sampleNo) const
233  {
234  return m_domain->ownSample(m_functionSpaceType, sampleNo);
235  }
236 
242  const int*
243  borrowSampleReferenceIDs() const;
244 
251  getX() const;
252 
259  getNormal() const;
260 
267  getSize() const;
268 
274  inline
275  int
276  getNumSamples() const {
277  return getDataShape().second;
278  }
279 
285  inline
286  int
287  getNumDPPSample() const {
288  return getNumDataPointsPerSample();
289  }
290 
292  inline
293  int
295  return getDataShape().first;
296  }
297 
303  inline
304  int
305  getDim() const {
306  return getDomain()->getDim();
307  }
313  boost::python::list
314  getListOfTags() const;
320  std::list<int>
321  getListOfTagsSTL() const;
322 
328  int getNumberOfTagsInUse() const;
329 
331  const int* borrowListOfTagsInUse() const;
332 
334  bool
335  probeInterpolation(const FunctionSpace& other) const
336  {
337  if (*this==other) {
338  return true;
339  } else {
340  const_Domain_ptr domain=getDomain();
341  if (*domain==*other.getDomain()) {
342  return domain->probeInterpolationOnDomain(getTypeCode(),other.getTypeCode());
343  } else {
344  return domain->probeInterpolationACross(getTypeCode(),*(other.getDomain()),other.getTypeCode());
345  }
346  }
347  }
348 
349 
350  protected:
351 
352  private:
359  FunctionSpace&
360  operator=(const FunctionSpace& other);
361 
362  //
363  // function space domain
364 
365 // const AbstractDomain* m_domain;
367 
368 
369  //
370  // function space type code.
372 
373 };
374 
377 
378 } // end of namespace
379 
380 #endif
Give a short description of what FunctionSpace does.
Definition: FunctionSpace.h:46
void setTagsByString(const std::string &name, const escript::Data &mask) const
Definition: FunctionSpace.cpp:266
int getDim() const
Return the spatial dimension of the underlying domain.
Definition: FunctionSpace.h:305
const int * borrowSampleReferenceIDs() const
Return a borrowed reference to the list of sample reference IDs.
Definition: FunctionSpace.cpp:199
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:57
int getReferenceIDOfSample(int sampleNo) const
Return the reference number associated with the given sample number. This function is not efficient...
Definition: FunctionSpace.h:220
int getReferenceIDFromDataPointNo(int dataPointNo) const
Return the reference number associated with the given data-point number.
Definition: FunctionSpace.cpp:179
int getNumberOfTagsInUse() const
return the number of tags in use and a pointer to an array with the number of tags in use ...
Definition: FunctionSpace.cpp:277
Domain_ptr getDomainPython() const
Return the function space domain. Internal use only! This gets around some python difficulties by cas...
Definition: FunctionSpace.cpp:109
int getApproximationOrder() const
returns the approximation order used for this function space
Definition: FunctionSpace.cpp:316
int getTagFromDataPointNo(int dataPointNo) const
Return the tag associated with the given data-point number.
Definition: FunctionSpace.cpp:150
escript::Data getX() const
Return the spatial locations of the data points.
Definition: FunctionSpace.cpp:229
std::pair< int, int > getDataShape() const
Return the shape of the data needed to represent the function space.
Definition: FunctionSpace.cpp:89
escript::Data getSize() const
Return the sample size (e.g. the diameter of elements, radius of particles).
Definition: FunctionSpace.cpp:247
int getNumDPPSample() const
Return the number of data points per sample.
Definition: FunctionSpace.h:287
std::string toString() const
Return a text description of the function space.
Definition: FunctionSpace.cpp:118
const_Domain_ptr m_domain
Definition: FunctionSpace.h:366
Data represents a collection of datapoints.
Definition: Data.h:71
int getTypeCode() const
Return the function space type code.
Definition: FunctionSpace.cpp:95
int m_functionSpaceType
Definition: FunctionSpace.h:371
boost::python::list getListOfTags() const
Returns a list of the tags used in this function space.
Definition: FunctionSpace.cpp:300
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 its sample point...
Definition: FunctionSpace.cpp:256
FunctionSpace & operator=(const FunctionSpace &other)
Assignment operator. This method is only defined (private) to prevent people from using it...
Definition: FunctionSpace.cpp:207
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:64
bool canTag() const
Checks if this functionspace support tags.
Definition: FunctionSpace.cpp:310
std::list< int > getListOfTagsSTL() const
Returns an stl::list of the tags used in this function space.
Definition: FunctionSpace.cpp:289
bool canInterpolate(FunctionSpace src, FunctionSpace dest)
Definition: FunctionSpace.cpp:32
bool ownSample(int sampleNo) const
Does this process own the sample? For non-MPI builds will always return true.
Definition: FunctionSpace.h:232
escript::Data getNormal() const
Return the surface normal field.
Definition: FunctionSpace.cpp:238
bool operator!=(const FunctionSpace &other) const
Definition: FunctionSpace.cpp:223
bool probeInterpolation(const FunctionSpace &other) const
Definition: FunctionSpace.h:335
FunctionSpace()
Default constructor for FunctionSpace.
Definition: FunctionSpace.cpp:47
int getNumDataPointsPerSample() const
Definition: FunctionSpace.h:294
const_Domain_ptr getDomain() const
Return the function space domain.
Definition: FunctionSpace.cpp:103
int getTagFromSampleNo(int sampleNo) const
Return the tag associated with the given sample number.
Definition: FunctionSpace.cpp:144
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:60
int getNumSamples() const
Return the number of samples.
Definition: FunctionSpace.h:276
const int * borrowListOfTagsInUse() const
Definition: FunctionSpace.cpp:283
bool operator==(const FunctionSpace &other) const
Comparison operator. Return true if function spaces are equal. ie: Same domain and same function spac...
Definition: FunctionSpace.cpp:217