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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 465 - (show annotations)
Wed Jan 25 01:08:17 2006 UTC (14 years, 10 months ago) by jgs
File MIME type: text/plain
File size: 8369 byte(s)
reorganise bruce source tree:
move all from src/Bruce -> src
remove inc
adjust all #includes appropriately


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26