1 |
// $Id$ |
|
2 |
/* |
/* $Id$ */ |
3 |
************************************************************ |
|
4 |
* Copyright 2006 by ACcESS MNRF * |
/******************************************************* |
5 |
* * |
* |
6 |
* http://www.access.edu.au * |
* Copyright 2003-2007 by ACceSS MNRF |
7 |
* Primary Business: Queensland, Australia * |
* Copyright 2007 by University of Queensland |
8 |
* Licensed under the Open Software License version 3.0 * |
* |
9 |
* http://www.opensource.org/licenses/osl-3.0.php * |
* http://esscc.uq.edu.au |
10 |
* * |
* Primary Business: Queensland, Australia |
11 |
************************************************************ |
* Licensed under the Open Software License version 3.0 |
12 |
*/ |
* http://www.opensource.org/licenses/osl-3.0.php |
13 |
|
* |
14 |
|
*******************************************************/ |
15 |
|
|
16 |
#if !defined escript_DataExpanded_20040323_H |
#if !defined escript_DataExpanded_20040323_H |
17 |
#define escript_DataExpanded_20040323_H |
#define escript_DataExpanded_20040323_H |
19 |
|
|
20 |
#include "DataAbstract.h" |
#include "DataAbstract.h" |
21 |
#include "DataBlocks2D.h" |
#include "DataBlocks2D.h" |
|
#include "DataArrayView.h" |
|
22 |
|
|
23 |
#include <boost/python/numeric.hpp> |
#include <boost/python/numeric.hpp> |
24 |
|
|
63 |
DataExpanded(const boost::python::numeric::array& value, |
DataExpanded(const boost::python::numeric::array& value, |
64 |
const FunctionSpace& what); |
const FunctionSpace& what); |
65 |
|
|
66 |
/** |
// /** |
67 |
\brief |
// \brief |
68 |
Alternative constructor for DataExpanded. |
// Alternative constructor for DataExpanded. |
69 |
|
// |
70 |
Description: |
// Description: |
71 |
Alternative Constructor for DataExpanded. |
// Alternative Constructor for DataExpanded. |
72 |
|
// |
73 |
The given single data value is copied to all the data points in |
// The given single data value is copied to all the data points in |
74 |
this data object, where the number of data points is defined by |
// this data object, where the number of data points is defined by |
75 |
the given function space. |
// the given function space. |
76 |
|
// |
77 |
\param value - Input - A single data value. |
// \param value - Input - A single data value. |
78 |
\param what - Input - A description of what this data represents. |
// \param what - Input - A description of what this data represents. |
79 |
*/ |
// */ |
80 |
ESCRIPT_DLL_API |
// ESCRIPT_DLL_API |
81 |
DataExpanded(const DataArrayView& value, |
// DataExpanded(const DataArrayView& value, |
82 |
const FunctionSpace& what); |
// const FunctionSpace& what); |
83 |
|
|
84 |
/** |
/** |
85 |
\brief |
\brief |
91 |
*/ |
*/ |
92 |
ESCRIPT_DLL_API |
ESCRIPT_DLL_API |
93 |
DataExpanded(const DataExpanded& other, |
DataExpanded(const DataExpanded& other, |
94 |
const DataArrayView::RegionType& region); |
const DataTypes::RegionType& region); |
95 |
|
|
96 |
/** |
/** |
97 |
\brief |
\brief |
102 |
\param what - Input - A description of what this data object represents. |
\param what - Input - A description of what this data object represents. |
103 |
\param shape - Input - the shape of each data-point. |
\param shape - Input - the shape of each data-point. |
104 |
\param data - the array of data values for the data-points. |
\param data - the array of data values for the data-points. |
105 |
|
|
106 |
|
TODO Note that this constructor will also copy data to all points if it only contains enough elements to hold a single point. ie this is the merge of two separate constructors. |
107 |
*/ |
*/ |
108 |
ESCRIPT_DLL_API |
ESCRIPT_DLL_API |
109 |
DataExpanded(const FunctionSpace& what, |
DataExpanded(const FunctionSpace& what, |
110 |
const DataArrayView::ShapeType &shape, |
const DataTypes::ShapeType &shape, |
111 |
const DataArrayView::ValueType &data); |
const DataTypes::ValueType &data); |
112 |
|
|
113 |
/** |
/** |
114 |
\brief |
\brief |
150 |
virtual |
virtual |
151 |
std::string |
std::string |
152 |
toString() const; |
toString() const; |
153 |
|
/** |
154 |
|
\brief |
155 |
|
dumps the object into a netCDF file |
156 |
|
*/ |
157 |
|
ESCRIPT_DLL_API |
158 |
|
virtual |
159 |
|
void |
160 |
|
dump(const std::string fileName) const; |
161 |
|
|
162 |
|
/** |
163 |
|
\brief |
164 |
|
sets all values to zero |
165 |
|
*/ |
166 |
|
ESCRIPT_DLL_API |
167 |
|
virtual |
168 |
|
void |
169 |
|
setToZero(); |
170 |
|
|
171 |
/** |
/** |
172 |
\brief |
\brief |
179 |
*/ |
*/ |
180 |
ESCRIPT_DLL_API |
ESCRIPT_DLL_API |
181 |
virtual |
virtual |
182 |
DataArrayView::ValueType::size_type |
DataTypes::ValueType::size_type |
183 |
getPointOffset(int sampleNo, |
getPointOffset(int sampleNo, |
184 |
int dataPointNo) const; |
int dataPointNo) const; |
185 |
|
|
186 |
/** |
// /** |
187 |
\brief |
/* \brief |
188 |
Return a view into the data array for the data point specified. |
Return a view into the data array for the data point specified. |
189 |
|
|
190 |
NOTE: Construction of the DataArrayView is a relatively expensive |
NOTE: Construction of the DataArrayView is a relatively expensive |
192 |
|
|
193 |
\param sampleNo - Input - sample number. |
\param sampleNo - Input - sample number. |
194 |
\param dataPointNo - Input - data point number. |
\param dataPointNo - Input - data point number. |
195 |
\return DataArrayView for the data point. |
\return DataArrayView for the data point.*/ |
196 |
|
// */ |
197 |
|
// ESCRIPT_DLL_API |
198 |
|
// DataArrayView |
199 |
|
// getDataPoint(int sampleNo, |
200 |
|
// int dataPointNo); |
201 |
|
|
202 |
|
|
203 |
|
/** |
204 |
|
\brief |
205 |
|
Return a a reference to the underlying DataVector. |
206 |
*/ |
*/ |
207 |
|
|
208 |
ESCRIPT_DLL_API |
ESCRIPT_DLL_API |
209 |
DataArrayView |
DataTypes::ValueType& |
210 |
getDataPoint(int sampleNo, |
getVector(); |
211 |
int dataPointNo); |
|
212 |
|
ESCRIPT_DLL_API |
213 |
|
const DataTypes::ValueType& |
214 |
|
getVector() const; |
215 |
|
|
216 |
|
|
217 |
/** |
/** |
218 |
\brief |
\brief |
233 |
ESCRIPT_DLL_API |
ESCRIPT_DLL_API |
234 |
virtual |
virtual |
235 |
DataAbstract* |
DataAbstract* |
236 |
getSlice(const DataArrayView::RegionType& region) const; |
getSlice(const DataTypes::RegionType& region) const; |
237 |
|
|
238 |
/** |
/** |
239 |
\brief |
\brief |
246 |
virtual |
virtual |
247 |
void |
void |
248 |
setSlice(const DataAbstract* value, |
setSlice(const DataAbstract* value, |
249 |
const DataArrayView::RegionType& region); |
const DataTypes::RegionType& region); |
250 |
|
|
|
/** |
|
|
\brief |
|
|
Assign the given value to all data-points associated with the given |
|
|
reference number. |
|
251 |
|
|
252 |
A reference number corresponds to a sample, and thus to all data-points |
// /** |
253 |
in that sample. |
/* \brief |
254 |
|
setTaggedValue |
255 |
|
|
256 |
If the given reference number does not correspond to any sample in this |
Description: |
257 |
Data object, an exception will be thrown. |
uses tag to set a new value |
258 |
|
|
259 |
|
\param tagKey - Input - Integer key. |
260 |
|
\param value - Input - Single DataArrayView value to be assigned to the tag.*/ |
261 |
|
// */ |
262 |
|
// ESCRIPT_DLL_API |
263 |
|
// virtual |
264 |
|
// void |
265 |
|
// setTaggedValue(int tagKey, |
266 |
|
// const DataArrayView& value); |
267 |
|
|
|
If the given value is a different shape to this Data object, an exception |
|
|
will be thrown. |
|
268 |
|
|
|
\param ref - Input - reference number which determines sample numebr to |
|
|
assign given values to. |
|
|
\param value - Input - Value to assign to data-point associated with |
|
|
the given reference number. |
|
|
*/ |
|
|
ESCRIPT_DLL_API |
|
|
virtual |
|
|
void |
|
|
setRefValue(int ref, |
|
|
const DataArray& value); |
|
269 |
|
|
270 |
/** |
/** |
271 |
\brief |
\brief |
272 |
Return the value of the first data-point in the sample associated with |
setTaggedValue |
|
the given reference number. |
|
|
|
|
|
A reference number corresponds to a sample, and thus to all data-points |
|
|
in that sample. If there is more than one data-point per sample number |
|
|
in this Data object, the value of the first data-point will be returned. |
|
|
|
|
|
If the given reference number does not correspond to any sample in this |
|
|
Data object, an exception will be thrown. |
|
|
|
|
|
If the given value is a different shape to this Data object, an exception |
|
|
will be thrown. |
|
|
|
|
|
\param ref - Input - reference number which determines sample number to |
|
|
read from. |
|
|
\param value - Output - Object to receive data-points associated with |
|
|
the given reference number. |
|
|
*/ |
|
|
ESCRIPT_DLL_API |
|
|
virtual |
|
|
void |
|
|
getRefValue(int ref, |
|
|
DataArray& value); |
|
273 |
|
|
274 |
/** |
Description: |
275 |
\brief |
uses tag to set a new value |
|
Archive the underlying data values to the file referenced |
|
|
by ofstream. A count of the number of values expected to be written |
|
|
is provided as a cross-check. |
|
276 |
|
|
277 |
The return value indicates success (0) or otherwise (1). |
\param tagKey - Input - Integer key. |
278 |
*/ |
\param pointshape - Input - The shape of the value parameter |
279 |
ESCRIPT_DLL_API |
\param value - Input - . |
280 |
int |
*/ |
281 |
archiveData(std::ofstream& archiveFile, |
void |
282 |
const DataArrayView::ValueType::size_type noValues) const; |
setTaggedValue(int tagKey, |
283 |
|
const DataTypes::ShapeType& pointshape, |
284 |
|
const DataTypes::ValueType& value, |
285 |
|
int dataOffset=0); |
286 |
|
|
|
/** |
|
|
\brief |
|
|
Extract the number of values specified by noValues from the file |
|
|
referenced by ifstream to the underlying data structure. |
|
287 |
|
|
|
The return value indicates success (0) or otherwise (1). |
|
|
*/ |
|
|
ESCRIPT_DLL_API |
|
|
int |
|
|
extractData(std::ifstream& archiveFile, |
|
|
const DataArrayView::ValueType::size_type noValues); |
|
288 |
|
|
289 |
/** |
/** |
290 |
\brief |
\brief |
368 |
virtual void |
virtual void |
369 |
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13); |
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13); |
370 |
|
|
371 |
|
/** |
372 |
|
* \brief |
373 |
|
* reorders data sample ordered by reference_ids to the ordering of the functions space |
374 |
|
* |
375 |
|
* \param reference_ids - Input - reference_ids used for current ordering |
376 |
|
* */ |
377 |
|
ESCRIPT_DLL_API |
378 |
|
virtual void |
379 |
|
reorderByReferenceIDs(int *reference_ids); |
380 |
|
|
381 |
|
|
382 |
|
|
383 |
protected: |
protected: |
384 |
|
|
395 |
given shape and number of data points, and creates the corresponding |
given shape and number of data points, and creates the corresponding |
396 |
DataArrayView of this data. |
DataArrayView of this data. |
397 |
|
|
|
\param shape - Input - The shape of the point data. |
|
398 |
\param noSamples - Input - number of samples. |
\param noSamples - Input - number of samples. |
399 |
\param noDataPointsPerSample - Input - number of data points per sample. |
\param noDataPointsPerSample - Input - number of data points per sample. |
400 |
*/ |
*/ |
401 |
void |
void |
402 |
initialise(const DataArrayView::ShapeType& shape, |
initialise(int noSamples, |
|
int noSamples, |
|
403 |
int noDataPointsPerSample); |
int noDataPointsPerSample); |
404 |
|
|
405 |
/** |
/** |
412 |
\param value Input - A single data point value. |
\param value Input - A single data point value. |
413 |
*/ |
*/ |
414 |
void |
void |
415 |
copy(const DataArrayView& value); |
copy(const DataConstant& value); |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
/** |
/** |
420 |
\brief |
\brief |
440 |
void |
void |
441 |
copyAll(const boost::python::numeric::array& value); |
copyAll(const boost::python::numeric::array& value); |
442 |
|
|
443 |
|
/** |
444 |
|
\brief |
445 |
|
Copy a double value to the data point dataPointNo of sample sampleNo in this object. |
446 |
|
|
447 |
|
Description: |
448 |
|
Copy a double value to the data point dataPointNo of sample sampleNo in this object. |
449 |
|
|
450 |
|
\param sampleNo Input - sample number |
451 |
|
\param dataPointNo Input - data point of the sample |
452 |
|
\param value Input - new values for the data point |
453 |
|
*/ |
454 |
|
ESCRIPT_DLL_API |
455 |
|
virtual void |
456 |
|
copyToDataPoint(const int sampleNo, const int dataPointNo, const double value); |
457 |
|
|
458 |
|
|
459 |
|
/** |
460 |
|
\brief |
461 |
|
Copy the numarray object to the data point dataPointNo of sample sampleNo in this object. |
462 |
|
|
463 |
|
Description: |
464 |
|
Copy the numarray object to the data point dataPointNo of sample sampleNo in this object. |
465 |
|
|
466 |
|
\param sampleNo Input - sample number |
467 |
|
\param dataPointNo Input - data point of the sample |
468 |
|
\param value Input - new values for the data point |
469 |
|
*/ |
470 |
|
void |
471 |
|
copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value); |
472 |
|
|
473 |
// |
// |
474 |
// The main data storage array, a 2D array of data blocks. |
// The main data storage array, a 2D array of data blocks. |
475 |
// noSamples * noDataPointsPerSample |
// noSamples * noDataPointsPerSample |