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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 480 - (show annotations)
Wed Feb 1 05:15:12 2006 UTC (13 years, 10 months ago) by jgs
File MIME type: text/plain
File size: 9969 byte(s)
rationalise #includes and forward declarations

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26