escript  Revision_
MultiRectangle.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 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 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 #ifndef __RIPLEY_MULTIRECTANGLE_H__
18 #define __RIPLEY_MULTIRECTANGLE_H__
19 
20 #include <ripley/Rectangle.h>
21 
22 namespace ripley {
23 
29 {
30  template<class Scalar> friend class DefaultAssembler2D;
31  friend class WaveAssembler2D;
32  friend class LameAssembler2D;
33 public:
34 
42  MultiRectangle(dim_t n0, dim_t n1, double x0, double y0, double x1, double y1,
43  int d0=-1, int d1=-1,
44  const std::vector<double>& points = std::vector<double>(),
45  const std::vector<int>& tags = std::vector<int>(),
46  const TagMap& tagnamestonums = TagMap(),
48  unsigned int subdivisions = 1
49  );
50 
55  ~MultiRectangle();
56 
62  virtual void interpolateAcross(escript::Data& target,
63  const escript::Data& source) const;
64 
70  void validateInterpolationAcross(int fsType_source,
71  const escript::AbstractDomain& domain, int fsType_target) const;
72 
77  virtual std::string getDescription() const;
78 
82  virtual bool operator==(const escript::AbstractDomain& other) const;
83 
89  void dump(const std::string& filename) const;
90 
93  virtual void readNcGrid(escript::Data& out, std::string filename,
94  std::string varname, const ReaderParameters& params) const;
95 
98  virtual void readBinaryGrid(escript::Data& out, std::string filename,
99  const ReaderParameters& params) const;
100 
101  virtual void readBinaryGridFromZipped(escript::Data& out, std::string filename,
102  const ReaderParameters& params) const;
103 
106  virtual void writeBinaryGrid(const escript::Data& in,
107  std::string filename,
108  int byteOrder, int dataType) const;
109 
114  virtual unsigned int getNumSubdivisionsPerElement() const { return m_subdivisions; }
115 
121  virtual RankVector getOwnerVector(int fsType) const;
122 
123 protected:
124  virtual void interpolateNodesToNodesFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
125  virtual void interpolateNodesToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
126 
127  virtual void interpolateElementsToElementsCoarser(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
128  virtual void interpolateElementsToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
129 
130  virtual void interpolateReducedToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
131  virtual void interpolateReducedToReducedFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
132 #ifdef ESYS_HAVE_PASO
133  virtual paso::SystemMatrixPattern_ptr getPasoMatrixPattern(
134  bool reducedRowOrder,
135  bool reducedColOrder) const;
136 #endif
137  virtual index_t getFirstInDim(unsigned axis) const;
138  virtual void populateSampleIds();
139  virtual dim_t getNumDOFInAxis(unsigned axis) const;
140  virtual dim_t getNumDOF() const;
141  virtual void populateDofMap();
142 
143  virtual dim_t findNode(const double *coords) const;
144 
145 private:
146  mutable std::vector<IndexVector> m_colIndices;
147  mutable std::vector<IndexVector> m_rowIndices;
148  unsigned int m_subdivisions;
149 };
150 
151 //protected
153 {
154  return getNumDOFInAxis(0)*getNumDOFInAxis(1);
155 }
156 
157 //protected
158 inline dim_t MultiRectangle::getNumDOFInAxis(unsigned axis) const
159 {
160  ESYS_ASSERT(axis < m_numDim, "Invalid axis");
161  dim_t res = m_ownNE[axis] + 1;
162  if (m_offset[axis] + m_NE[axis] < m_gNE[axis]) {
163  res--;
164  }
165  return res;
166 }
167 
168 //protected
170 {
171  return m_offset[axis] == 0 ? 0 : m_subdivisions;
172 }
173 
174 } // end of namespace ripley
175 
176 #endif // __RIPLEY_MULTIRECTANGLE_H__
177 
Rectangle is the 2-dimensional implementation of a RipleyDomain.
Definition: MultiRectangle.h:28
std::vector< int > RankVector
Definition: Ripley.h:45
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:116
Definition: ripley/src/WaveAssembler2D.h:24
Definition: LameAssembler2D.h:24
std::vector< IndexVector > m_rowIndices
Definition: MultiRectangle.h:147
virtual dim_t getNumDOF() const
returns the number of degrees of freedom per MPI rank
Definition: MultiRectangle.h:152
Definition: ripley/src/DefaultAssembler2D.h:24
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:62
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition: SystemMatrixPattern.h:39
std::map< std::string, int > TagMap
Definition: Ripley.h:46
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
Rectangle is the 2-dimensional implementation of a RipleyDomain.
Definition: ripley/src/Rectangle.h:28
virtual dim_t getNumDOFInAxis(unsigned axis) const
Definition: MultiRectangle.h:158
boost::shared_ptr< SubWorld > SubWorld_ptr
Definition: SubWorld.h:146
Structure that wraps parameters for the grid reading routines.
Definition: ripley/src/RipleyDomain.h:68
virtual index_t getFirstInDim(unsigned axis) const
Definition: MultiRectangle.h:169
Data represents a collection of datapoints.
Definition: Data.h:63
virtual unsigned int getNumSubdivisionsPerElement() const
returns the number of times each root element has been subdivided
Definition: MultiRectangle.h:114
Definition: ripley/src/AbstractAssembler.h:25
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:87
unsigned int m_subdivisions
Definition: MultiRectangle.h:148
Base class for all escript domains.
Definition: AbstractDomain.h:45
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false...
Definition: Assert.h:78
#define RIPLEY_DLL_API
Definition: ripley/src/system_dep.h:20
index_t dim_t
Definition: DataTypes.h:64
std::vector< IndexVector > m_colIndices
Definition: MultiRectangle.h:146