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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 627 - (hide annotations)
Thu Mar 23 02:22:46 2006 UTC (15 years, 1 month ago) by elspeth
File MIME type: text/plain
File size: 7897 byte(s)
Copyright information added.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26