ripley/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 __RIPLEY_RECTANGLE_H__
#define __RIPLEY_RECTANGLE_H__
#ifdef _WIN32 // for M_1_PI
#define _USE_MATH_DEFINES
#include <math.h>
#endif
#include <ripley/RipleyDomain.h>
namespace ripley {
class RIPLEY_DLL_API Rectangle: public RipleyDomain
{
template<class Scalar> friend class DefaultAssembler2D;
friend class WaveAssembler2D;
friend class LameAssembler2D;
public:
Rectangle(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 fsType, 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;
const double *getLength() const { return m_length; }
const double *getElementLength() const { return m_dx; }
virtual RankVector getOwnerVector(int fsType) const;
protected:
virtual dim_t getNumNodes() const;
virtual dim_t getNumElements() const;
virtual dim_t getNumFaceElements() const;
virtual dim_t getNumDOF() const;
virtual dim_t getNumDOFInAxis(unsigned axis) const;
virtual index_t getFirstInDim(unsigned axis) const;
virtual IndexVector getDiagonalIndices(bool upperOnly) const;
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 std::vector<IndexVector> getConnections(bool includeShared=false) const;
#ifdef ESYS_HAVE_TRILINOS
virtual esys_trilinos::const_TrilinosGraph_ptr getTrilinosGraph() const;
#endif
#ifdef ESYS_HAVE_PASO
virtual paso::SystemMatrixPattern_ptr getPasoMatrixPattern(
bool reducedRowOrder, bool reducedColOrder) const;
#endif
virtual void interpolateNodesOnElements(escript::Data& out,
const escript::Data& in, bool reduced) const;
virtual void interpolateNodesOnFaces(escript::Data& out,
const escript::Data& in,
bool reduced) const;
virtual void nodesToDOF(escript::Data& out, const escript::Data& in) const;
virtual dim_t getDofOfNode(dim_t node) const;
virtual void populateSampleIds();
virtual void populateDofMap();
template<typename Scalar>
void assembleGradientImpl(escript::Data& out,
const escript::Data& in) const;
template<typename Scalar>
void addToMatrixAndRHS(escript::AbstractSystemMatrix* S, escript::Data& F,
const std::vector<Scalar>& EM_S, const std::vector<Scalar>& EM_F,
bool addS, bool addF, index_t firstNode, int nEq=1, int nComp=1) const;
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;
virtual dim_t findNode(const double *coords) const;
escript::Data randomFillWorker(const escript::DataTypes::ShapeType& shape,
long seed, const boost::python::tuple& filter) 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_ownNE[2];
dim_t m_NN[2];
dim_t m_offset[2];
dim_t m_faceCount[4];
IndexVector m_faceOffset;
IndexVector m_dofId;
IndexVector m_nodeId;
IndexVector m_elementId;
IndexVector m_faceId;
// vector with first node id on each rank
IndexVector m_nodeDistribution;
// vector that maps each node to a DOF index (used for the coupler)
IndexVector m_dofMap;
#ifdef ESYS_HAVE_PASO
// the Paso System Matrix pattern
mutable paso::SystemMatrixPattern_ptr m_pattern;
#endif
#ifdef ESYS_HAVE_TRILINOS
mutable esys_trilinos::const_TrilinosGraph_ptr m_graph;
#endif
private:
template<typename Scalar>
void assembleIntegrateImpl(std::vector<Scalar>& integrals, const escript::Data& arg) const;
template <typename S>
void interpolateNodesOnElementsWorker(escript::Data& out,
const escript::Data& in, bool reduced, S sentinel) const;
template <typename S>
void interpolateNodesOnFacesWorker(escript::Data& out,
const escript::Data& in,
bool reduced, S sentinel) const;
};
inline dim_t Rectangle::getDofOfNode(dim_t node) const
{
return m_dofMap[node];
}
inline dim_t Rectangle::getNumDataPointsGlobal() const
{
return (m_gNE[0]+1)*(m_gNE[1]+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]+m_dx[dim]*(m_offset[dim]+index);
}
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 (m_gNE[0]+1)/m_NX[0]*(m_gNE[1]+1)/m_NX[1];
}
//protected
inline dim_t Rectangle::getNumDOFInAxis(unsigned axis) const
{
ESYS_ASSERT(axis < m_numDim, "Invalid axis");
return (m_gNE[axis]+1)/m_NX[axis];
}
//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];
}
//protected
inline dim_t Rectangle::getNumFaceElements() const
{
return m_faceCount[0] + m_faceCount[1] + m_faceCount[2] + m_faceCount[3];
}
//protected
inline index_t Rectangle::getFirstInDim(unsigned axis) const
{
return m_offset[axis] == 0 ? 0 : 1;
}
} // end of namespace ripley
#endif // __RIPLEY_RECTANGLE_H__
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
S
#define S(_J_, _I_)
Definition: ShapeFunctions.cpp:122
escript::AbstractDomain
Base class for all escript domains.
Definition: AbstractDomain.h:51
escript::AbstractSystemMatrix
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:44
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
escript::FunctionSpace
Definition: FunctionSpace.h:36
ripley::DefaultAssembler2D
Definition: ripley/src/DefaultAssembler2D.h:26
ripley::LameAssembler2D
Definition: LameAssembler2D.h:26
ripley::Rectangle
Rectangle is the 2-dimensional implementation of a RipleyDomain.
Definition: ripley/src/Rectangle.h:35
ripley::Rectangle::getLength
const double * getLength() const
returns the lengths of the domain
Definition: ripley/src/Rectangle.h:211
ripley::Rectangle::getNumNodes
virtual dim_t getNumNodes() const
returns the number of nodes per MPI rank
Definition: ripley/src/Rectangle.h:401
ripley::Rectangle::getNumFaceElements
virtual dim_t getNumFaceElements() const
returns the number of face elements on current MPI rank
Definition: ripley/src/Rectangle.h:413
ripley::Rectangle::m_faceCount
dim_t m_faceCount[4]
number of face elements per edge (left, right, bottom, top)
Definition: ripley/src/Rectangle.h:321
ripley::Rectangle::getNumDOF
virtual dim_t getNumDOF() const
returns the number of degrees of freedom per MPI rank
Definition: ripley/src/Rectangle.h:388
ripley::Rectangle::m_origin
double m_origin[2]
origin of domain
Definition: ripley/src/Rectangle.h:297
ripley::Rectangle::m_NN
dim_t m_NN[2]
number of nodes for this rank in each dimension
Definition: ripley/src/Rectangle.h:315
ripley::Rectangle::m_offset
dim_t m_offset[2]
first node on this rank is at (offset0,offset1) in global mesh
Definition: ripley/src/Rectangle.h:318
ripley::Rectangle::m_faceOffset
IndexVector m_faceOffset
Definition: ripley/src/Rectangle.h:325
ripley::Rectangle::m_dofId
IndexVector m_dofId
vector of sample reference identifiers
Definition: ripley/src/Rectangle.h:328
ripley::Rectangle::randomFill
virtual escript::Data randomFill(const escript::DataTypes::ShapeType &shape, const escript::FunctionSpace &what, long seed, const boost::python::tuple &filter) const
returns a Data object filled with random data passed through filter.
ripley::Rectangle::getNumDOFInAxis
virtual dim_t getNumDOFInAxis(unsigned axis) const
Definition: ripley/src/Rectangle.h:394
ripley::Rectangle::m_NX
int m_NX[2]
number of spatial subdivisions
Definition: ripley/src/Rectangle.h:306
ripley::Rectangle::getNumElements
virtual dim_t getNumElements() const
returns the number of elements per MPI rank
Definition: ripley/src/Rectangle.h:407
ripley::Rectangle::getNumDataPointsGlobal
virtual dim_t getNumDataPointsGlobal() const
returns the number of data points summed across all MPI processes
Definition: ripley/src/Rectangle.h:367
ripley::Rectangle::m_nodeId
IndexVector m_nodeId
Definition: ripley/src/Rectangle.h:329
ripley::Rectangle::getElementLength
const double * getElementLength() const
returns the lengths of an element
Definition: ripley/src/Rectangle.h:217
ripley::Rectangle::getNodeDistribution
virtual IndexVector getNodeDistribution() const
returns the node distribution vector
Definition: ripley/src/Rectangle.h:172
ripley::Rectangle::getNumNodesPerDim
virtual const dim_t * getNumNodesPerDim() const
returns the number of nodes per MPI rank in each dimension
Definition: ripley/src/Rectangle.h:153
ripley::Rectangle::m_NE
dim_t m_NE[2]
number of elements for this rank in each dimension including shared
Definition: ripley/src/Rectangle.h:309
ripley::Rectangle::m_dx
double m_dx[2]
grid spacings / cell sizes of domain
Definition: ripley/src/Rectangle.h:303
ripley::Rectangle::m_dofMap
IndexVector m_dofMap
Definition: ripley/src/Rectangle.h:337
ripley::Rectangle::m_elementId
IndexVector m_elementId
Definition: ripley/src/Rectangle.h:330
ripley::Rectangle::getDofOfNode
virtual dim_t getDofOfNode(dim_t node) const
Definition: ripley/src/Rectangle.h:362
ripley::Rectangle::getFirstInDim
virtual index_t getFirstInDim(unsigned axis) const
Definition: ripley/src/Rectangle.h:419
ripley::Rectangle::getLocalCoordinate
virtual double getLocalCoordinate(index_t index, int dim) const
returns the index'th coordinate value in given dimension for this rank
Definition: ripley/src/Rectangle.h:372
ripley::Rectangle::m_gNE
dim_t m_gNE[2]
total number of elements in each dimension
Definition: ripley/src/Rectangle.h:294
ripley::Rectangle::getNumSubdivisionsPerDim
virtual const int * getNumSubdivisionsPerDim() const
returns the number of spatial subdivisions in each dimension
Definition: ripley/src/Rectangle.h:178
ripley::Rectangle::getGridParameters
virtual boost::python::tuple getGridParameters() const
returns the tuple (origin, spacing, number_of_elements)
Definition: ripley/src/Rectangle.h:379
ripley::Rectangle::m_faceId
IndexVector m_faceId
Definition: ripley/src/Rectangle.h:331
ripley::Rectangle::m_nodeDistribution
IndexVector m_nodeDistribution
Definition: ripley/src/Rectangle.h:334
ripley::Rectangle::getNumElementsPerDim
virtual const dim_t * getNumElementsPerDim() const
returns the number of elements per MPI rank in each dimension
Definition: ripley/src/Rectangle.h:159
ripley::Rectangle::getNumFacesPerBoundary
virtual const dim_t * getNumFacesPerBoundary() const
returns the number of face elements in the order (left,right,bottom,top) on current MPI rank
Definition: ripley/src/Rectangle.h:166
ripley::RipleyDomain
RipleyDomain extends the AbstractContinuousDomain interface for the Ripley library and is the base cl...
Definition: ripley/src/RipleyDomain.h:103
ripley::RipleyDomain::m_numDim
int m_numDim
Definition: ripley/src/RipleyDomain.h:771
ripley::WaveAssembler2D
Definition: ripley/src/WaveAssembler2D.h:26
escript::DataTypes::ShapeType
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:44
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:66
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:61
escript::SubWorld_ptr
boost::shared_ptr< SubWorld > SubWorld_ptr
Definition: SubWorld.h:147
paso::SystemMatrixPattern_ptr
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition: SystemMatrixPattern.h:40
ripley
Definition: ripley/src/AbstractAssembler.h:26
ripley::IndexVector
std::vector< index_t > IndexVector
Definition: Ripley.h:44
ripley::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: ripleycpp.cpp:63
ripley::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: ripleycpp.cpp:117
ripley::TagMap
std::map< std::string, int > TagMap
Definition: Ripley.h:47
ripley::RankVector
std::vector< int > RankVector
Definition: Ripley.h:46
ripley::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: ripleycpp.cpp:88
ripley::DataMap
std::map< std::string, escript::Data > DataMap
Definition: ripley/src/domainhelpers.h:25
RIPLEY_DLL_API
#define RIPLEY_DLL_API
Definition: ripley/src/system_dep.h:21
ripley::ReaderParameters
Structure that wraps parameters for the grid reading routines.
Definition: ripley/src/RipleyDomain.h:70