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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 117 - (show annotations)
Fri Apr 1 05:48:57 2005 UTC (14 years, 4 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/DataExpanded.h
File MIME type: text/plain
File size: 8298 byte(s)
*** empty log message ***

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/scoped_ptr.hpp>
24 #include <boost/python/numeric.hpp>
25
26 namespace escript {
27
28 //
29 // Forward declarations of other Data types.
30 class DataEmpty;
31 class DataConstant;
32 class DataTagged;
33
34 /**
35 \brief
36 Give a short description of what DataExpanded does.
37
38 Description:
39 Give a detailed description of DataExpanded.
40
41 Template Parameters:
42 For templates describe any conditions that the parameters used in the
43 template must satisfy.
44 */
45
46 class DataExpanded : public DataAbstract {
47
48 public:
49
50 /**
51 \brief
52 Constructor for DataExpanded.
53
54 Description:
55 Constructor for DataExpanded.
56
57 The given single data value is copied to all the data points in
58 this data object, where the number of data points is defined by
59 the given function space.
60
61 \param value - Input - A single data value.
62 \param what - Input - A description of what this data represents.
63 */
64 DataExpanded(const boost::python::numeric::array& value,
65 const FunctionSpace& what);
66
67 /**
68 \brief
69 Alternative constructor for DataExpanded.
70
71 Description:
72 Alternative Constructor for DataExpanded.
73
74 The given single data value is copied to all the data points in
75 this data object, where the number of data points is defined by
76 the given function space.
77
78 \param value - Input - A single data value.
79 \param what - Input - A description of what this data represents.
80 */
81 DataExpanded(const DataArrayView& value,
82 const FunctionSpace& what);
83
84 /**
85 \brief
86 Alternative constructor for DataExpanded that copies a slice from
87 another DataExpanded.
88
89 \param other - Input - DataExpanded object to slice from.
90 \param region - Input - region to copy.
91 */
92 DataExpanded(const DataExpanded& other,
93 const DataArrayView::RegionType& region);
94
95 /**
96 \brief
97 Copy constructor for DataExpanded.
98 Performs a deep copy from another DataExpanded.
99 */
100 DataExpanded(const DataExpanded& other);
101
102 /**
103 \brief
104 Copy constructor for DataExpanded.
105 Construct a DataExpanded from a DataConstant.
106 */
107 DataExpanded(const DataConstant& other);
108
109 /**
110 \brief
111 Copy constructor for DataExpanded.
112 Construct a DataExpanded from a DataTagged.
113 */
114 DataExpanded(const DataTagged& other);
115
116 /**
117 \brief
118 Default destructor for DataExpanded.
119 */
120 virtual
121 ~DataExpanded();
122
123 /**
124 \brief
125 Return a textual representation of the data.
126 */
127 virtual
128 std::string
129 toString() const;
130
131 /**
132 \brief
133 Reshape the data point if the data point is currently rank 0.
134 The original data point value is used for all values of the new
135 data point.
136 */
137 void
138 reshapeDataPoint(const DataArrayView::ShapeType& shape);
139
140 /**
141 \brief
142 Return the offset for the given given data point. This returns
143 the offset in bytes for the given point into the container
144 holding the point data.
145
146 \param sampleNo - Input - sample number.
147 \param dataPointNo - Input - data point number.
148 */
149 virtual
150 DataArrayView::ValueType::size_type
151 getPointOffset(int sampleNo,
152 int dataPointNo) const;
153
154 /**
155 \brief
156 Return a view into the data array for the data point specified.
157
158 NOTE: Construction of the DataArrayView is a relatively expensive
159 operation.
160
161 \param sampleNo - Input - sample number.
162 \param dataPointNo - Input - data point number.
163 \return DataArrayView for the data point.
164 */
165 DataArrayView
166 getDataPoint(int sampleNo,
167 int dataPointNo);
168
169 /**
170 \brief
171 Return the number of doubles stored for the Data.
172 */
173 virtual
174 ValueType::size_type
175 getLength() const;
176
177 /**
178 \brief
179 Factory method that returns a newly created DataExpanded.
180 The caller is reponsible for managing the object created.
181
182 \param region - Input - Region to copy.
183 */
184 virtual
185 DataAbstract*
186 getSlice(const DataArrayView::RegionType& region) const;
187
188 /**
189 \brief
190 Copy the specified region from the given value.
191
192 \param value - Input - Data object to copy from.
193 \param region - Input - Region to copy.
194 */
195 virtual
196 void
197 setSlice(const DataAbstract* value,
198 const DataArrayView::RegionType& region);
199
200 /**
201 \brief
202 Assign the given value to all data-points associated with the given
203 reference number.
204
205 A reference number corresponds to a sample, and thus to all data-points
206 in that sample.
207
208 If the given reference number does not correspond to any sample in this
209 Data object, an exception will be thrown.
210
211 If the given value is a different shape to this Data object, an exception
212 will be thrown.
213
214 \param ref - Input - reference number which determines sample numebr to
215 assign given values to.
216 \param value - Input - Value to assign to data-point associated with
217 the given reference number.
218 */
219 virtual
220 void
221 setRefValue(int ref,
222 const DataArray& value);
223
224 /**
225 \brief
226 Return the value of the first data-point in the sample associated with
227 the given reference number.
228
229 A reference number corresponds to a sample, and thus to all data-points
230 in that sample. If there is more than one data-point per sample number
231 in this Data object, the value of the first data-point will be returned.
232
233 If the given reference number does not correspond to any sample in this
234 Data object, an exception will be thrown.
235
236 If the given value is a different shape to this Data object, an exception
237 will be thrown.
238
239 \param ref - Input - reference number which determines sample number to
240 read from.
241 \param value - Output - Object to receive data-points associated with
242 the given reference number.
243 */
244 virtual
245 void
246 getRefValue(int ref,
247 DataArray& value);
248
249 protected:
250
251 private:
252
253 /**
254 \brief
255 Common initialisation called from constructors.
256
257 Description:
258 Common initialisation called from constructors.
259
260 Resizes the underlying data array to provide sufficient storage for the
261 given shape and number of data points, and creates the corresponding
262 DataArrayView of this data.
263
264 \param shape - Input - The shape of the point data.
265 \param noSamples - Input - number of samples.
266 \param noDataPointsPerSample - Input - number of data points per sample.
267 */
268 void
269 initialise(const DataArrayView::ShapeType& shape,
270 int noSamples,
271 int noDataPointsPerSample);
272
273 /**
274 \brief
275 Copy the given data point to all data points in this object.
276
277 Description:
278 Copy the given data point to all data points in this object.
279
280 \param value Input - A single data point value.
281 */
282 void
283 copy(const DataArrayView& value);
284
285 void
286 copy(const boost::python::numeric::array& value);
287
288 //
289 // The main data storage array, a 2D array of data blocks.
290 // noSamples * noDataPointsPerSample
291 DataBlocks2D m_data;
292
293 };
294
295 } // end of namespace
296
297 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26