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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations)
Wed Mar 22 02:12:00 2006 UTC (13 years, 5 months ago) by elspeth
File MIME type: text/plain
File size: 10426 byte(s)
More copyright information.

1 // $Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
7 * Primary Business: Queensland, Australia *
8 * Licensed under the Open Software License version 3.0 *
9 * http://www.opensource.org/licenses/osl-3.0.php *
10 * *
11 ************************************************************
12 */
13
14 #if !defined escript_DataExpanded_20040323_H
15 #define escript_DataExpanded_20040323_H
16
17 #include "DataAbstract.h"
18 #include "DataBlocks2D.h"
19 #include "DataArrayView.h"
20
21 #include <boost/python/numeric.hpp>
22
23 namespace escript {
24
25 //
26 // Forward declarations of other Data types.
27 class DataConstant;
28 class DataTagged;
29
30 /**
31 \brief
32 Give a short description of what DataExpanded does.
33
34 Description:
35 Give a detailed description of DataExpanded.
36
37 Template Parameters:
38 For templates describe any conditions that the parameters used in the
39 template must satisfy.
40 */
41
42 class DataExpanded : public DataAbstract {
43
44 public:
45
46 /**
47 \brief
48 Constructor for DataExpanded.
49
50 Description:
51 Constructor for DataExpanded.
52
53 The given single data value is copied to all the data points in
54 this data object, where the number of data points is defined by
55 the given function space.
56
57 \param value - Input - A single data value.
58 \param what - Input - A description of what this data represents.
59 */
60 DataExpanded(const boost::python::numeric::array& value,
61 const FunctionSpace& what);
62
63 /**
64 \brief
65 Alternative constructor for DataExpanded.
66
67 Description:
68 Alternative Constructor for DataExpanded.
69
70 The given single data value is copied to all the data points in
71 this data object, where the number of data points is defined by
72 the given function space.
73
74 \param value - Input - A single data value.
75 \param what - Input - A description of what this data represents.
76 */
77 DataExpanded(const DataArrayView& value,
78 const FunctionSpace& what);
79
80 /**
81 \brief
82 Alternative constructor for DataExpanded that copies a slice from
83 another DataExpanded.
84
85 \param other - Input - DataExpanded object to slice from.
86 \param region - Input - region to copy.
87 */
88 DataExpanded(const DataExpanded& other,
89 const DataArrayView::RegionType& region);
90
91 /**
92 \brief
93 Alternative constructor for DataExpanded objects.
94
95 Description:
96 Alternative Constructor for DataExpanded objects.
97 \param what - Input - A description of what this data object represents.
98 \param shape - Input - the shape of each data-point.
99 \param data - the array of data values for the data-points.
100 */
101 DataExpanded(const FunctionSpace& what,
102 const DataArrayView::ShapeType &shape,
103 const DataArrayView::ValueType &data);
104
105 /**
106 \brief
107 Copy constructor for DataExpanded.
108 Performs a deep copy from another DataExpanded.
109 */
110 DataExpanded(const DataExpanded& other);
111
112 /**
113 \brief
114 Copy constructor for DataExpanded.
115 Construct a DataExpanded from a DataConstant.
116 */
117 DataExpanded(const DataConstant& other);
118
119 /**
120 \brief
121 Copy constructor for DataExpanded.
122 Construct a DataExpanded from a DataTagged.
123 */
124 DataExpanded(const DataTagged& other);
125
126 /**
127 \brief
128 Default destructor for DataExpanded.
129 */
130 virtual
131 ~DataExpanded();
132
133 /**
134 \brief
135 Return a textual representation of the data.
136 */
137 virtual
138 std::string
139 toString() const;
140
141 /**
142 \brief
143 Reshape the data point if the data point is currently rank 0.
144 The original data point value is used for all values of the new
145 data point.
146 */
147 void
148 reshapeDataPoint(const DataArrayView::ShapeType& shape);
149
150 /**
151 \brief
152 Return the offset for the given given data point. This returns
153 the offset in bytes for the given point into the container
154 holding the point data.
155
156 \param sampleNo - Input - sample number.
157 \param dataPointNo - Input - data point number.
158 */
159 virtual
160 DataArrayView::ValueType::size_type
161 getPointOffset(int sampleNo,
162 int dataPointNo) const;
163
164 /**
165 \brief
166 Return a view into the data array for the data point specified.
167
168 NOTE: Construction of the DataArrayView is a relatively expensive
169 operation.
170
171 \param sampleNo - Input - sample number.
172 \param dataPointNo - Input - data point number.
173 \return DataArrayView for the data point.
174 */
175 DataArrayView
176 getDataPoint(int sampleNo,
177 int dataPointNo);
178
179 /**
180 \brief
181 Return the number of doubles stored for the Data.
182 */
183 virtual
184 ValueType::size_type
185 getLength() const;
186
187 /**
188 \brief
189 Factory method that returns a newly created DataExpanded.
190 The caller is reponsible for managing the object created.
191
192 \param region - Input - Region to copy.
193 */
194 virtual
195 DataAbstract*
196 getSlice(const DataArrayView::RegionType& region) const;
197
198 /**
199 \brief
200 Copy the specified region from the given value.
201
202 \param value - Input - Data object to copy from.
203 \param region - Input - Region to copy.
204 */
205 virtual
206 void
207 setSlice(const DataAbstract* value,
208 const DataArrayView::RegionType& region);
209
210 /**
211 \brief
212 Assign the given value to all data-points associated with the given
213 reference number.
214
215 A reference number corresponds to a sample, and thus to all data-points
216 in that sample.
217
218 If the given reference number does not correspond to any sample in this
219 Data object, an exception will be thrown.
220
221 If the given value is a different shape to this Data object, an exception
222 will be thrown.
223
224 \param ref - Input - reference number which determines sample numebr to
225 assign given values to.
226 \param value - Input - Value to assign to data-point associated with
227 the given reference number.
228 */
229 virtual
230 void
231 setRefValue(int ref,
232 const DataArray& value);
233
234 /**
235 \brief
236 Return the value of the first data-point in the sample associated with
237 the given reference number.
238
239 A reference number corresponds to a sample, and thus to all data-points
240 in that sample. If there is more than one data-point per sample number
241 in this Data object, the value of the first data-point will be returned.
242
243 If the given reference number does not correspond to any sample in this
244 Data object, an exception will be thrown.
245
246 If the given value is a different shape to this Data object, an exception
247 will be thrown.
248
249 \param ref - Input - reference number which determines sample number to
250 read from.
251 \param value - Output - Object to receive data-points associated with
252 the given reference number.
253 */
254 virtual
255 void
256 getRefValue(int ref,
257 DataArray& value);
258
259 /**
260 \brief
261 Archive the underlying data values to the file referenced
262 by ofstream. A count of the number of values expected to be written
263 is provided as a cross-check.
264
265 The return value indicates success (0) or otherwise (1).
266 */
267 int
268 archiveData(std::ofstream& archiveFile,
269 const DataArrayView::ValueType::size_type noValues) const;
270
271 /**
272 \brief
273 Extract the number of values specified by noValues from the file
274 referenced by ifstream to the underlying data structure.
275
276 The return value indicates success (0) or otherwise (1).
277 */
278 int
279 extractData(std::ifstream& archiveFile,
280 const DataArrayView::ValueType::size_type noValues);
281
282 /**
283 \brief
284 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
285
286 \param ev - Output - eigenvalues in increasing order at each data point
287
288 */
289 virtual void
290 eigenvalues(DataAbstract* ev);
291
292 /**
293 \brief
294 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
295
296 \param ev - Output - eigenvalues in increasing order at each data point
297 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
298 and the first nonzero component is positive.
299 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
300
301 */
302
303 virtual void
304 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
305
306
307 protected:
308
309 private:
310
311 /**
312 \brief
313 Common initialisation called from constructors.
314
315 Description:
316 Common initialisation called from constructors.
317
318 Resizes the underlying data array to provide sufficient storage for the
319 given shape and number of data points, and creates the corresponding
320 DataArrayView of this data.
321
322 \param shape - Input - The shape of the point data.
323 \param noSamples - Input - number of samples.
324 \param noDataPointsPerSample - Input - number of data points per sample.
325 */
326 void
327 initialise(const DataArrayView::ShapeType& shape,
328 int noSamples,
329 int noDataPointsPerSample);
330
331 /**
332 \brief
333 Copy the given data point value to all data points in this object.
334
335 Description:
336 Copy the given data point to all data points in this object.
337
338 \param value Input - A single data point value.
339 */
340 void
341 copy(const DataArrayView& value);
342
343 /**
344 \brief
345 Copy the given data point value given a numarray object to all data points in this object.
346
347 Description:
348 Copy the given data point value given a numarray object to all data points in this object.
349
350 \param value Input - A single data point value.
351 */
352 void
353 copy(const boost::python::numeric::array& value);
354
355 /**
356 \brief
357 Copy the numarray object to the data points in this object.
358
359 Description:
360 Copy the numarray object to the data points in this object.
361
362 \param value Input - new values for the data points
363 */
364 void
365 copyAll(const boost::python::numeric::array& value);
366
367 //
368 // The main data storage array, a 2D array of data blocks.
369 // noSamples * noDataPointsPerSample
370 DataBlocks2D m_data;
371
372 };
373
374 } // end of namespace
375
376 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26