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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (hide annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 2 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/DataExpanded.h
File MIME type: text/plain
File size: 9506 byte(s)
Merge of development branch back to main trunk on 2005-07-08

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26