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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 117 - (hide annotations)
Fri Apr 1 05:48:57 2005 UTC (14 years, 5 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 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 117 Copy constructor for DataExpanded.
98     Performs a deep copy from another DataExpanded.
99 jgs 82 */
100 jgs 117 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 jgs 102 virtual
121     ~DataExpanded();
122 jgs 82
123     /**
124     \brief
125 jgs 117 Return a textual representation of the data.
126 jgs 82 */
127 jgs 102 virtual
128     std::string
129     toString() const;
130 jgs 82
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 jgs 102 void
138     reshapeDataPoint(const DataArrayView::ShapeType& shape);
139 jgs 82
140     /**
141     \brief
142 jgs 117 Return the offset for the given given data point. This returns
143     the offset in bytes for the given point into the container
144 jgs 82 holding the point data.
145 jgs 117
146     \param sampleNo - Input - sample number.
147     \param dataPointNo - Input - data point number.
148 jgs 82 */
149 jgs 102 virtual
150     DataArrayView::ValueType::size_type
151     getPointOffset(int sampleNo,
152     int dataPointNo) const;
153 jgs 82
154     /**
155     \brief
156 jgs 117 Return a view into the data array for the data point specified.
157    
158 jgs 82 NOTE: Construction of the DataArrayView is a relatively expensive
159 jgs 102 operation.
160 jgs 117
161     \param sampleNo - Input - sample number.
162     \param dataPointNo - Input - data point number.
163     \return DataArrayView for the data point.
164 jgs 82 */
165 jgs 102 DataArrayView
166     getDataPoint(int sampleNo,
167     int dataPointNo);
168 jgs 82
169     /**
170     \brief
171 jgs 102 Return the number of doubles stored for the Data.
172 jgs 82 */
173 jgs 102 virtual
174     ValueType::size_type
175     getLength() const;
176 jgs 82
177     /**
178     \brief
179     Factory method that returns a newly created DataExpanded.
180     The caller is reponsible for managing the object created.
181 jgs 117
182 jgs 82 \param region - Input - Region to copy.
183     */
184 jgs 102 virtual
185     DataAbstract*
186     getSlice(const DataArrayView::RegionType& region) const;
187 jgs 82
188     /**
189     \brief
190     Copy the specified region from the given value.
191 jgs 117
192     \param value - Input - Data object to copy from.
193 jgs 82 \param region - Input - Region to copy.
194     */
195 jgs 102 virtual
196     void
197     setSlice(const DataAbstract* value,
198     const DataArrayView::RegionType& region);
199 jgs 82
200 jgs 110 /**
201     \brief
202 jgs 113 Assign the given value to all data-points associated with the given
203 jgs 110 reference number.
204    
205     A reference number corresponds to a sample, and thus to all data-points
206 jgs 113 in that sample.
207 jgs 110
208 jgs 113 If the given reference number does not correspond to any sample in this
209     Data object, an exception will be thrown.
210    
211 jgs 110 If the given value is a different shape to this Data object, an exception
212     will be thrown.
213    
214 jgs 113 \param ref - Input - reference number which determines sample numebr to
215     assign given values to.
216 jgs 110 \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 jgs 113 Return the value of the first data-point in the sample associated with
227     the given reference number.
228 jgs 110
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 jgs 113 in this Data object, the value of the first data-point will be returned.
232 jgs 110
233 jgs 113 If the given reference number does not correspond to any sample in this
234     Data object, an exception will be thrown.
235    
236 jgs 110 If the given value is a different shape to this Data object, an exception
237     will be thrown.
238    
239 jgs 113 \param ref - Input - reference number which determines sample number to
240     read from.
241 jgs 110 \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 jgs 82 protected:
250    
251     private:
252    
253     /**
254     \brief
255 jgs 117 Common initialisation called from constructors.
256 jgs 82
257     Description:
258 jgs 117 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 jgs 82 \param shape - Input - The shape of the point data.
265     \param noSamples - Input - number of samples.
266 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
267 jgs 82 */
268 jgs 102 void
269     initialise(const DataArrayView::ShapeType& shape,
270     int noSamples,
271     int noDataPointsPerSample);
272 jgs 82
273     /**
274     \brief
275 jgs 117 Copy the given data point to all data points in this object.
276 jgs 82
277     Description:
278 jgs 117 Copy the given data point to all data points in this object.
279    
280     \param value Input - A single data point value.
281 jgs 82 */
282 jgs 102 void
283     copy(const DataArrayView& value);
284 jgs 82
285 jgs 102 void
286     copy(const boost::python::numeric::array& value);
287    
288 jgs 82 //
289 jgs 117 // The main data storage array, a 2D array of data blocks.
290     // noSamples * noDataPointsPerSample
291 jgs 82 DataBlocks2D m_data;
292    
293     };
294    
295     } // end of namespace
296 jgs 102
297 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26