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