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

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26