TestDomain.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __ESCRIPT_TESTDOMAIN_H__
#define __ESCRIPT_TESTDOMAIN_H__
#include "system_dep.h"
#include "NullDomain.h"
#include <vector>
namespace escript {
class ESCRIPT_DLL_API TestDomain : public NullDomain
{
public:
TestDomain(int pointspersample, int numsamples, int dpsize=1);
virtual ~TestDomain();
virtual int getMPISize() const;
virtual int getMPIRank() const;
virtual void MPIBarrier() const;
virtual bool onMasterProcessor() const;
virtual escript::JMPI getMPI() const;
virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
virtual std::string getDescription() const;
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
bool commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const;
virtual escript::Data getX() const;
virtual void interpolateAcross(escript::Data& target, const escript::Data& source) const;
virtual bool probeInterpolationAcross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
virtual int getDefaultCode() const;
virtual int getContinuousFunctionCode() const;
virtual int getFunctionCode() const;
virtual int getFunctionOnBoundaryCode() const;
virtual int getFunctionOnContactZeroCode() const;
virtual int getFunctionOnContactOneCode() const;
virtual int getSolutionCode() const;
virtual int getReducedSolutionCode() const;
virtual int getDiracDeltaFunctionsCode() const;
virtual std::pair<int,DataTypes::dim_t> getDataShape(int functionSpaceCode) const;
virtual int getTagFromSampleNo(int functionSpaceType, DataTypes::index_t sampleNo) const;
virtual const DataTypes::dim_t* borrowSampleReferenceIDs(int functionSpaceType) const;
virtual int getDim() const;
virtual bool operator==(const AbstractDomain& other) const;
virtual bool operator!=(const AbstractDomain& other) const;
virtual bool canTag(int functionSpaceCode) const;
virtual int getNumberOfTagsInUse(int functionSpaceCode) const;
virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const;
virtual escript::Data randomFill(const DataTypes::ShapeType& shape,
const FunctionSpace& what, long seed,
const boost::python::tuple& filter) const;
void addUsedTag(int t);
void clearUsedTags();
void assignTags(std::vector<int> t);
void resetTagAssignments();
private:
DataTypes::dim_t m_totalsamples; // samples in all worlds
DataTypes::dim_t m_samples; // number of samples
DataTypes::dim_t m_originsample;
DataTypes::dim_t m_endsample;
int m_dpps; // data points per sample
int m_dpsize; // how big are the datapoints?
DataTypes::dim_t* m_samplerefids; // sample reference ids
std::vector<int> mytags;
std::vector<int> tag_assignment; // which tag is assigned to each sample
// to make testing easier, the tags in use list is
// controlled separately
escript::JMPI myworld;
};
ESCRIPT_DLL_API
FunctionSpace getTestDomainFunctionSpace(int dpps, DataTypes::dim_t samples, int dpsize);
} // end of namespace
#endif // __ESCRIPT_TESTDOMAIN_H__
escript::Data::getReady
const DataReady * getReady() const
Definition: Data.h:1786
ESCRIPT_DLL_API
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
escript::MPIBarrierWorld
void MPIBarrierWorld()
performs a barrier synchronization across all processors.
Definition: Utils.cpp:377
escript::TestDomain::~TestDomain
virtual ~TestDomain()
Definition: TestDomain.cpp:80
escript::TestDomain::getSolutionCode
virtual int getSolutionCode() const
Definition: TestDomain.cpp:203
escript::TestDomain::getContinuousFunctionCode
virtual int getContinuousFunctionCode() const
Definition: TestDomain.cpp:178
escript::DomainException
Definition: DomainException.h:41
escript::TestDomain::interpolateAcross
virtual void interpolateAcross(escript::Data &target, const escript::Data &source) const
Interpolates data given on source onto target where source and target are given on different domains.
Definition: TestDomain.cpp:152
escript::TestDomain::isValidFunctionSpaceType
virtual bool isValidFunctionSpaceType(int functionSpaceType) const
Returns true if the given integer is a valid function space type for this domain.
Definition: TestDomain.cpp:119
escript::TestDomain::getTagFromSampleNo
virtual int getTagFromSampleNo(int functionSpaceType, DataTypes::index_t sampleNo) const
Return the tag key for the given sample number.
Definition: TestDomain.cpp:223
escript::DataTypes::DataVectorAlt< real_t >
escript::randomFillArray
void randomFillArray(long seed, double *array, size_t n)
Definition: Random.cpp:75
escript::TestDomain::getFunctionOnContactZeroCode
virtual int getFunctionOnContactZeroCode() const
Definition: TestDomain.cpp:193
escript::TestDomain
(Testing use only) Provides a domain to wrap a collection of values.
Definition: TestDomain.h:56
escript::TestDomain::assignTags
void assignTags(std::vector< int > t)
Definition: TestDomain.cpp:328
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:55
escript::TestDomain::borrowSampleReferenceIDs
virtual const DataTypes::dim_t * borrowSampleReferenceIDs(int functionSpaceType) const
Returns a borrowed pointer to the sample reference number id list.
Definition: TestDomain.cpp:234
escript::getMPISizeWorld
int getMPISizeWorld()
returns the total number of available MPI processes for MPI_COMM_WORLD
Definition: Utils.cpp:94
escript::TestDomain::getMPIRank
virtual int getMPIRank() const
return the number MPI rank of this processor
Definition: TestDomain.cpp:90
escript::TestDomain::operator!=
virtual bool operator!=(const AbstractDomain &other) const
Return true if given domains are not equal.
Definition: TestDomain.cpp:250
escript::FunctionSpace
Definition: FunctionSpace.h:49
escript::makeInfo
JMPI makeInfo(MPI_Comm comm, bool owncom)
Definition: EsysMPI.cpp:43
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
speckley::probeInterpolationAcross
bool probeInterpolationAcross(int fsType_source, const escript::AbstractDomain &domain, int fsType_target, int dim)
Definition: CrossDomainCoupler.cpp:32
escript::FunctionSpace::getDomain
const_Domain_ptr getDomain() const
Returns the function space domain.
Definition: FunctionSpace.cpp:103
escript::TestDomain::getMPI
virtual escript::JMPI getMPI() const
returns a shared pointer to the MPI information wrapper for this domain
Definition: TestDomain.cpp:112
system_dep.h
escript::TestDomain::TestDomain
TestDomain(int pointspersample, int numsamples, int dpsize=1)
Definition: TestDomain.cpp:51
MPI_COMM_WORLD
#define MPI_COMM_WORLD
Definition: EsysMPI.h:48
Utils.h
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::DataException
Definition: DataException.h:41
escript::TestDomain::getFunctionOnBoundaryCode
virtual int getFunctionOnBoundaryCode() const
Definition: TestDomain.cpp:188
escript::TestDomain::randomFill
virtual escript::Data randomFill(const DataTypes::ShapeType &shape, const FunctionSpace &what, long seed, const boost::python::tuple &filter) const
Fills the data object with filtered random values.
Definition: TestDomain.cpp:293
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:93
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:71
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:72
DomainException.h
escript::TestDomain::borrowListOfTagsInUse
virtual const int * borrowListOfTagsInUse(int functionSpaceCode) const
Definition: TestDomain.cpp:323
escript::TestDomain::getX
virtual escript::Data getX() const
Returns locations in the domain. The function space is chosen appropriately.
Definition: TestDomain.cpp:265
escript::TestDomain::resetTagAssignments
void resetTagAssignments()
Definition: TestDomain.cpp:342
escript::TestDomain::getDataShape
virtual std::pair< int, DataTypes::dim_t > getDataShape(int functionSpaceCode) const
Returns the number of data points per sample, and the number of samples as a pair.
Definition: TestDomain.cpp:218
escript::TestDomain::getDefaultCode
virtual int getDefaultCode() const
Definition: TestDomain.cpp:173
escript::TestDomain::addUsedTag
void addUsedTag(int t)
Definition: TestDomain.cpp:305
escript::TestDomain::getMPISize
virtual int getMPISize() const
return the number of processors used for this domain
Definition: TestDomain.cpp:85
escript::TestDomain::operator==
virtual bool operator==(const AbstractDomain &other) const
Return true if given domains are equal.
Definition: TestDomain.cpp:244
escript::TestDomain::getReducedSolutionCode
virtual int getReducedSolutionCode() const
Definition: TestDomain.cpp:208
escript::TestDomain::functionSpaceTypeAsString
virtual std::string functionSpaceTypeAsString(int functionSpaceType) const
Return a description for the given function space type code.
Definition: TestDomain.cpp:129
escript::TestDomain::canTag
virtual bool canTag(int functionSpaceCode) const
Checks if this domain allows tags for the specified functionSpaceCode.
Definition: TestDomain.cpp:255
escript::TestDomain::commonFunctionSpace
bool commonFunctionSpace(const std::vector< int > &fs, int &resultcode) const
given a vector of FunctionSpace type codes, pass back a code which then can all be interpolated to.
Definition: TestDomain.cpp:163
escript::TestDomain::MPIBarrier
virtual void MPIBarrier() const
If compiled for MPI then execute an MPI_Barrier, else do nothing.
Definition: TestDomain.cpp:95
escript::TestDomain::interpolateOnDomain
virtual void interpolateOnDomain(escript::Data &target, const escript::Data &source) const
Interpolates data given on source onto target where source and target have to be given on the same do...
Definition: TestDomain.cpp:134
escript::TestDomain::clearUsedTags
void clearUsedTags()
Definition: TestDomain.cpp:317
escript::getTestDomainFunctionSpace
FunctionSpace getTestDomainFunctionSpace(int dpps, DataTypes::dim_t samples, int dpsize)
Definition: TestDomain.cpp:352
escript::TestDomain::getNumberOfTagsInUse
virtual int getNumberOfTagsInUse(int functionSpaceCode) const
returns the number of tags in use and a pointer to an array with the number of tags in use
Definition: TestDomain.cpp:260
escript::TestDomain::getDiracDeltaFunctionsCode
virtual int getDiracDeltaFunctionsCode() const
Definition: TestDomain.cpp:213
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:88
Random.h
escript
Definition: AbstractContinuousDomain.cpp:23
escript::DataTypes::DataVectorAlt::size
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:243
escript::DataReady::getVectorRW
virtual DataTypes::RealVectorType & getVectorRW()=0
Provide access to underlying storage. Internal use only!
escript::TestDomain::probeInterpolationOnDomain
virtual bool probeInterpolationOnDomain(int functionSpaceType_source, int functionSpaceType_target) const
True if interpolation is possible from source to target.
Definition: TestDomain.cpp:143
NullDomain.h
escript::TestDomain::getFunctionOnContactOneCode
virtual int getFunctionOnContactOneCode() const
Definition: TestDomain.cpp:198
escript::TestDomain::probeInterpolationAcross
virtual bool probeInterpolationAcross(int functionSpaceType_source, const AbstractDomain &targetDomain, int functionSpaceType_target) const
Definition: TestDomain.cpp:157
escript::TestDomain::getDescription
virtual std::string getDescription() const
Return a description for this domain.
Definition: TestDomain.cpp:124
Data.h
escript::AbstractDomain
Base class for all escript domains.
Definition: AbstractDomain.h:64
escript::getMPIRankWorld
int getMPIRankWorld()
returns the MPI processor number within MPI_COMM_WORLD
Definition: Utils.cpp:103
escript::TestDomain::onMasterProcessor
virtual bool onMasterProcessor() const
Return true if on MPI master, else false.
Definition: TestDomain.cpp:100
escript::TestDomain::getFunctionCode
virtual int getFunctionCode() const
Definition: TestDomain.cpp:183
escript::TestDomain::getDim
virtual int getDim() const
Returns the spatial dimension of the domain.
Definition: TestDomain.cpp:239
TestDomain.h
escript::DataTypes::scalarShape
static const ShapeType scalarShape
Use this instead of creating empty shape objects for scalars.
Definition: DataTypes.h:75