escript  Revision_
MultiRectangle.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 #ifndef __RIPLEY_MULTIRECTANGLE_H__
19 #define __RIPLEY_MULTIRECTANGLE_H__
20 
21 #include <ripley/Rectangle.h>
22 
23 namespace ripley {
24 
30 {
31  template<class Scalar> friend class DefaultAssembler2D;
32  friend class WaveAssembler2D;
33  friend class LameAssembler2D;
34 public:
35 
43  MultiRectangle(dim_t n0, dim_t n1, double x0, double y0, double x1, double y1,
44  int d0=-1, int d1=-1,
45  const std::vector<double>& points = std::vector<double>(),
46  const std::vector<int>& tags = std::vector<int>(),
47  const TagMap& tagnamestonums = TagMap(),
49  unsigned int subdivisions = 1
50  );
51 
56  ~MultiRectangle();
57 
63  virtual void interpolateAcross(escript::Data& target,
64  const escript::Data& source) const;
65 
71  void validateInterpolationAcross(int fsType_source,
72  const escript::AbstractDomain& domain, int fsType_target) const;
73 
78  virtual std::string getDescription() const;
79 
83  virtual bool operator==(const escript::AbstractDomain& other) const;
84 
90  void dump(const std::string& filename) const;
91 
94  virtual void readNcGrid(escript::Data& out, std::string filename,
95  std::string varname, const ReaderParameters& params) const;
96 
99  virtual void readBinaryGrid(escript::Data& out, std::string filename,
100  const ReaderParameters& params) const;
101 
102  virtual void readBinaryGridFromZipped(escript::Data& out, std::string filename,
103  const ReaderParameters& params) const;
104 
107  virtual void writeBinaryGrid(const escript::Data& in,
108  std::string filename,
109  int byteOrder, int dataType) const;
110 
115  virtual unsigned int getNumSubdivisionsPerElement() const { return m_subdivisions; }
116 
122  virtual RankVector getOwnerVector(int fsType) const;
123 
124 protected:
125  virtual void interpolateNodesToNodesFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
126  virtual void interpolateNodesToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
127 
128  virtual void interpolateElementsToElementsCoarser(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
129  virtual void interpolateElementsToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
130 
131  virtual void interpolateReducedToElementsFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
132  virtual void interpolateReducedToReducedFiner(const escript::Data& source, escript::Data& target, const MultiRectangle& other) const;
133 #ifdef ESYS_HAVE_PASO
134  virtual paso::SystemMatrixPattern_ptr getPasoMatrixPattern(
135  bool reducedRowOrder,
136  bool reducedColOrder) const;
137 #endif
138  virtual index_t getFirstInDim(unsigned axis) const;
139  virtual void populateSampleIds();
140  virtual dim_t getNumDOFInAxis(unsigned axis) const;
141  virtual dim_t getNumDOF() const;
142  virtual void populateDofMap();
143 
144  virtual dim_t findNode(const double *coords) const;
145 
146 private:
147  mutable std::vector<IndexVector> m_colIndices;
148  mutable std::vector<IndexVector> m_rowIndices;
149  unsigned int m_subdivisions;
150 
151  template <typename S>
152  void interpolateNodesToNodesFinerWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
153  template <typename S>
154  void interpolateNodesToElementsFinerWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
155 
156  template <typename S>
157  void interpolateElementsToElementsCoarserWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
158  template <typename S>
159  void interpolateElementsToElementsFinerWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
160 
161  template <typename S>
162  void interpolateReducedToElementsFinerWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
163  template <typename S>
164  void interpolateReducedToReducedFinerWorker(const escript::Data& source, escript::Data& target, const MultiRectangle& other, S sentinel) const;
165 
166 
167 
168 };
169 
170 //protected
172 {
173  return getNumDOFInAxis(0)*getNumDOFInAxis(1);
174 }
175 
176 //protected
177 inline dim_t MultiRectangle::getNumDOFInAxis(unsigned axis) const
178 {
179  ESYS_ASSERT(axis < m_numDim, "Invalid axis");
180  dim_t res = m_ownNE[axis] + 1;
181  if (m_offset[axis] + m_NE[axis] < m_gNE[axis]) {
182  res--;
183  }
184  return res;
185 }
186 
187 //protected
189 {
190  return m_offset[axis] == 0 ? 0 : m_subdivisions;
191 }
192 
193 } // end of namespace ripley
194 
195 #endif // __RIPLEY_MULTIRECTANGLE_H__
196 
#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
#define S(_J_, _I_)
Definition: ShapeFunctions.cpp:122
Base class for all escript domains.
Definition: AbstractDomain.h:51
Data represents a collection of datapoints.
Definition: Data.h:64
Definition: ripley/src/DefaultAssembler2D.h:26
Definition: LameAssembler2D.h:26
Rectangle is the 2-dimensional implementation of a RipleyDomain.
Definition: MultiRectangle.h:30
virtual unsigned int getNumSubdivisionsPerElement() const
returns the number of times each root element has been subdivided
Definition: MultiRectangle.h:115
virtual dim_t getNumDOFInAxis(unsigned axis) const
Definition: MultiRectangle.h:177
virtual dim_t getNumDOF() const
returns the number of degrees of freedom per MPI rank
Definition: MultiRectangle.h:171
unsigned int m_subdivisions
Definition: MultiRectangle.h:149
virtual index_t getFirstInDim(unsigned axis) const
Definition: MultiRectangle.h:188
std::vector< IndexVector > m_colIndices
Definition: MultiRectangle.h:147
std::vector< IndexVector > m_rowIndices
Definition: MultiRectangle.h:148
Rectangle is the 2-dimensional implementation of a RipleyDomain.
Definition: ripley/src/Rectangle.h:35
dim_t m_offset[2]
first node on this rank is at (offset0,offset1) in global mesh
Definition: ripley/src/Rectangle.h:318
dim_t m_ownNE[2]
number of own elements for this rank in each dimension
Definition: ripley/src/Rectangle.h:312
dim_t m_NE[2]
number of elements for this rank in each dimension including shared
Definition: ripley/src/Rectangle.h:309
dim_t m_gNE[2]
total number of elements in each dimension
Definition: ripley/src/Rectangle.h:294
int m_numDim
Definition: ripley/src/RipleyDomain.h:771
Definition: ripley/src/WaveAssembler2D.h:26
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
boost::shared_ptr< SubWorld > SubWorld_ptr
Definition: SubWorld.h:147
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition: SystemMatrixPattern.h:40
Definition: ripley/src/AbstractAssembler.h:26
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
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
std::map< std::string, int > TagMap
Definition: Ripley.h:47
std::vector< int > RankVector
Definition: Ripley.h:46
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
#define RIPLEY_DLL_API
Definition: ripley/src/system_dep.h:21
Structure that wraps parameters for the grid reading routines.
Definition: ripley/src/RipleyDomain.h:70