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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 474 - (hide annotations)
Mon Jan 30 04:23:44 2006 UTC (15 years, 2 months ago) by jgs
File MIME type: text/plain
File size: 8317 byte(s)
restructure escript source tree
move src/Data/* -> src
remove inc
modify #includes and cpppath settings accordingly

1 jgs 149 // $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 jgs 151
16 jgs 149 #if !defined bruce_Bruce_20050829_H
17     #define bruce_Bruce_20050829_H
18    
19 jgs 474 #include "AbstractContinuousDomain.h"
20     #include "FunctionSpaceFactory.h"
21     #include "FunctionSpace.h"
22     #include "Data.h"
23 jgs 149
24 jgs 465 #include "BruceException.h"
25    
26     #include "vtkCellType.h"
27    
28     #include <boost/python/extract.hpp>
29    
30 jgs 149 #include <string>
31 jgs 150 #include <vector>
32 jgs 149
33     namespace bruce {
34    
35     /**
36     \brief
37 jgs 151 Bruce implements a structured AbstractContinuousDomain.
38 jgs 149
39     Description:
40 jgs 151 Bruce implements a structured AbstractContinuousDomain.
41 jgs 149 */
42    
43     class Bruce : public escript::AbstractContinuousDomain {
44    
45     public:
46    
47     //
48     // Codes for function space types supported
49 jgs 154 static const int ContinuousFunction; // data is on the nodes
50     static const int Function; // data is on the cell centres
51 jgs 149
52 jgs 150 //
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 jgs 149 /**
61     \brief
62 jgs 150 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 jgs 149 Constructor for Bruce.
73    
74     Description:
75     Constructor for Bruce.
76 jgs 150
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 jgs 149 */
90 jgs 150 Bruce(DimVec v0, DimVec v1, DimVec v2,
91     int n0, int n1, int n2,
92     DimVec origin);
93 jgs 149
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 jgs 150 return *(static_cast<const AbstractContinuousDomain*>(this));
115 jgs 149 }
116    
117     /**
118     \brief
119     Return this as an AbstractDomain.
120     */
121     inline
122     const AbstractDomain&
123     asAbstractDomain() const
124     {
125 jgs 150 return *(static_cast<const AbstractDomain*>(this));
126 jgs 149 }
127    
128     /**
129     \brief
130 jgs 150 Return a description for this domain.
131     */
132     virtual
133 jgs 151 inline
134 jgs 150 std::string
135 jgs 151 getDescription() const
136     {
137     return "Bruce";
138     }
139 jgs 150
140     /**
141     \brief
142 jgs 149 Returns true if the given integer is a valid function space type
143     for this domain.
144     */
145     virtual
146     bool
147 jgs 150 isValidFunctionSpaceType(int functionSpaceCode) const;
148 jgs 149
149     /**
150     \brief
151 jgs 150 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 jgs 151 inline
163 jgs 150 int
164 jgs 151 getContinuousFunctionCode() const
165     {
166     return ContinuousFunction;
167     }
168 jgs 150
169     /**
170     \brief
171     Return a function FunctionSpace code.
172     */
173     virtual
174 jgs 151 inline
175 jgs 150 int
176 jgs 151 getFunctionCode() const
177     {
178     return Function;
179     }
180 jgs 150
181     /**
182     \brief
183 jgs 149 Return the spatial dimension of the mesh.
184     */
185     virtual
186 jgs 151 inline
187 jgs 149 int
188 jgs 151 getDim() const
189     {
190     return m_origin.size();
191     }
192 jgs 149
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 jgs 154 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 jgs 149 Returns the locations in the domain of the FEM nodes.
225     */
226     virtual
227     escript::Data
228     getX() const;
229    
230     /**
231     \brief
232 jgs 150 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 jgs 149 Returns the element size.
241     */
242     virtual
243     escript::Data
244     getSize() const;
245    
246     /**
247     \brief
248 jgs 150 Copies the size of samples into out.
249     */
250     virtual
251     void
252     setToSize(escript::Data& out) const;
253    
254     /**
255     \brief
256 jgs 154 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 jgs 149 Comparison operators.
267     */
268     virtual bool operator==(const AbstractDomain& other) const;
269     virtual bool operator!=(const AbstractDomain& other) const;
270    
271 jgs 153 /*
272     \brief
273     Return the tag key for the given sample number.
274 jgs 154 NB: tags are not implemented on Bruce, so this method always returns 0.
275 jgs 153 */
276     virtual
277 jgs 154 inline
278 jgs 153 int
279 jgs 154 getTagFromSampleNo(int functionSpaceCode,
280     int sampleNo) const
281     {
282     return 0;
283     }
284 jgs 153
285     /**
286     \brief
287     Return the reference number of the given sample number.
288     */
289     virtual
290     int
291 jgs 154 getReferenceNoFromSampleNo(int functionSpaceCode,
292     int sampleNo) const;
293 jgs 153
294 jgs 154 /**
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 jgs 153
305 jgs 154 /**
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 jgs 149 protected:
337    
338 jgs 150 /**
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 jgs 151 static
357 jgs 150 bool
358 jgs 151 isZero(DimVec vec);
359 jgs 150
360 jgs 149 private:
361    
362 jgs 150 //
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 jgs 149 };
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