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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2119 - (show annotations)
Tue Dec 2 06:06:04 2008 UTC (11 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 10630 byte(s)
Branch commit.
Threading Wrapped Array through the code.
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 ESCRIPT_DLL_API
68 DataExpanded(const WrappedArray& value,
69 const FunctionSpace& what);
70
71 /**
72 \brief
73 Alternative constructor for DataExpanded that copies a slice from
74 another DataExpanded.
75
76 \param other - Input - DataExpanded object to slice from.
77 \param region - Input - region to copy.
78 */
79 ESCRIPT_DLL_API
80 DataExpanded(const DataExpanded& other,
81 const DataTypes::RegionType& region);
82
83 /**
84 \brief
85 Alternative constructor for DataExpanded objects.
86
87 Description:
88 Alternative Constructor for DataExpanded objects.
89 \param what - Input - A description of what this data object represents.
90 \param shape - Input - the shape of each data-point.
91 \param data - the array of data values for the data-points.
92
93 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.
94 */
95 ESCRIPT_DLL_API
96 DataExpanded(const FunctionSpace& what,
97 const DataTypes::ShapeType &shape,
98 const DataTypes::ValueType &data);
99
100 /**
101 \brief
102 Copy constructor for DataExpanded.
103 Performs a deep copy from another DataExpanded.
104 */
105 ESCRIPT_DLL_API
106 DataExpanded(const DataExpanded& other);
107
108 /**
109 \brief
110 Copy constructor for DataExpanded.
111 Construct a DataExpanded from a DataConstant.
112 */
113 ESCRIPT_DLL_API
114 DataExpanded(const DataConstant& other);
115
116 /**
117 \brief
118 Copy constructor for DataExpanded.
119 Construct a DataExpanded from a DataTagged.
120 */
121 ESCRIPT_DLL_API
122 DataExpanded(const DataTagged& other);
123
124 /**
125 \brief
126 Default destructor for DataExpanded.
127 */
128 ESCRIPT_DLL_API
129 virtual
130 ~DataExpanded();
131
132 ESCRIPT_DLL_API
133 bool
134 isExpanded() const
135 {
136 return true;
137 };
138
139 /**
140 \brief
141 Return a textual representation of the data.
142 */
143 ESCRIPT_DLL_API
144 virtual
145 std::string
146 toString() const;
147
148 /**
149 \brief Return a deep copy of the current object.
150 */
151 ESCRIPT_DLL_API
152 virtual
153 DataAbstract*
154 deepCopy();
155
156
157 /**
158 \brief
159 dumps the object into a netCDF file
160 */
161 ESCRIPT_DLL_API
162 virtual
163 void
164 dump(const std::string fileName) const;
165
166 /**
167 \brief
168 sets all values to zero
169 */
170 ESCRIPT_DLL_API
171 virtual
172 void
173 setToZero();
174
175 /**
176 \brief
177 Return the offset for the given given data point. This returns
178 the offset in bytes for the given point into the container
179 holding the point data.
180
181 \param sampleNo - Input - sample number.
182 \param dataPointNo - Input - data point number.
183 */
184 ESCRIPT_DLL_API
185 virtual
186 DataTypes::ValueType::size_type
187 getPointOffset(int sampleNo,
188 int dataPointNo) const;
189
190 ESCRIPT_DLL_API
191 virtual
192 DataTypes::ValueType::size_type
193 getPointOffset(int sampleNo,
194 int dataPointNo);
195
196 /**
197 \brief
198 Return a a reference to the underlying DataVector.
199 */
200
201 ESCRIPT_DLL_API
202 DataTypes::ValueType&
203 getVector();
204
205 ESCRIPT_DLL_API
206 const DataTypes::ValueType&
207 getVector() const;
208
209
210 /**
211 \brief
212 Return the number of doubles stored for the Data.
213 */
214 ESCRIPT_DLL_API
215 virtual
216 ValueType::size_type
217 getLength() const;
218
219 /**
220 \brief
221 Factory method that returns a newly created DataExpanded.
222 The caller is reponsible for managing the object created.
223
224 \param region - Input - Region to copy.
225 */
226 ESCRIPT_DLL_API
227 virtual
228 DataAbstract*
229 getSlice(const DataTypes::RegionType& region) const;
230
231 /**
232 \brief
233 Copy the specified region from the given value.
234
235 \param value - Input - Data object to copy from.
236 \param region - Input - Region to copy.
237 */
238 ESCRIPT_DLL_API
239 virtual
240 void
241 setSlice(const DataAbstract* value,
242 const DataTypes::RegionType& region);
243
244 /**
245 \brief
246 setTaggedValue
247
248 Description:
249 uses tag to set a new value
250
251 \param tagKey - Input - Integer key.
252 \param pointshape - Input - The shape of the value parameter
253 \param value - Input - .
254 */
255 void
256 setTaggedValue(int tagKey,
257 const DataTypes::ShapeType& pointshape,
258 const DataTypes::ValueType& value,
259 int dataOffset=0);
260
261
262
263 /**
264 \brief
265 Computes a symmetric matrix (A + AT) / 2
266
267 \param ev - Output - symmetric matrix
268
269 */
270 ESCRIPT_DLL_API
271 virtual void
272 symmetric(DataAbstract* ev);
273
274 /**
275 \brief
276 Computes a nonsymmetric matrix (A - AT) / 2
277
278 \param ev - Output - nonsymmetric matrix
279
280 */
281 ESCRIPT_DLL_API
282 virtual void
283 nonsymmetric(DataAbstract* ev);
284
285 /**
286 \brief
287 Computes the trace of a matrix
288
289 \param ev - Output - trace of your matrix
290
291 */
292 ESCRIPT_DLL_API
293 virtual void
294 trace(DataAbstract* ev, int axis_offset);
295
296 /**
297 \brief
298 Transpose each data point of this Data object around the given axis.
299
300 \param ev - Output - transpose of your matrix
301
302 */
303 ESCRIPT_DLL_API
304 virtual void
305 transpose(DataAbstract* ev, int axis_offset);
306
307 /**
308 \brief
309 swaps components axis0 and axis1
310
311 \param ev - Output - swapped components
312
313 */
314 ESCRIPT_DLL_API
315 virtual void
316 swapaxes(DataAbstract* ev, int axis0, int axis1);
317
318
319 /**
320 \brief
321 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
322
323 \param ev - Output - eigenvalues in increasing order at each data point
324
325 */
326 ESCRIPT_DLL_API
327 virtual void
328 eigenvalues(DataAbstract* ev);
329
330 /**
331 \brief
332 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
333
334 \param ev - Output - eigenvalues in increasing order at each data point
335 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
336 and the first nonzero component is positive.
337 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
338
339 */
340
341 ESCRIPT_DLL_API
342 virtual void
343 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
344
345 /**
346 * \brief
347 * reorders data sample ordered by reference_ids to the ordering of the functions space
348 *
349 * \param reference_ids - Input - reference_ids used for current ordering
350 * */
351 ESCRIPT_DLL_API
352 virtual void
353 reorderByReferenceIDs(int *reference_ids);
354
355
356
357 protected:
358
359 private:
360
361 /**
362 \brief
363 Common initialisation called from constructors.
364
365 Description:
366 Common initialisation called from constructors.
367
368 Resizes the underlying data array to provide sufficient storage for the
369 given shape and number of data points, and creates the corresponding
370 DataArrayView of this data.
371
372 \param noSamples - Input - number of samples.
373 \param noDataPointsPerSample - Input - number of data points per sample.
374 */
375 void
376 initialise(int noSamples,
377 int noDataPointsPerSample);
378
379 /**
380 \brief
381 Copy the given data point value to all data points in this object.
382
383 Description:
384 Copy the given data point to all data points in this object.
385
386 \param value Input - A single data point value.
387 */
388 void
389 copy(const DataConstant& value);
390
391
392
393 /**
394 \brief
395 Copy the given data point value given a numarray object to all data points in this object.
396
397 Description:
398 Copy the given data point value given a numarray object to all data points in this object.
399
400 \param value Input - A single data point value.
401 */
402 void
403 copy(const boost::python::numeric::array& value);
404
405 void
406 copy(const WrappedArray& value);
407
408 /**
409 \brief
410 Copy the numarray object to the data points in this object.
411
412 Description:
413 Copy the numarray object to the data points in this object.
414
415 \param value Input - new values for the data points
416 */
417 void
418 copyAll(const boost::python::numeric::array& value);
419
420 /**
421 \brief
422 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
423
424 Description:
425 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
426
427 \param sampleNo Input - sample number
428 \param dataPointNo Input - data point of the sample
429 \param value Input - new values for the data point
430 */
431 ESCRIPT_DLL_API
432 virtual void
433 copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
434
435
436 /**
437 \brief
438 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
439
440 Description:
441 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
442
443 \param sampleNo Input - sample number
444 \param dataPointNo Input - data point of the sample
445 \param value Input - new values for the data point
446 */
447 void
448 copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
449
450 //
451 // The main data storage array, a 2D array of data blocks.
452 // noSamples * noDataPointsPerSample
453 DataBlocks2D m_data;
454
455 };
456
457 } // end of namespace
458
459 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26