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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4657 - (show annotations)
Thu Feb 6 06:12:20 2014 UTC (5 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 10240 byte(s)
I changed some files.
Updated copyright notices, added GeoComp.



1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
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_RECTANGLE_H__
18 #define __RIPLEY_RECTANGLE_H__
19
20 #include <ripley/RipleyDomain.h>
21
22 struct Paso_Connector;
23
24 namespace ripley {
25
26 /**
27 \brief
28 Rectangle is the 2-dimensional implementation of a RipleyDomain.
29 */
30 class RIPLEY_DLL_API Rectangle: public RipleyDomain
31 {
32 public:
33
34 /**
35 \brief creates a rectangular mesh with n0 x n1 elements over the
36 rectangle [x0,x1] x [y0,y1].
37 \param n0,n1 number of elements in each dimension
38 \param x0,y0,x1,y1 coordinates of bottom-left and top-right corners
39 \param d0,d1 number of subdivisions in each dimension
40 */
41 Rectangle(int n0, int n1, double x0, double y0, double x1, double y1,
42 int d0=-1, int d1=-1,
43 const std::vector<double>& points = std::vector<double>(),
44 const std::vector<int>& tags = std::vector<int>(),
45 const simap_t& tagnamestonums = simap_t());
46
47 /**
48 \brief
49 Destructor.
50 */
51 ~Rectangle();
52
53 /**
54 \brief
55 returns a description for this domain
56 */
57 virtual std::string getDescription() const;
58
59 /**
60 \brief equality operator
61 */
62 virtual bool operator==(const escript::AbstractDomain& other) const;
63
64 /**
65 \brief
66 dumps the mesh to a file with the given name
67 \param filename The name of the output file
68 */
69 void dump(const std::string& filename) const;
70
71 /**
72 */
73 virtual void readNcGrid(escript::Data& out, std::string filename,
74 std::string varname, const ReaderParameters& params) const;
75
76 /**
77 */
78 virtual void readBinaryGrid(escript::Data& out, std::string filename,
79 const ReaderParameters& params) const;
80
81 /**
82 */
83 virtual void writeBinaryGrid(const escript::Data& in,
84 std::string filename,
85 int byteOrder, int dataType) const;
86
87 /**
88 \brief
89 returns the array of reference numbers for a function space type
90 \param fsType The function space type
91 */
92 const int* borrowSampleReferenceIDs(int fsType) const;
93
94 /**
95 \brief
96 returns true if this rank owns the sample id.
97 */
98 virtual bool ownSample(int fs_code, index_t id) const;
99
100 /**
101 \brief
102 copies the surface normals at data points into out. The actual function
103 space to be considered is defined by out. out has to be defined on this
104 domain.
105 */
106 virtual void setToNormal(escript::Data& out) const;
107
108 /**
109 \brief
110 copies the size of samples into out. The actual function space to be
111 considered is defined by out. out has to be defined on this domain.
112 */
113 virtual void setToSize(escript::Data& out) const;
114
115 /**
116 \brief
117 returns the number of data points summed across all MPI processes
118 */
119 virtual int getNumDataPointsGlobal() const;
120
121 /**
122 \brief
123 writes information about the mesh to standard output
124 \param full whether to print additional data
125 */
126 virtual void Print_Mesh_Info(const bool full=false) const;
127
128 /**
129 \brief
130 returns the number of nodes per MPI rank in each dimension
131 */
132 virtual const int* getNumNodesPerDim() const { return m_NN; }
133
134 /**
135 \brief
136 returns the number of elements per MPI rank in each dimension
137 */
138 virtual const int* getNumElementsPerDim() const { return m_NE; }
139
140 /**
141 \brief
142 returns the number of face elements in the order
143 (left,right,bottom,top) on current MPI rank
144 */
145 virtual const int* getNumFacesPerBoundary() const { return m_faceCount; }
146
147 /**
148 \brief
149 returns the node distribution vector
150 */
151 virtual IndexVector getNodeDistribution() const { return m_nodeDistribution; }
152
153 /**
154 \brief
155 returns the number of spatial subdivisions in each dimension
156 */
157 virtual const int* getNumSubdivisionsPerDim() const { return m_NX; }
158
159 /**
160 \brief
161 returns the index'th coordinate value in given dimension for this rank
162 */
163 virtual double getLocalCoordinate(int index, int dim) const;
164
165 /**
166 \brief
167 returns the tuple (origin, spacing, number_of_elements)
168 */
169 virtual boost::python::tuple getGridParameters() const;
170
171 /**
172 * \brief
173 Returns a Data object filled with random data passed through filter.
174 */
175 virtual escript::Data randomFill(long seed, const boost::python::tuple& filter) const;
176
177 /**
178 \brief
179 Sets the assembler to a custom/specific assembler.
180 */
181 virtual void setAssembler(std::string type, std::map<std::string, escript::Data> options);
182
183
184 protected:
185 virtual dim_t getNumNodes() const;
186 virtual dim_t getNumElements() const;
187 virtual dim_t getNumFaceElements() const;
188 virtual dim_t getNumDOF() const;
189 virtual dim_t insertNeighbourNodes(IndexVector& index, index_t node) const;
190 virtual void assembleCoordinates(escript::Data& arg) const;
191 virtual void assembleGradient(escript::Data& out,
192 const escript::Data& in) const;
193 virtual void assembleIntegrate(DoubleVector& integrals,
194 const escript::Data& arg) const;
195 virtual Paso_SystemMatrixPattern* getPattern(bool reducedRowOrder, bool reducedColOrder) const;
196 virtual void interpolateNodesOnElements(escript::Data& out,
197 const escript::Data& in, bool reduced) const;
198 virtual void interpolateNodesOnFaces(escript::Data& out,
199 const escript::Data& in,
200 bool reduced) const;
201 virtual void nodesToDOF(escript::Data& out, const escript::Data& in) const;
202 virtual void dofToNodes(escript::Data& out, const escript::Data& in) const;
203 virtual int getDofOfNode(int node) const;
204
205 private:
206 void populateSampleIds();
207 void createPattern();
208 void addToMatrixAndRHS(Paso_SystemMatrix* S, escript::Data& F,
209 const DoubleVector& EM_S, const DoubleVector& EM_F,
210 bool addS, bool addF, int firstNode, int nEq=1, int nComp=1) const;
211
212 template<typename ValueType>
213 void readBinaryGridImpl(escript::Data& out, const std::string& filename,
214 const ReaderParameters& params) const;
215
216 template<typename ValueType>
217 void writeBinaryGridImpl(const escript::Data& in,
218 const std::string& filename, int byteOrder) const;
219
220 int findNode(const double *coords) const;
221
222 /// total number of elements in each dimension
223 dim_t m_gNE[2];
224
225 /// origin of domain
226 double m_origin[2];
227
228 /// side lengths of domain
229 double m_length[2];
230
231 /// grid spacings / cell sizes of domain
232 double m_dx[2];
233
234 /// number of spatial subdivisions
235 dim_t m_NX[2];
236
237 /// number of elements for this rank in each dimension including shared
238 dim_t m_NE[2];
239
240 /// number of own elements for this rank in each dimension
241 dim_t m_ownNE[2];
242
243 /// number of nodes for this rank in each dimension
244 dim_t m_NN[2];
245
246 /// first node on this rank is at (offset0,offset1) in global mesh
247 dim_t m_offset[2];
248
249 /// number of face elements per edge (left, right, bottom, top)
250 int m_faceCount[4];
251
252 /// faceOffset[i]=-1 if face i is not an external face, otherwise it is
253 /// the index of that face (where i: 0=left, 1=right, 2=bottom, 3=top)
254 IndexVector m_faceOffset;
255
256 /// vector of sample reference identifiers
257 IndexVector m_dofId;
258 IndexVector m_nodeId;
259 IndexVector m_elementId;
260 IndexVector m_faceId;
261
262 // vector with first node id on each rank
263 IndexVector m_nodeDistribution;
264
265 // vector that maps each node to a DOF index (used for the coupler)
266 IndexVector m_dofMap;
267
268 // Paso connector used by the system matrix and to interpolate DOF to
269 // nodes
270 Paso_Connector* m_connector;
271
272 // the Paso System Matrix pattern
273 Paso_SystemMatrixPattern* m_pattern;
274
275 friend class DefaultAssembler2D;
276 friend class WaveAssembler2D;
277 };
278
279 ////////////////////////////// inline methods ////////////////////////////////
280 inline int Rectangle::getDofOfNode(int node) const {
281 return m_dofMap[node];
282 }
283
284 inline int Rectangle::getNumDataPointsGlobal() const
285 {
286 return (m_gNE[0]+1)*(m_gNE[1]+1);
287 }
288
289 inline double Rectangle::getLocalCoordinate(int index, int dim) const
290 {
291 EsysAssert((dim>=0 && dim<2), "'dim' out of bounds");
292 EsysAssert((index>=0 && index<m_NN[dim]), "'index' out of bounds");
293 return m_origin[dim]+m_dx[dim]*(m_offset[dim]+index);
294 }
295
296 inline boost::python::tuple Rectangle::getGridParameters() const
297 {
298 return boost::python::make_tuple(
299 boost::python::make_tuple(m_origin[0], m_origin[1]),
300 boost::python::make_tuple(m_dx[0], m_dx[1]),
301 boost::python::make_tuple(m_gNE[0], m_gNE[1]));
302 }
303
304 inline Paso_SystemMatrixPattern* Rectangle::getPattern(bool reducedRowOrder,
305 bool reducedColOrder) const
306 {
307 // TODO: reduced
308 return m_pattern;
309 }
310
311
312 //protected
313 inline dim_t Rectangle::getNumDOF() const
314 {
315 return (m_gNE[0]+1)/m_NX[0]*(m_gNE[1]+1)/m_NX[1];
316 }
317
318 //protected
319 inline dim_t Rectangle::getNumNodes() const
320 {
321 return m_NN[0]*m_NN[1];
322 }
323
324 //protected
325 inline dim_t Rectangle::getNumElements() const
326 {
327 return m_NE[0]*m_NE[1];
328 }
329
330 //protected
331 inline dim_t Rectangle::getNumFaceElements() const
332 {
333 return m_faceCount[0] + m_faceCount[1] + m_faceCount[2] + m_faceCount[3];
334 }
335
336
337 } // end of namespace ripley
338
339 #endif // __RIPLEY_RECTANGLE_H__
340

  ViewVC Help
Powered by ViewVC 1.1.26