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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2653 - (show annotations)
Tue Sep 8 04:26:30 2009 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 6485 byte(s)
Fix bug in maxGlobalDataPoint and minGlobalDataPoint.
They now give the correct answers and the datapoint ids returned are globally
correct.

Removed some #defines from before COW
Removed hasNoSamples() - I don't trust myself to use that properly let alone anybody else.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26