/[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 1889 - (show annotations)
Thu Oct 16 05:57:09 2008 UTC (11 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 10354 byte(s)
Branch commit
Rewrote resolve to take into account Tagged and Constant Data.
Mixing expanded and Tagged does not work yet.

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 /**
187 \brief
188 Return a a reference to the underlying DataVector.
189 */
190
191 ESCRIPT_DLL_API
192 DataTypes::ValueType&
193 getVector();
194
195 ESCRIPT_DLL_API
196 const DataTypes::ValueType&
197 getVector() const;
198
199
200 /**
201 \brief
202 Return the number of doubles stored for the Data.
203 */
204 ESCRIPT_DLL_API
205 virtual
206 ValueType::size_type
207 getLength() const;
208
209 /**
210 \brief
211 Factory method that returns a newly created DataExpanded.
212 The caller is reponsible for managing the object created.
213
214 \param region - Input - Region to copy.
215 */
216 ESCRIPT_DLL_API
217 virtual
218 DataAbstract*
219 getSlice(const DataTypes::RegionType& region) const;
220
221 /**
222 \brief
223 Copy the specified region from the given value.
224
225 \param value - Input - Data object to copy from.
226 \param region - Input - Region to copy.
227 */
228 ESCRIPT_DLL_API
229 virtual
230 void
231 setSlice(const DataAbstract* value,
232 const DataTypes::RegionType& region);
233
234 /**
235 \brief
236 setTaggedValue
237
238 Description:
239 uses tag to set a new value
240
241 \param tagKey - Input - Integer key.
242 \param pointshape - Input - The shape of the value parameter
243 \param value - Input - .
244 */
245 void
246 setTaggedValue(int tagKey,
247 const DataTypes::ShapeType& pointshape,
248 const DataTypes::ValueType& value,
249 int dataOffset=0);
250
251
252
253 /**
254 \brief
255 Computes a symmetric matrix (A + AT) / 2
256
257 \param ev - Output - symmetric matrix
258
259 */
260 ESCRIPT_DLL_API
261 virtual void
262 symmetric(DataAbstract* ev);
263
264 /**
265 \brief
266 Computes a nonsymmetric matrix (A - AT) / 2
267
268 \param ev - Output - nonsymmetric matrix
269
270 */
271 ESCRIPT_DLL_API
272 virtual void
273 nonsymmetric(DataAbstract* ev);
274
275 /**
276 \brief
277 Computes the trace of a matrix
278
279 \param ev - Output - trace of your matrix
280
281 */
282 ESCRIPT_DLL_API
283 virtual void
284 trace(DataAbstract* ev, int axis_offset);
285
286 /**
287 \brief
288 Transpose each data point of this Data object around the given axis.
289
290 \param ev - Output - transpose of your matrix
291
292 */
293 ESCRIPT_DLL_API
294 virtual void
295 transpose(DataAbstract* ev, int axis_offset);
296
297 /**
298 \brief
299 swaps components axis0 and axis1
300
301 \param ev - Output - swapped components
302
303 */
304 ESCRIPT_DLL_API
305 virtual void
306 swapaxes(DataAbstract* ev, int axis0, int axis1);
307
308
309 /**
310 \brief
311 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
312
313 \param ev - Output - eigenvalues in increasing order at each data point
314
315 */
316 ESCRIPT_DLL_API
317 virtual void
318 eigenvalues(DataAbstract* ev);
319
320 /**
321 \brief
322 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
323
324 \param ev - Output - eigenvalues in increasing order at each data point
325 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
326 and the first nonzero component is positive.
327 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
328
329 */
330
331 ESCRIPT_DLL_API
332 virtual void
333 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
334
335 /**
336 * \brief
337 * reorders data sample ordered by reference_ids to the ordering of the functions space
338 *
339 * \param reference_ids - Input - reference_ids used for current ordering
340 * */
341 ESCRIPT_DLL_API
342 virtual void
343 reorderByReferenceIDs(int *reference_ids);
344
345
346
347 protected:
348
349 private:
350
351 /**
352 \brief
353 Common initialisation called from constructors.
354
355 Description:
356 Common initialisation called from constructors.
357
358 Resizes the underlying data array to provide sufficient storage for the
359 given shape and number of data points, and creates the corresponding
360 DataArrayView of this data.
361
362 \param noSamples - Input - number of samples.
363 \param noDataPointsPerSample - Input - number of data points per sample.
364 */
365 void
366 initialise(int noSamples,
367 int noDataPointsPerSample);
368
369 /**
370 \brief
371 Copy the given data point value to all data points in this object.
372
373 Description:
374 Copy the given data point to all data points in this object.
375
376 \param value Input - A single data point value.
377 */
378 void
379 copy(const DataConstant& value);
380
381
382
383 /**
384 \brief
385 Copy the given data point value given a numarray object to all data points in this object.
386
387 Description:
388 Copy the given data point value given a numarray object to all data points in this object.
389
390 \param value Input - A single data point value.
391 */
392 void
393 copy(const boost::python::numeric::array& value);
394
395 /**
396 \brief
397 Copy the numarray object to the data points in this object.
398
399 Description:
400 Copy the numarray object to the data points in this object.
401
402 \param value Input - new values for the data points
403 */
404 void
405 copyAll(const boost::python::numeric::array& value);
406
407 /**
408 \brief
409 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
410
411 Description:
412 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
413
414 \param sampleNo Input - sample number
415 \param dataPointNo Input - data point of the sample
416 \param value Input - new values for the data point
417 */
418 ESCRIPT_DLL_API
419 virtual void
420 copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
421
422
423 /**
424 \brief
425 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
426
427 Description:
428 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
429
430 \param sampleNo Input - sample number
431 \param dataPointNo Input - data point of the sample
432 \param value Input - new values for the data point
433 */
434 void
435 copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& 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