/[escript]/branches/schroedinger/escript/src/DataExpanded.h
ViewVC logotype

Contents of /branches/schroedinger/escript/src/DataExpanded.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (show annotations)
Thu Oct 9 03:09:30 2008 UTC (11 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 10280 byte(s)
Branch commit
It compiles but doesn't do much.


1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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_DataExpanded_20040323_H
16 #define escript_DataExpanded_20040323_H
17 #include "system_dep.h"
18
19 #include "DataReady.h"
20 #include "DataBlocks2D.h"
21
22 #include <boost/python/numeric.hpp>
23
24 namespace escript {
25
26 //
27 // Forward declarations of other Data types.
28 class DataConstant;
29 class DataTagged;
30
31 /**
32 \brief
33 Give a short description of what DataExpanded does.
34
35 Description:
36 Give a detailed description of DataExpanded.
37
38 Template Parameters:
39 For templates describe any conditions that the parameters used in the
40 template must satisfy.
41 */
42
43 class DataExpanded : public DataReady {
44
45 typedef DataReady parent;
46
47 public:
48
49 /**
50 \brief
51 Constructor for DataExpanded.
52
53 Description:
54 Constructor for DataExpanded.
55
56 The given single data value is copied to all the data points in
57 this data object, where the number of data points is defined by
58 the given function space.
59
60 \param value - Input - A single data value.
61 \param what - Input - A description of what this data represents.
62 */
63 ESCRIPT_DLL_API
64 DataExpanded(const boost::python::numeric::array& value,
65 const FunctionSpace& what);
66
67 /**
68 \brief
69 Alternative constructor for DataExpanded that copies a slice from
70 another DataExpanded.
71
72 \param other - Input - DataExpanded object to slice from.
73 \param region - Input - region to copy.
74 */
75 ESCRIPT_DLL_API
76 DataExpanded(const DataExpanded& other,
77 const DataTypes::RegionType& region);
78
79 /**
80 \brief
81 Alternative constructor for DataExpanded objects.
82
83 Description:
84 Alternative Constructor for DataExpanded objects.
85 \param what - Input - A description of what this data object represents.
86 \param shape - Input - the shape of each data-point.
87 \param data - the array of data values for the data-points.
88
89 TODO Note that this constructor will also copy data to all points if it only contains enough elements to hold a single point. ie this is the merge of two separate constructors.
90 */
91 ESCRIPT_DLL_API
92 DataExpanded(const FunctionSpace& what,
93 const DataTypes::ShapeType &shape,
94 const DataTypes::ValueType &data);
95
96 /**
97 \brief
98 Copy constructor for DataExpanded.
99 Performs a deep copy from another DataExpanded.
100 */
101 ESCRIPT_DLL_API
102 DataExpanded(const DataExpanded& other);
103
104 /**
105 \brief
106 Copy constructor for DataExpanded.
107 Construct a DataExpanded from a DataConstant.
108 */
109 ESCRIPT_DLL_API
110 DataExpanded(const DataConstant& other);
111
112 /**
113 \brief
114 Copy constructor for DataExpanded.
115 Construct a DataExpanded from a DataTagged.
116 */
117 ESCRIPT_DLL_API
118 DataExpanded(const DataTagged& other);
119
120 /**
121 \brief
122 Default destructor for DataExpanded.
123 */
124 ESCRIPT_DLL_API
125 virtual
126 ~DataExpanded();
127
128 /**
129 \brief
130 Return a textual representation of the data.
131 */
132 ESCRIPT_DLL_API
133 virtual
134 std::string
135 toString() const;
136
137 /**
138 \brief Return a deep copy of the current object.
139 */
140 ESCRIPT_DLL_API
141 virtual
142 DataAbstract*
143 deepCopy();
144
145
146 /**
147 \brief
148 dumps the object into a netCDF file
149 */
150 ESCRIPT_DLL_API
151 virtual
152 void
153 dump(const std::string fileName) const;
154
155 /**
156 \brief
157 sets all values to zero
158 */
159 ESCRIPT_DLL_API
160 virtual
161 void
162 setToZero();
163
164 /**
165 \brief
166 Return the offset for the given given data point. This returns
167 the offset in bytes for the given point into the container
168 holding the point data.
169
170 \param sampleNo - Input - sample number.
171 \param dataPointNo - Input - data point number.
172 */
173 ESCRIPT_DLL_API
174 virtual
175 DataTypes::ValueType::size_type
176 getPointOffset(int sampleNo,
177 int dataPointNo) const;
178
179 /**
180 \brief
181 Return a a reference to the underlying DataVector.
182 */
183
184 ESCRIPT_DLL_API
185 DataTypes::ValueType&
186 getVector();
187
188 ESCRIPT_DLL_API
189 const DataTypes::ValueType&
190 getVector() const;
191
192
193 /**
194 \brief
195 Return the number of doubles stored for the Data.
196 */
197 ESCRIPT_DLL_API
198 virtual
199 ValueType::size_type
200 getLength() const;
201
202 /**
203 \brief
204 Factory method that returns a newly created DataExpanded.
205 The caller is reponsible for managing the object created.
206
207 \param region - Input - Region to copy.
208 */
209 ESCRIPT_DLL_API
210 virtual
211 DataAbstract*
212 getSlice(const DataTypes::RegionType& region) const;
213
214 /**
215 \brief
216 Copy the specified region from the given value.
217
218 \param value - Input - Data object to copy from.
219 \param region - Input - Region to copy.
220 */
221 ESCRIPT_DLL_API
222 virtual
223 void
224 setSlice(const DataAbstract* value,
225 const DataTypes::RegionType& region);
226
227 /**
228 \brief
229 setTaggedValue
230
231 Description:
232 uses tag to set a new value
233
234 \param tagKey - Input - Integer key.
235 \param pointshape - Input - The shape of the value parameter
236 \param value - Input - .
237 */
238 void
239 setTaggedValue(int tagKey,
240 const DataTypes::ShapeType& pointshape,
241 const DataTypes::ValueType& value,
242 int dataOffset=0);
243
244
245
246 /**
247 \brief
248 Computes a symmetric matrix (A + AT) / 2
249
250 \param ev - Output - symmetric matrix
251
252 */
253 ESCRIPT_DLL_API
254 virtual void
255 symmetric(DataAbstract* ev);
256
257 /**
258 \brief
259 Computes a nonsymmetric matrix (A - AT) / 2
260
261 \param ev - Output - nonsymmetric matrix
262
263 */
264 ESCRIPT_DLL_API
265 virtual void
266 nonsymmetric(DataAbstract* ev);
267
268 /**
269 \brief
270 Computes the trace of a matrix
271
272 \param ev - Output - trace of your matrix
273
274 */
275 ESCRIPT_DLL_API
276 virtual void
277 trace(DataAbstract* ev, int axis_offset);
278
279 /**
280 \brief
281 Transpose each data point of this Data object around the given axis.
282
283 \param ev - Output - transpose of your matrix
284
285 */
286 ESCRIPT_DLL_API
287 virtual void
288 transpose(DataAbstract* ev, int axis_offset);
289
290 /**
291 \brief
292 swaps components axis0 and axis1
293
294 \param ev - Output - swapped components
295
296 */
297 ESCRIPT_DLL_API
298 virtual void
299 swapaxes(DataAbstract* ev, int axis0, int axis1);
300
301
302 /**
303 \brief
304 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
305
306 \param ev - Output - eigenvalues in increasing order at each data point
307
308 */
309 ESCRIPT_DLL_API
310 virtual void
311 eigenvalues(DataAbstract* ev);
312
313 /**
314 \brief
315 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
316
317 \param ev - Output - eigenvalues in increasing order at each data point
318 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
319 and the first nonzero component is positive.
320 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
321
322 */
323
324 ESCRIPT_DLL_API
325 virtual void
326 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
327
328 /**
329 * \brief
330 * reorders data sample ordered by reference_ids to the ordering of the functions space
331 *
332 * \param reference_ids - Input - reference_ids used for current ordering
333 * */
334 ESCRIPT_DLL_API
335 virtual void
336 reorderByReferenceIDs(int *reference_ids);
337
338
339
340 protected:
341
342 private:
343
344 /**
345 \brief
346 Common initialisation called from constructors.
347
348 Description:
349 Common initialisation called from constructors.
350
351 Resizes the underlying data array to provide sufficient storage for the
352 given shape and number of data points, and creates the corresponding
353 DataArrayView of this data.
354
355 \param noSamples - Input - number of samples.
356 \param noDataPointsPerSample - Input - number of data points per sample.
357 */
358 void
359 initialise(int noSamples,
360 int noDataPointsPerSample);
361
362 /**
363 \brief
364 Copy the given data point value to all data points in this object.
365
366 Description:
367 Copy the given data point to all data points in this object.
368
369 \param value Input - A single data point value.
370 */
371 void
372 copy(const DataConstant& value);
373
374
375
376 /**
377 \brief
378 Copy the given data point value given a numarray object to all data points in this object.
379
380 Description:
381 Copy the given data point value given a numarray object to all data points in this object.
382
383 \param value Input - A single data point value.
384 */
385 void
386 copy(const boost::python::numeric::array& value);
387
388 /**
389 \brief
390 Copy the numarray object to the data points in this object.
391
392 Description:
393 Copy the numarray object to the data points in this object.
394
395 \param value Input - new values for the data points
396 */
397 void
398 copyAll(const boost::python::numeric::array& value);
399
400 /**
401 \brief
402 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
403
404 Description:
405 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
406
407 \param sampleNo Input - sample number
408 \param dataPointNo Input - data point of the sample
409 \param value Input - new values for the data point
410 */
411 ESCRIPT_DLL_API
412 virtual void
413 copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
414
415
416 /**
417 \brief
418 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
419
420 Description:
421 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
422
423 \param sampleNo Input - sample number
424 \param dataPointNo Input - data point of the sample
425 \param value Input - new values for the data point
426 */
427 void
428 copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
429
430 //
431 // The main data storage array, a 2D array of data blocks.
432 // noSamples * noDataPointsPerSample
433 DataBlocks2D m_data;
434
435 };
436
437 } // end of namespace
438
439 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26