/[escript]/trunk/escript/src/DataConstant.h
ViewVC logotype

Contents of /trunk/escript/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2635 - (show annotations)
Thu Aug 27 04:54:41 2009 UTC (10 years ago) by jfenwick
File MIME type: text/plain
File size: 6595 byte(s)
A bunch of changes related to saveDataCSV.
[Not completed or unit tested yet]

Added saveDataCSV to util.py
AbstractDomain (and MeshAdapter) have a commonFunctionSpace method to 
take a group of FunctionSpaces and return something they can all be interpolated to.

Added pointToStream() in DataTypes to help print points.

added actsConstant() to data - required because DataConstant doesn't store samples the same way other Data do.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #if !defined escript_DataConstant_20040323_H
16 #define escript_DataConstant_20040323_H
17 #include "system_dep.h"
18
19 #include "DataReady.h"
20 #include "WrappedArray.h"
21
22 #include <boost/python/numeric.hpp>
23
24 namespace escript {
25
26 /**
27 \brief
28 DataConstant stores a single data point which represents the entire
29 function space.
30
31 Description:
32 DataConstant stores a single data point which represents the entire
33 function space.
34 */
35 class DataConstant : public DataReady {
36 typedef DataReady parent;
37 public:
38
39 /**
40 \brief
41 Constructor for DataConstant objects.
42
43 Description:
44 Constructor for DataConstant objects.
45
46 \param value - Input - Data value for a single point.
47 \param what - Input - A description of what this data object represents.
48 */
49 ESCRIPT_DLL_API
50 DataConstant(const WrappedArray& value,
51 const FunctionSpace& what);
52
53
54 /**
55 \brief
56 Copy constructor. Performs a deep copy.
57 */
58 ESCRIPT_DLL_API
59 DataConstant(const DataConstant& other);
60
61
62 /**
63 \brief
64 Alternative constructor for DataConstant objects.
65
66 Description:
67 Alternative Constructor for DataConstant objects.
68 \param other - Input - Data object to copy from.
69 \param region - Input - region to copy.
70 */
71 ESCRIPT_DLL_API
72 DataConstant(const DataConstant& other,
73 const DataTypes::RegionType& region);
74
75 /**
76 \brief
77 Alternative constructor for DataConstant objects.
78
79 Description:
80 Alternative Constructor for DataConstant objects.
81 \param what - Input - A description of what this data object represents.
82 \param shape - Input - the shape of each data-point.
83 \param data - the data values for each data-point.
84 */
85 ESCRIPT_DLL_API
86 DataConstant(const FunctionSpace& what,
87 const DataTypes::ShapeType &shape,
88 const DataTypes::ValueType &data);
89
90
91 ESCRIPT_DLL_API
92 bool
93 isConstant() const
94 {
95 return true;
96 };
97
98 ESCRIPT_DLL_API
99 virtual
100 bool
101 actsConstant() const {return true;}
102
103 /**
104 \brief
105 Write the data as a string.
106 */
107 ESCRIPT_DLL_API
108 std::string
109 toString() const;
110
111 /**
112 \brief Return a deep copy of the current object.
113 */
114 ESCRIPT_DLL_API
115 virtual
116 DataAbstract*
117 deepCopy();
118
119
120 /**
121 \brief
122 dumps the object into a netCDF file
123 */
124 ESCRIPT_DLL_API
125 virtual
126 void
127 dump(const std::string fileName) const;
128
129 /**
130 \brief
131 sets all values to zero
132 */
133 ESCRIPT_DLL_API
134 virtual
135 void
136 setToZero();
137
138 /**
139 \brief
140 Return the offset for the given sample. This is a somewhat artificial notion
141 but returns the offset in bytes for the given point into the container
142 holding the point data. Only really necessary to avoid many DataArrayView
143 objects.
144 \param sampleNo - Input - sample number.
145 \param dataPointNo - Input - data point number for the sample.
146 */
147 ESCRIPT_DLL_API
148 virtual
149 DataTypes::ValueType::size_type
150 getPointOffset(int sampleNo,
151 int dataPointNo) const;
152
153 ESCRIPT_DLL_API
154 virtual
155 DataTypes::ValueType::size_type
156 getPointOffset(int sampleNo,
157 int dataPointNo);
158
159 /**
160 \brief
161 Return the number of doubles stored for the Data object.
162 */
163 ESCRIPT_DLL_API
164 virtual
165 DataTypes::ValueType::size_type
166 getLength() const;
167
168 /**
169 \brief
170 Factory method that returns a newly created DataConstant object
171 sliced from the specified region of this object.
172 The caller is reponsible for managing the object created.
173 \param region - Input - region to slice from this object.
174 */
175 ESCRIPT_DLL_API
176 virtual
177 DataAbstract*
178 getSlice(const DataTypes::RegionType& region) const;
179
180 /**
181 \brief
182 Copy the specified region from the given value.
183 \param value - Input - Data object to copy from.
184 \param region - Input - Region to copy.
185 */
186 ESCRIPT_DLL_API
187 virtual
188 void
189 setSlice(const DataAbstract* value,
190 const DataTypes::RegionType& region);
191
192
193 /**
194 \brief
195 Computes a symmetric matrix (A + AT) / 2
196
197 \param ev - Output - symmetric matrix
198
199 */
200 ESCRIPT_DLL_API
201 virtual void
202 symmetric(DataAbstract* ev);
203
204 /**
205 \brief
206 Computes a nonsymmetric matrix (A - AT) / 2
207
208 \param ev - Output - nonsymmetric matrix
209
210 */
211 ESCRIPT_DLL_API
212 virtual void
213 nonsymmetric(DataAbstract* ev);
214
215 /**
216 \brief
217 Computes the trace of a matrix
218
219 \param ev - Output - trace of matrix
220 \param axis_offset
221
222 */
223 ESCRIPT_DLL_API
224 virtual void
225 trace(DataAbstract* ev, int axis_offset);
226
227 /**
228 \brief
229 Transpose each data point of this Data object around the given axis.
230
231 \param ev - Output - transpose of matrix
232 \param axis_offset
233 */
234 ESCRIPT_DLL_API
235 virtual void
236 transpose(DataAbstract* ev, int axis_offset);
237
238 /**
239 \brief
240 swaps components axis0 and axis1
241
242 \param ev - Output - swapped components
243 \param axis0
244 \param axis1
245 */
246 ESCRIPT_DLL_API
247 virtual void
248 swapaxes(DataAbstract* ev, int axis0, int axis1);
249
250
251 /**
252 \brief
253 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
254
255 \param ev - Output - eigenvalues in increasing order at each data point
256
257 */
258 ESCRIPT_DLL_API
259 virtual void
260 eigenvalues(DataAbstract* ev);
261
262 /**
263 \brief
264 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
265
266 \param ev - Output - eigenvalues in increasing order at each data point
267 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
268 and the first nonzero component is positive.
269 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
270
271 */
272
273 ESCRIPT_DLL_API
274 virtual void
275 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
276
277
278 /**
279 \brief
280 Return a reference to the underlying DataVector.
281 */
282 ESCRIPT_DLL_API
283 DataTypes::ValueType&
284 getVectorRW();
285
286
287 ESCRIPT_DLL_API
288 const DataTypes::ValueType&
289 getVectorRO() const;
290
291 protected:
292
293 private:
294 //
295 // the actual data
296 DataTypes::ValueType m_data;
297
298 };
299
300 } // end of namespace
301 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26