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

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

  ViewVC Help
Powered by ViewVC 1.1.26