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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2005 - (show annotations)
Mon Nov 10 01:21:39 2008 UTC (10 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 10483 byte(s)
Bringing all changes across from schroedinger.
(Note this does not mean development is done, just that it will happen
on the trunk for now).
If anyone notices any problems please contact me.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26