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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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 jgs 480
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/python/numeric.hpp>
24    
25     namespace escript {
26    
27 jgs 117 //
28     // Forward declarations of other Data types.
29 jgs 102 class DataConstant;
30     class DataTagged;
31 jgs 82
32     /**
33     \brief
34     Give a short description of what DataExpanded does.
35    
36     Description:
37 jgs 117 Give a detailed description of DataExpanded.
38 jgs 82
39     Template Parameters:
40     For templates describe any conditions that the parameters used in the
41 jgs 117 template must satisfy.
42 jgs 82 */
43    
44 jgs 117 class DataExpanded : public DataAbstract {
45 jgs 82
46     public:
47    
48     /**
49     \brief
50 jgs 117 Constructor for DataExpanded.
51 jgs 82
52 jgs 117 Description:
53     Constructor for DataExpanded.
54 jgs 82
55 jgs 117 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 jgs 82
59 jgs 117 \param value - Input - A single data value.
60 jgs 82 \param what - Input - A description of what this data represents.
61     */
62 jgs 102 DataExpanded(const boost::python::numeric::array& value,
63     const FunctionSpace& what);
64 jgs 82
65     /**
66     \brief
67 jgs 117 Alternative constructor for DataExpanded.
68 jgs 82
69     Description:
70 jgs 102 Alternative Constructor for DataExpanded.
71 jgs 117
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 jgs 82 \param what - Input - A description of what this data represents.
78     */
79 jgs 102 DataExpanded(const DataArrayView& value,
80     const FunctionSpace& what);
81 jgs 82
82     /**
83     \brief
84     Alternative constructor for DataExpanded that copies a slice from
85     another DataExpanded.
86    
87 jgs 102 \param other - Input - DataExpanded object to slice from.
88     \param region - Input - region to copy.
89 jgs 82 */
90 jgs 102 DataExpanded(const DataExpanded& other,
91     const DataArrayView::RegionType& region);
92 jgs 82
93     /**
94     \brief
95 jgs 119 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 jgs 122 \param data - the array of data values for the data-points.
102 jgs 119 */
103     DataExpanded(const FunctionSpace& what,
104     const DataArrayView::ShapeType &shape,
105     const DataArrayView::ValueType &data);
106    
107     /**
108     \brief
109 jgs 117 Copy constructor for DataExpanded.
110     Performs a deep copy from another DataExpanded.
111 jgs 82 */
112 jgs 117 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 jgs 102 virtual
133     ~DataExpanded();
134 jgs 82
135     /**
136     \brief
137 jgs 117 Return a textual representation of the data.
138 jgs 82 */
139 jgs 102 virtual
140     std::string
141     toString() const;
142 jgs 82
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 jgs 102 void
150     reshapeDataPoint(const DataArrayView::ShapeType& shape);
151 jgs 82
152     /**
153     \brief
154 jgs 117 Return the offset for the given given data point. This returns
155     the offset in bytes for the given point into the container
156 jgs 82 holding the point data.
157 jgs 117
158     \param sampleNo - Input - sample number.
159     \param dataPointNo - Input - data point number.
160 jgs 82 */
161 jgs 102 virtual
162     DataArrayView::ValueType::size_type
163     getPointOffset(int sampleNo,
164     int dataPointNo) const;
165 jgs 82
166     /**
167     \brief
168 jgs 117 Return a view into the data array for the data point specified.
169    
170 jgs 82 NOTE: Construction of the DataArrayView is a relatively expensive
171 jgs 102 operation.
172 jgs 117
173     \param sampleNo - Input - sample number.
174     \param dataPointNo - Input - data point number.
175     \return DataArrayView for the data point.
176 jgs 82 */
177 jgs 102 DataArrayView
178     getDataPoint(int sampleNo,
179     int dataPointNo);
180 jgs 82
181     /**
182     \brief
183 jgs 102 Return the number of doubles stored for the Data.
184 jgs 82 */
185 jgs 102 virtual
186     ValueType::size_type
187     getLength() const;
188 jgs 82
189     /**
190     \brief
191     Factory method that returns a newly created DataExpanded.
192     The caller is reponsible for managing the object created.
193 jgs 117
194 jgs 82 \param region - Input - Region to copy.
195     */
196 jgs 102 virtual
197     DataAbstract*
198     getSlice(const DataArrayView::RegionType& region) const;
199 jgs 82
200     /**
201     \brief
202     Copy the specified region from the given value.
203 jgs 117
204     \param value - Input - Data object to copy from.
205 jgs 82 \param region - Input - Region to copy.
206     */
207 jgs 102 virtual
208     void
209     setSlice(const DataAbstract* value,
210     const DataArrayView::RegionType& region);
211 jgs 82
212 jgs 110 /**
213     \brief
214 jgs 113 Assign the given value to all data-points associated with the given
215 jgs 110 reference number.
216    
217     A reference number corresponds to a sample, and thus to all data-points
218 jgs 113 in that sample.
219 jgs 110
220 jgs 113 If the given reference number does not correspond to any sample in this
221     Data object, an exception will be thrown.
222    
223 jgs 110 If the given value is a different shape to this Data object, an exception
224     will be thrown.
225    
226 jgs 113 \param ref - Input - reference number which determines sample numebr to
227     assign given values to.
228 jgs 110 \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 jgs 113 Return the value of the first data-point in the sample associated with
239     the given reference number.
240 jgs 110
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 jgs 113 in this Data object, the value of the first data-point will be returned.
244 jgs 110
245 jgs 113 If the given reference number does not correspond to any sample in this
246     Data object, an exception will be thrown.
247    
248 jgs 110 If the given value is a different shape to this Data object, an exception
249     will be thrown.
250    
251 jgs 113 \param ref - Input - reference number which determines sample number to
252     read from.
253 jgs 110 \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 jgs 123 /**
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 jgs 82 protected:
285    
286     private:
287    
288     /**
289     \brief
290 jgs 117 Common initialisation called from constructors.
291 jgs 82
292     Description:
293 jgs 117 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 jgs 82 \param shape - Input - The shape of the point data.
300     \param noSamples - Input - number of samples.
301 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
302 jgs 82 */
303 jgs 102 void
304     initialise(const DataArrayView::ShapeType& shape,
305     int noSamples,
306     int noDataPointsPerSample);
307 jgs 82
308     /**
309     \brief
310 jgs 126 Copy the given data point value to all data points in this object.
311 jgs 82
312     Description:
313 jgs 117 Copy the given data point to all data points in this object.
314    
315     \param value Input - A single data point value.
316 jgs 82 */
317 jgs 102 void
318     copy(const DataArrayView& value);
319 jgs 82
320 jgs 126 /**
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 jgs 102 void
330     copy(const boost::python::numeric::array& value);
331    
332 jgs 126 /**
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 jgs 82 //
345 jgs 117 // The main data storage array, a 2D array of data blocks.
346     // noSamples * noDataPointsPerSample
347 jgs 82 DataBlocks2D m_data;
348    
349     };
350    
351     } // end of namespace
352 jgs 102
353 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26