escript  Revision_
AbstractDomain.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_ABSTRACTDOMAIN_H__
20 #define __ESCRIPT_ABSTRACTDOMAIN_H__
21 
22 #include "system_dep.h"
23 #include "DataTypes.h"
24 #include "EsysMPI.h"
25 #include "Pointers.h"
26 
27 #include <boost/python/tuple.hpp>
28 #ifdef ESYS_HAVE_BOOST_NUMPY
29 #include <boost/python/numpy.hpp>
30 #endif
31 
32 
33 #include <vector>
34 #include <string>
35 
36 namespace escript {
37 
38 // class forward declarations
39 class Data;
40 class FunctionSpace;
41 class AbstractDomain;
42 
45 
50 class ESCRIPT_DLL_API AbstractDomain: public REFCOUNT_BASE_CLASS(AbstractDomain)
51 {
52 public:
53  typedef int StatusType;
54 
61  Domain_ptr getPtr();
62 
63  const_Domain_ptr getPtr() const;
64 
69  virtual ~AbstractDomain() {}
70 
75  virtual JMPI getMPI() const = 0;
76 
81  virtual int getMPISize() const = 0;
82 
87  virtual int getMPIRank() const = 0;
88 
93  virtual void MPIBarrier() const = 0;
94 
99  virtual bool onMasterProcessor() const = 0;
100 
107  virtual MPI_Comm getMPIComm() const = 0;
108 
114  virtual bool isValidFunctionSpaceType(int functionSpaceType) const = 0;
115 
120  virtual std::string getDescription() const = 0;
121 
126  virtual std::string functionSpaceTypeAsString(int functionSpaceType) const = 0;
127 
134  virtual int getDim() const = 0;
135 
140  virtual bool operator==(const AbstractDomain& other) const = 0;
141 
146  virtual bool operator!=(const AbstractDomain& other) const = 0;
147 
154  virtual void write(const std::string& filename) const = 0;
155 
162  virtual void dump(const std::string& filename) const = 0;
163 
175  virtual std::pair<int,DataTypes::dim_t> getDataShape(int functionSpaceCode) const = 0;
176 
183  virtual int getTagFromSampleNo(int functionSpaceType, DataTypes::index_t sampleNo) const = 0;
184 
191  virtual void setTagMap(const std::string& name, int tag) = 0;
192 
198  virtual int getTag(const std::string& name) const = 0;
199 
205  virtual bool isValidTagName(const std::string& name) const;
206 
211  virtual std::string showTagNames() const = 0;
212 
218  // ESCRIPT_DLL_API class already exported
219  virtual const DataTypes::dim_t* borrowSampleReferenceIDs(int functionSpaceType) const = 0;
220 
227  virtual void setNewX(const escript::Data& arg) = 0;
228 
236  virtual void interpolateOnDomain(escript::Data& target, const escript::Data& source) const = 0;
237 
241  virtual bool probeInterpolationOnDomain(int functionSpaceType_source,
242  int functionSpaceType_target) const = 0;
243 
253  virtual signed char preferredInterpolationOnDomain(
254  int functionSpaceType_source,
255  int functionSpaceType_target) const = 0;
256 
264  virtual bool
265  commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const = 0;
266 
273  virtual void interpolateAcross(escript::Data& target, const escript::Data& source) const = 0;
274 
275  virtual bool probeInterpolationAcross(int functionSpaceType_source,
276  const AbstractDomain& targetDomain,
277  int functionSpaceType_target) const = 0;
278 
283  virtual escript::Data getX() const = 0;
284 
285 #ifdef ESYS_HAVE_BOOST_NUMPY
290  virtual boost::python::numpy::ndarray getNumpyX() const = 0;
291 #endif
292 
297  virtual escript::Data getNormal() const = 0;
298 
303  virtual escript::Data getSize() const = 0;
304 
313  virtual void setToX(escript::Data& out) const = 0;
314 
323  virtual void setToNormal(escript::Data& out) const = 0;
324 
333  virtual void setToSize(escript::Data& out) const = 0;
334 
342  virtual void setToGradient(escript::Data& grad, const escript::Data& arg) const = 0;
343 
348  virtual bool ownSample(int fs_code, DataTypes::index_t id) const = 0;
349 
355  virtual void setTags(int functionSpaceType, int newTag, const escript::Data& mask) const = 0;
356 
364  virtual bool isCellOriented(int functionSpaceCode) const = 0;
365 
374  virtual StatusType getStatus() const;
375 
381  void throwStandardException(const std::string& functionName) const;
382 
388  virtual int getNumberOfTagsInUse(int functionSpaceCode) const = 0;
389 
390  virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const = 0;
391 
395  virtual bool canTag(int functionspacecode) const = 0;
396 
400  virtual int getApproximationOrder(const int functionSpaceCode) const = 0;
401 
402  virtual bool supportsContactElements() const = 0;
403 
407  virtual bool supportsFilter(const boost::python::tuple& t) const;
408 
413  const FunctionSpace& what, long seed,
414  const boost::python::tuple& filter) const = 0;
415 };
416 
417 } // end of namespace
418 
419 #endif // __ESCRIPT_ABSTRACTDOMAIN_H__
420 
int MPI_Comm
Definition: EsysMPI.h:44
Typedefs and macros for reference counted storage.
#define POINTER_WRAPPER_CLASS(x)
Definition: Pointers.h:33
#define REFCOUNT_BASE_CLASS(x)
Definition: Pointers.h:31
Base class for all escript domains.
Definition: AbstractDomain.h:51
virtual void dump(const std::string &filename) const =0
dumps the domain to an external file filename.
virtual int getTag(const std::string &name) const =0
Return the tag key for tag name.
virtual bool probeInterpolationOnDomain(int functionSpaceType_source, int functionSpaceType_target) const =0
True if interpolation is possible from source to target.
virtual escript::Data getSize() const =0
Returns the local size of samples. The function space is chosen appropriately.
virtual int getMPIRank() const =0
return the number MPI rank of this processor
virtual const int * borrowListOfTagsInUse(int functionSpaceCode) const =0
virtual int getTagFromSampleNo(int functionSpaceType, DataTypes::index_t sampleNo) const =0
Return the tag key for the given sample number.
virtual const DataTypes::dim_t * borrowSampleReferenceIDs(int functionSpaceType) const =0
Returns a borrowed pointer to the sample reference number id list.
virtual void interpolateOnDomain(escript::Data &target, const escript::Data &source) const =0
Interpolates data given on source onto target where source and target have to be given on the same do...
virtual bool operator==(const AbstractDomain &other) const =0
Return true if given domains are equal.
virtual void setTagMap(const std::string &name, int tag)=0
sets a map from a clear tag name to a tag key
virtual escript::Data randomFill(const DataTypes::ShapeType &shape, const FunctionSpace &what, long seed, const boost::python::tuple &filter) const =0
Fills the data object with filtered random values.
virtual bool isValidFunctionSpaceType(int functionSpaceType) const =0
Returns true if the given integer is a valid function space type for this domain.
virtual void interpolateAcross(escript::Data &target, const escript::Data &source) const =0
Interpolates data given on source onto target where source and target are given on different domains.
virtual std::string getDescription() const =0
Return a description for this domain.
virtual int getNumberOfTagsInUse(int functionSpaceCode) const =0
returns the number of tags in use and a pointer to an array with the number of tags in use
virtual void setToSize(escript::Data &out) const =0
Copies the size of samples into out. The actual function space to be considered is defined by out....
virtual bool canTag(int functionspacecode) const =0
Checks if this domain allows tags for the specified functionSpaceCode.
virtual signed char preferredInterpolationOnDomain(int functionSpaceType_source, int functionSpaceType_target) const =0
Preferred direction of interpolation. If you really need to test for a particular direction,...
virtual int getApproximationOrder(const int functionSpaceCode) const =0
returns the approximation order used for a function space functionSpaceCode
int StatusType
Definition: AbstractDomain.h:53
virtual int getDim() const =0
Returns the spatial dimension of the domain.
virtual std::string showTagNames() const =0
Returns all tag names in a single string sperated by commas.
virtual ~AbstractDomain()
Destructor for AbstractDomain.
Definition: AbstractDomain.h:69
virtual bool commonFunctionSpace(const std::vector< int > &fs, int &resultcode) const =0
given a vector of FunctionSpace type codes, pass back a code which then can all be interpolated to.
virtual bool ownSample(int fs_code, DataTypes::index_t id) const =0
True if this rank owns the sample(id) Must be implemented by the Domain adapter.
virtual void setNewX(const escript::Data &arg)=0
Assigns new location to the domain.
virtual bool onMasterProcessor() const =0
Return true if on MPI master, else false.
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const =0
Return a description for the given function space type code.
virtual escript::Data getX() const =0
Returns locations in the domain. The function space is chosen appropriately.
virtual bool operator!=(const AbstractDomain &other) const =0
Return true if given domains are not equal.
virtual bool isCellOriented(int functionSpaceCode) const =0
returns true if data on this domain and a function space of type functionSpaceCode has to considered ...
virtual bool probeInterpolationAcross(int functionSpaceType_source, const AbstractDomain &targetDomain, int functionSpaceType_target) const =0
virtual void MPIBarrier() const =0
If compiled for MPI then execute an MPI_Barrier, else do nothing.
virtual void write(const std::string &filename) const =0
Writes the domain to an external file filename.
virtual int getMPISize() const =0
return the number of processors used for this domain
virtual void setTags(int functionSpaceType, int newTag, const escript::Data &mask) const =0
assigns new tag newTag to all samples of functionspace with a positive value of mask for any its samp...
virtual MPI_Comm getMPIComm() const =0
get the communicator for this domain. Returns an integer on non-MPI builds Routine must be implemente...
virtual std::pair< int, DataTypes::dim_t > getDataShape(int functionSpaceCode) const =0
Returns the number of data points per sample, and the number of samples as a pair.
virtual void setToX(escript::Data &out) const =0
Copies the location of data points on the domain into out. The actual function space to be considered...
virtual escript::Data getNormal() const =0
Return boundary normals. The function space is chosen appropriately.
virtual void setToGradient(escript::Data &grad, const escript::Data &arg) const =0
Copies the gradient of arg into grad. The actual function space to be considered for the gradient is ...
virtual bool supportsContactElements() const =0
virtual void setToNormal(escript::Data &out) const =0
Copies the surface normals at data points into out. The actual function space to be considered is def...
virtual JMPI getMPI() const =0
returns a shared pointer to the MPI information wrapper for this domain
Data represents a collection of datapoints.
Definition: Data.h:64
Definition: FunctionSpace.h:36
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:44
index_t dim_t
Definition: DataTypes.h:66
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:61
Definition: AbstractContinuousDomain.cpp:23
boost::shared_ptr< const AbstractDomain > const_Domain_ptr
Definition: AbstractDomain.h:44
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:41
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:74