/[escript]/trunk/bruce/src/Bruce.h
ViewVC logotype

Contents of /trunk/bruce/src/Bruce.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (11 years, 10 months ago) by ksteube
File MIME type: text/plain
File size: 8363 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

1
2 /* $Id$ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 #if !defined bruce_Bruce_20050829_H
17 #define bruce_Bruce_20050829_H
18 #include "system_dep.h"
19 #include "escript/AbstractDomain.h"
20 #include "escript/AbstractContinuousDomain.h"
21 #include "escript/FunctionSpace.h"
22 #include "escript/Data.h"
23
24
25 #include <string>
26 #include <vector>
27
28 namespace bruce {
29
30 /**
31 \brief
32 Bruce implements a structured AbstractContinuousDomain.
33
34 Description:
35 Bruce implements a structured AbstractContinuousDomain.
36 */
37
38 class Bruce : public escript::AbstractContinuousDomain {
39
40 public:
41
42 //
43 // Codes for function space types supported
44 BRUCE_DLL_API
45 static const int ContinuousFunction; // data is on the nodes
46 BRUCE_DLL_API
47 static const int Function; // data is on the cell centres
48
49 //
50 // Type of FunctionSpaceNamesMap
51 typedef std::map<int, std::string> FunctionSpaceNamesMapType;
52
53 //
54 // Types for the dimension vectors
55 typedef std::vector<double> DimVec;
56
57 /**
58 \brief
59 Default constructor for Bruce.
60
61 Description:
62 Default constructor for Bruce.
63 Creates a null Bruce object.
64 */
65 BRUCE_DLL_API
66 Bruce();
67
68 /**
69 \brief
70 Constructor for Bruce.
71
72 Description:
73 Constructor for Bruce.
74
75 The point "origin" specifies the location of the origin
76 of the domain specified by this object. The dimensionality of this
77 point determines the dimensionality of the space the domain occupies.
78
79 The vectors v0,v1,v2 specify the axis in
80 of the domain of this Bruce object. If v2 is an empty vector, this
81 object is a two dimensional domain. If v1 is also an empty vector,
82 this object is a one dimensional domain. If v0 is also an empty
83 vector, this is a point domain.
84
85 The integers n0,n1,n2 specify the dumber of data-points along each
86 axis in the domain.
87 */
88 BRUCE_DLL_API
89 Bruce(DimVec v0, DimVec v1, DimVec v2,
90 int n0, int n1, int n2,
91 DimVec origin);
92
93 /**
94 \brief
95 Copy constructor.
96 */
97 BRUCE_DLL_API
98 Bruce(const Bruce& other);
99
100 /**
101 \brief
102 Destructor for Bruce.
103 */
104 BRUCE_DLL_API
105 ~Bruce();
106
107 /**
108 \brief
109 Return this as an AbstractContinuousDomain.
110 */
111 BRUCE_DLL_API
112 inline
113 const AbstractContinuousDomain&
114 asAbstractContinuousDomain() const
115 {
116 return *(static_cast<const AbstractContinuousDomain*>(this));
117 }
118
119 /**
120 \brief
121 Return this as an AbstractDomain.
122 */
123 BRUCE_DLL_API
124 inline
125 const AbstractDomain&
126 asAbstractDomain() const
127 {
128 return *(static_cast<const AbstractDomain*>(this));
129 }
130
131 /**
132 \brief
133 Return a description for this domain.
134 */
135 BRUCE_DLL_API
136 virtual
137 inline
138 std::string
139 getDescription() const
140 {
141 return "Bruce";
142 }
143
144 /**
145 \brief
146 Returns true if the given integer is a valid function space type
147 for this domain.
148 */
149 BRUCE_DLL_API
150 virtual
151 bool
152 isValidFunctionSpaceType(int functionSpaceCode) const;
153
154 /**
155 \brief
156 Return a description for the given function space type code.
157 */
158 BRUCE_DLL_API
159 virtual
160 std::string
161 functionSpaceTypeAsString(int functionSpaceCode) const;
162
163 /**
164 \brief
165 Return a continuous FunctionSpace code.
166 */
167 BRUCE_DLL_API
168 virtual
169 inline
170 int
171 getContinuousFunctionCode() const
172 {
173 return ContinuousFunction;
174 }
175
176 /**
177 \brief
178 Return a function FunctionSpace code.
179 */
180 BRUCE_DLL_API
181 virtual
182 inline
183 int
184 getFunctionCode() const
185 {
186 return Function;
187 }
188
189 /**
190 \brief
191 Return the spatial dimension of the mesh.
192 */
193 BRUCE_DLL_API
194 virtual
195 inline
196 int
197 getDim() const
198 {
199 return m_origin.size();
200 }
201
202 /**
203 \brief
204 Return the number of data points per sample, and the number of samples
205 needed to represent data on parts of the mesh.
206 */
207 BRUCE_DLL_API
208 virtual
209 std::pair<int,int>
210 getDataShape(int functionSpaceCode) const;
211
212 /**
213 \brief
214 Return the number of samples
215 needed to represent data on parts of the mesh.
216 */
217 BRUCE_DLL_API
218 int
219 getNumSamples(int functionSpaceCode) const;
220
221 /**
222 \brief
223 Return the number of data-points per sample
224 needed to represent data on parts of the mesh.
225 */
226 BRUCE_DLL_API
227 inline
228 int
229 getNumDataPointsPerSample(int functionSpaceCode) const
230 {
231 return 1;
232 }
233
234 /**
235 \brief
236 Returns the locations in the domain of the FEM nodes.
237 */
238 BRUCE_DLL_API
239 virtual
240 escript::Data
241 getX() const;
242
243 /**
244 \brief
245 Copies the location of data points on the domain into out.
246 */
247 BRUCE_DLL_API
248 virtual
249 void
250 setToX(escript::Data& out) const;
251
252 /**
253 \brief
254 Returns the element size.
255 */
256 BRUCE_DLL_API
257 virtual
258 escript::Data
259 getSize() const;
260
261 /**
262 \brief
263 Copies the size of samples into out.
264 */
265 BRUCE_DLL_API
266 virtual
267 void
268 setToSize(escript::Data& out) const;
269
270 /**
271 \brief
272 Copies the gradient of arg into grad. The actual function space to be considered
273 for the gradient is defined by grad. arg and grad have to be defined on this.
274 */
275 BRUCE_DLL_API
276 virtual
277 void
278 setToGradient(escript::Data& grad,
279 const escript::Data& arg) const;
280
281 /**
282 \brief
283 Comparison operators.
284 */
285 BRUCE_DLL_API
286 virtual bool operator==(const AbstractDomain& other) const;
287 BRUCE_DLL_API
288 virtual bool operator!=(const AbstractDomain& other) const;
289
290 /*
291 \brief
292 Return the tag key for the given sample number.
293 NB: tags are not implemented on Bruce, so this method always returns 0.
294 */
295 BRUCE_DLL_API
296 virtual
297 inline
298 int
299 getTagFromSampleNo(int functionSpaceCode,
300 int sampleNo) const
301 {
302 return 0;
303 }
304
305 /**
306 \brief
307 Return the reference number of the given sample number.
308 */
309 BRUCE_DLL_API
310 virtual
311 int
312 getReferenceNoFromSampleNo(int functionSpaceCode,
313 int sampleNo) const;
314
315 /**
316 \brief
317 Saves a dictionary of Data objects to a VTK XML input file.
318 The dictionary consists of pairs of Data objects plus a name
319 for each. Each Data object must be defined on this domain.
320 */
321 BRUCE_DLL_API
322 virtual
323 void
324 saveVTK(const std::string& filename,
325 const boost::python::dict& dataDict) const;
326
327 /**
328 \brief
329 Interpolates data given on source onto target where source and target
330 have to be given on the same domain.
331 */
332 BRUCE_DLL_API
333 virtual
334 void
335 interpolateOnDomain(escript::Data& target,
336 const escript::Data& source) const;
337
338 BRUCE_DLL_API
339 virtual
340 bool
341 probeInterpolationOnDomain(int functionSpaceType_source,
342 int functionSpaceType_target) const;
343
344 /**
345 \brief
346 Interpolates data given on source onto target where source and target
347 are given on different domains.
348 */
349 BRUCE_DLL_API
350 virtual
351 void
352 interpolateACross(escript::Data& target,
353 const escript::Data& source) const;
354
355 BRUCE_DLL_API
356 virtual
357 bool
358 probeInterpolationACross(int functionSpaceType_source,
359 const AbstractDomain& targetDomain,
360 int functionSpaceType_target) const;
361
362 protected:
363
364 /**
365 \brief
366 Build the table of function space type names.
367 */
368 BRUCE_DLL_API
369 void
370 setFunctionSpaceTypeNames();
371
372 /**
373 \brief
374 Ensure the parameters supplied to the constructor are valid.
375 */
376 BRUCE_DLL_API
377 bool
378 checkParameters();
379
380 /**
381 \brief
382 Check if all components of vector are zero.
383 */
384 BRUCE_DLL_API
385 static
386 bool
387 isZero(DimVec vec);
388
389 private:
390
391 //
392 // vectors describing axis of the domain
393 DimVec m_v0, m_v1, m_v2;
394
395 //
396 // number of data points in each axial direction of the domain
397 int m_n0, m_n1, m_n2;
398
399 //
400 // the coordinates of the origin of the domain
401 DimVec m_origin;
402
403 //
404 // map from FunctionSpace codes to names
405 static FunctionSpaceNamesMapType m_functionSpaceTypeNames;
406
407 };
408
409 } // end of namespace
410
411 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26