speckley/src/Rectangle.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 __SPECKLEY_RECTANGLE_H__
#define __SPECKLEY_RECTANGLE_H__
#include <speckley/SpeckleyDomain.h>
namespace speckley {
#ifdef USE_RIPLEY
class RipleyCoupler; //forward declaration of coupler to avoid circles
#endif
class Speckley_DLL_API Rectangle: public SpeckleyDomain
{
public:
Rectangle(int order, dim_t n0, dim_t n1, double x0, double y0,
double x1, double y1, int d0=-1, int d1=-1,
const std::vector<double>& points = std::vector<double>(),
const std::vector<int>& tags = std::vector<int>(),
const TagMap& tagnamestonums = TagMap(),
escript::SubWorld_ptr w=escript::SubWorld_ptr()
);
~Rectangle();
virtual std::string getDescription() const;
virtual bool operator==(const escript::AbstractDomain& other) const;
virtual void write(const std::string& filename) const;
void dump(const std::string& filename) const;
virtual void readNcGrid(escript::Data& out, std::string filename,
std::string varname, const ReaderParameters& params) const;
virtual void readBinaryGrid(escript::Data& out, std::string filename,
const ReaderParameters& params) const;
virtual void readBinaryGridFromZipped(escript::Data& out,
std::string filename, const ReaderParameters& params) const;
virtual void writeBinaryGrid(const escript::Data& in,
std::string filename,
int byteOrder, int dataType) const;
const dim_t* borrowSampleReferenceIDs(int fsType) const;
virtual bool ownSample(int fs_code, index_t id) const;
virtual void setToNormal(escript::Data& out) const;
virtual void setToSize(escript::Data& out) const;
virtual dim_t getNumDataPointsGlobal() const;
virtual void Print_Mesh_Info(const bool full=false) const;
virtual const dim_t* getNumNodesPerDim() const { return m_NN; }
virtual const dim_t* getNumElementsPerDim() const { return m_NE; }
virtual const dim_t* getNumFacesPerBoundary() const { return m_faceCount; }
virtual IndexVector getNodeDistribution() const { return m_nodeDistribution; }
virtual const int* getNumSubdivisionsPerDim() const { return m_NX; }
virtual double getLocalCoordinate(index_t index, int dim) const;
virtual boost::python::tuple getGridParameters() const;
virtual escript::Data randomFill(const escript::DataTypes::ShapeType& shape,
const escript::FunctionSpace& what, long seed, const boost::python::tuple& filter) const;
virtual Assembler_ptr createAssembler(std::string type,
const DataMap& options) const;
virtual void interpolateAcross(escript::Data& target,
const escript::Data& source) const;
virtual bool probeInterpolationAcross(int, const escript::AbstractDomain&,
int) const;
const double *getLength() const { return m_length; }
protected:
virtual dim_t getNumNodes() const;
virtual dim_t getNumElements() const;
virtual dim_t getNumDOF() const;
#ifdef ESYS_MPI
virtual void balanceNeighbours(escript::Data& data, bool average) const;
#endif
virtual void assembleCoordinates(escript::Data& arg) const;
virtual void assembleGradient(escript::Data& out,
const escript::Data& in) const;
virtual void assembleIntegrate(std::vector<real_t>& integrals,
const escript::Data& arg) const;
virtual void assembleIntegrate(std::vector<cplx_t>& integrals,
const escript::Data& arg) const;
virtual void interpolateNodesOnElements(escript::Data& out,
const escript::Data& in,
bool reduced) const;
virtual void interpolateElementsOnNodes(escript::Data& out,
const escript::Data& in) const;
virtual dim_t getDofOfNode(dim_t node) const;
virtual void reduceElements(escript::Data& out, const escript::Data& in) const;
private:
template<typename Scalar>
void gradient_order2(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order3(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order4(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order5(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order6(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order7(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order8(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order9(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void gradient_order10(escript::Data&, const escript::Data&) const;
template<typename Scalar>
void reduction_order2(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order3(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order4(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order5(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order6(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order7(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order8(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order9(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void reduction_order10(const escript::Data&, escript::Data&) const;
template<typename Scalar>
void integral_order2(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order3(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order4(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order5(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order6(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order7(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order8(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order9(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void integral_order10(std::vector<Scalar>&, const escript::Data&) const;
template<typename Scalar>
void assembleIntegrateWorker(std::vector<Scalar>& integrals,
const escript::Data& arg) const;
template<typename Scalar>
void interpolateNodesOnElementsWorker(escript::Data& out,
const escript::Data& in,
bool reduced) const;
template<typename Scalar>
void interpolateElementsOnNodesWorker(escript::Data& out,
const escript::Data& in) const;
#ifdef ESYS_MPI
template<typename Scalar>
void balanceNeighboursWorker(escript::Data& data, bool average) const;
/* \brief
Sums the values across MPI overlaps
*/
template<typename Scalar>
void shareCorners(escript::Data& out, int rx, int ry) const;
/* \brief
Sums the values across MPI overlaps
*/
template<typename Scalar>
void shareSides(escript::Data& out, int rx, int ry) const;
/* \brief
Sums the values across MPI overlaps
*/
template<typename Scalar>
void shareVertical(escript::Data& out, int rx, int ry) const;
#endif
/* \brief
interpolates the non-corner point values of an element
from the corner values
*/
void interpolateFromCorners(escript::Data& out) const;
void populateSampleIds();
template<typename ValueType>
void readBinaryGridImpl(escript::Data& out, const std::string& filename,
const ReaderParameters& params) const;
#ifdef ESYS_HAVE_BOOST_IO
template<typename ValueType>
void readBinaryGridZippedImpl(escript::Data& out,
const std::string& filename, const ReaderParameters& params) const;
#endif
template<typename ValueType>
void writeBinaryGridImpl(const escript::Data& in,
const std::string& filename, int byteOrder) const;
dim_t findNode(const double *coords) const;
dim_t m_gNE[2];
double m_origin[2];
double m_length[2];
double m_dx[2];
int m_NX[2];
dim_t m_NE[2];
dim_t m_NN[2];
dim_t m_offset[2];
dim_t m_faceCount[4];
IndexVector m_dofId;
IndexVector m_nodeId;
IndexVector m_elementId;
// vector with first node id on each rank
IndexVector m_nodeDistribution;
#ifdef USE_RIPLEY
mutable RipleyCoupler *coupler;
#endif
friend class DefaultAssembler2D;
friend class WaveAssembler2D;
};
inline dim_t Rectangle::getDofOfNode(dim_t node) const
{
return m_nodeId[node];
}
inline dim_t Rectangle::getNumDataPointsGlobal() const
{
return (m_gNE[0]*m_order+1)*(m_gNE[1]*m_order+1);
}
inline double Rectangle::getLocalCoordinate(index_t index, int dim) const
{
ESYS_ASSERT(dim>=0 && dim<2, "'dim' out of bounds");
ESYS_ASSERT(index>=0 && index<m_NN[dim], "'index' out of bounds");
return m_origin[dim] //origin
+ m_dx[dim]*(m_offset[dim] + index/m_order //elements
+ point_locations[m_order-2][index%m_order]); //quads
}
inline boost::python::tuple Rectangle::getGridParameters() const
{
return boost::python::make_tuple(
boost::python::make_tuple(m_origin[0], m_origin[1]),
boost::python::make_tuple(m_dx[0], m_dx[1]),
boost::python::make_tuple(m_gNE[0], m_gNE[1]));
}
//protected
inline dim_t Rectangle::getNumDOF() const
{
return getNumNodes();
}
//protected
inline dim_t Rectangle::getNumNodes() const
{
return m_NN[0] * m_NN[1];
}
//protected
inline dim_t Rectangle::getNumElements() const
{
return m_NE[0]*m_NE[1];
}
} // end of namespace speckley
#endif // __SPECKLEY_RECTANGLE_H__
speckley::TagMap
std::map< std::string, int > TagMap
Definition: Speckley.h:63
speckley::readNcGrid
escript::Data readNcGrid(std::string filename, std::string varname, escript::FunctionSpace fs, const object &pyShape, double fill, const object &pyFirst, const object &pyNum, const object &pyMultiplier, const object &pyReverse)
Definition: speckleycpp.cpp:115
speckley::SpeckleyDomain::m_order
int m_order
element order (will be m_order + 1 quad points in each axis)
Definition: speckley/src/SpeckleyDomain.h:769
speckley::readBinaryGridFromZipped
escript::Data readBinaryGridFromZipped(std::string filename, escript::FunctionSpace fs, const object &pyShape, double fill, int byteOrder, int dataType, const object &pyFirst, const object &pyNum, const object &pyMultiplier, const object &pyReverse)
Definition: speckleycpp.cpp:86
speckley::Rectangle::getDofOfNode
virtual dim_t getDofOfNode(dim_t node) const
Definition: speckley/src/Rectangle.h:420
speckley::Rectangle::getNumDOF
virtual dim_t getNumDOF() const
returns the number of degrees of freedom per MPI rank
Definition: speckley/src/Rectangle.h:448
escript::FunctionSpace
Definition: FunctionSpace.h:49
speckley::DefaultAssembler2D
Definition: speckley/src/DefaultAssembler2D.h:39
speckley::probeInterpolationAcross
bool probeInterpolationAcross(int fsType_source, const escript::AbstractDomain &domain, int fsType_target, int dim)
Definition: CrossDomainCoupler.cpp:32
speckley
Definition: AbstractAssembler.cpp:19
speckley::Rectangle::getNumNodes
virtual dim_t getNumNodes() const
returns the number of nodes per MPI rank
Definition: speckley/src/Rectangle.h:454
speckley::readBinaryGrid
escript::Data readBinaryGrid(std::string filename, escript::FunctionSpace fs, const object &pyShape, double fill, int byteOrder, int dataType, const object &pyFirst, const object &pyNum, const object &pyMultiplier, const object &pyReverse)
Definition: speckleycpp.cpp:61
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
speckley::Rectangle::m_NN
dim_t m_NN[2]
number of nodes for this rank in each dimension
Definition: speckley/src/Rectangle.h:409
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
speckley::Rectangle::m_gNE
dim_t m_gNE[2]
total number of elements in each dimension
Definition: speckley/src/Rectangle.h:391
speckley::WaveAssembler2D
Definition: speckley/src/WaveAssembler2D.h:39
speckley::Rectangle::getLocalCoordinate
virtual double getLocalCoordinate(index_t index, int dim) const
returns the index'th coordinate value in given dimension for this rank
Definition: speckley/src/Rectangle.h:430
speckley::Rectangle::m_dx
double m_dx[2]
grid spacings / cell sizes of domain
Definition: speckley/src/Rectangle.h:400
speckley::Rectangle
Rectangle is the 2-dimensional implementation of a SpeckleyDomain.
Definition: speckley/src/Rectangle.h:47
speckley::RipleyCoupler
Definition: CrossDomainCoupler.h:43
speckley::Rectangle::getNumDataPointsGlobal
virtual dim_t getNumDataPointsGlobal() const
returns the number of data points summed across all MPI processes
Definition: speckley/src/Rectangle.h:425
escript::SubWorld_ptr
boost::shared_ptr< SubWorld > SubWorld_ptr
Definition: SubWorld.h:161
speckley::Rectangle::getNumElements
virtual dim_t getNumElements() const
returns the number of elements per MPI rank
Definition: speckley/src/Rectangle.h:460
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:88
speckley::Rectangle::m_origin
double m_origin[2]
origin of domain
Definition: speckley/src/Rectangle.h:394
speckley::Rectangle::m_nodeId
IndexVector m_nodeId
Definition: speckley/src/Rectangle.h:419
speckley::Rectangle::getGridParameters
virtual boost::python::tuple getGridParameters() const
returns the tuple (origin, spacing, number_of_elements)
Definition: speckley/src/Rectangle.h:439
speckley::ReaderParameters
Structure that wraps parameters for the grid reading routines.
Definition: speckley/src/SpeckleyDomain.h:66
escript::AbstractDomain
Base class for all escript domains.
Definition: AbstractDomain.h:64
speckley::Rectangle::m_NE
dim_t m_NE[2]
number of elements for this rank in each dimension including shared
Definition: speckley/src/Rectangle.h:406
speckley::IndexVector
std::vector< index_t > IndexVector
Definition: Speckley.h:61
Speckley_DLL_API
#define Speckley_DLL_API
Definition: speckley/src/system_dep.h:23
speckley::Rectangle::m_offset
dim_t m_offset[2]
first node on this rank is at (offset0,offset1) in global mesh
Definition: speckley/src/Rectangle.h:412
speckley::DataMap
std::map< std::string, escript::Data > DataMap
Definition: speckley/src/domainhelpers.h:39
ESYS_ASSERT
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false.
Definition: Assert.h:79
speckley::point_locations
const double point_locations[][11]
Definition: Speckley.h:88