/[escript]/trunk/ripley/src/MultiRectangle.h
ViewVC logotype

Contents of /trunk/ripley/src/MultiRectangle.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6141 - (show annotations)
Wed Apr 6 03:51:30 2016 UTC (2 years, 4 months ago) by caltinay
File MIME type: text/plain
File size: 5874 byte(s)
more namespacing of defines.

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
24 /**
25 \brief
26 Rectangle is the 2-dimensional implementation of a RipleyDomain.
27 */
28 class RIPLEY_DLL_API MultiRectangle: public Rectangle
29 {
30 friend class DefaultAssembler2D;
31 friend class WaveAssembler2D;
32 friend class LameAssembler2D;
33 public:
34
35 /**
36 \brief creates a rectangular mesh with n0 x n1 elements over the
37 rectangle [x0,x1] x [y0,y1].
38 \param n0,n1 number of elements in each dimension
39 \param x0,y0,x1,y1 coordinates of bottom-left and top-right corners
40 \param d0,d1 number of subdivisions in each dimension
41 */
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(),
47 escript::SubWorld_ptr w=escript::SubWorld_ptr(),
48 unsigned int subdivisions = 1
49 );
50
51 /**
52 \brief
53 Destructor.
54 */
55 ~MultiRectangle();
56
57 /**
58 \brief
59 interpolates data given on source onto target where source and target
60 are given on different domains
61 */
62 virtual void interpolateAcross(escript::Data& target,
63 const escript::Data& source) const;
64
65 /**
66 \brief
67 Checks that the given interpolation is possible, throw RipleyExceptions
68 if not
69 */
70 void validateInterpolationAcross(int fsType_source,
71 const escript::AbstractDomain& domain, int fsType_target) const;
72
73 /**
74 \brief
75 returns a description for this domain
76 */
77 virtual std::string getDescription() const;
78
79 /**
80 \brief equality operator
81 */
82 virtual bool operator==(const escript::AbstractDomain& other) const;
83
84 /**
85 \brief
86 dumps the mesh to a file with the given name
87 \param filename The name of the output file
88 */
89 void dump(const std::string& filename) const;
90
91 /**
92 */
93 virtual void readNcGrid(escript::Data& out, std::string filename,
94 std::string varname, const ReaderParameters& params) const;
95
96 /**
97 */
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
104 /**
105 */
106 virtual void writeBinaryGrid(const escript::Data& in,
107 std::string filename,
108 int byteOrder, int dataType) const;
109
110 /**
111 \brief
112 returns the number of times each root element has been subdivided
113 */
114 virtual unsigned int getNumSubdivisionsPerElement() const { return m_subdivisions; }
115
116 /**
117 \brief
118 returns a vector of rank numbers where vec[i]=n means that rank n
119 'owns' element/face element i.
120 */
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 virtual paso::SystemMatrixPattern_ptr getPasoMatrixPattern(
133 bool reducedRowOrder,
134 bool reducedColOrder) const;
135 virtual index_t getFirstInDim(unsigned axis) const;
136 virtual void populateSampleIds();
137 virtual dim_t getNumDOFInAxis(unsigned axis) const;
138 virtual dim_t getNumDOF() const;
139 virtual void populateDofMap();
140
141 virtual dim_t findNode(const double *coords) const;
142
143 private:
144 mutable std::vector<IndexVector> m_colIndices;
145 mutable std::vector<IndexVector> m_rowIndices;
146 unsigned int m_subdivisions;
147 };
148
149 //protected
150 inline dim_t MultiRectangle::getNumDOF() const
151 {
152 return getNumDOFInAxis(0)*getNumDOFInAxis(1);
153 }
154
155 //protected
156 inline dim_t MultiRectangle::getNumDOFInAxis(unsigned axis) const
157 {
158 ESYS_ASSERT(axis < m_numDim, "Invalid axis");
159 dim_t res = m_ownNE[axis] + 1;
160 if (m_offset[axis] + m_NE[axis] < m_gNE[axis]) {
161 res--;
162 }
163 return res;
164 }
165
166 //protected
167 index_t MultiRectangle::getFirstInDim(unsigned axis) const
168 {
169 return m_offset[axis] == 0 ? 0 : m_subdivisions;
170 }
171
172 } // end of namespace ripley
173
174 #endif // __RIPLEY_MULTIRECTANGLE_H__
175

  ViewVC Help
Powered by ViewVC 1.1.26