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_DataConstant_20040323_H |
17 |
jgs |
82 |
#define escript_DataConstant_20040323_H |
18 |
|
|
|
19 |
|
|
#include "escript/Data/DataAbstract.h" |
20 |
|
|
#include "escript/Data/DataArray.h" |
21 |
|
|
#include "escript/Data/DataArrayView.h" |
22 |
|
|
|
23 |
|
|
#include <boost/python/numeric.hpp> |
24 |
|
|
|
25 |
|
|
namespace escript { |
26 |
jgs |
102 |
|
27 |
jgs |
82 |
/** |
28 |
|
|
\brief |
29 |
jgs |
102 |
DataConstant stores a single data point which represents the entire |
30 |
jgs |
82 |
function space. |
31 |
|
|
|
32 |
|
|
Description: |
33 |
jgs |
102 |
DataConstant stores a single data point which represents the entire |
34 |
jgs |
82 |
function space. |
35 |
|
|
*/ |
36 |
jgs |
102 |
class DataConstant : public DataAbstract { |
37 |
jgs |
82 |
|
38 |
|
|
public: |
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
\brief |
42 |
jgs |
102 |
Constructor for DataConstant objects. |
43 |
jgs |
82 |
|
44 |
|
|
Description: |
45 |
jgs |
102 |
Constructor for DataConstant objects. |
46 |
jgs |
82 |
|
47 |
jgs |
102 |
\param value - Input - Data value for a single point. |
48 |
|
|
\param what - Input - A description of what this data object represents. |
49 |
|
|
*/ |
50 |
|
|
DataConstant(const boost::python::numeric::array& value, |
51 |
|
|
const FunctionSpace& what); |
52 |
jgs |
100 |
|
53 |
jgs |
82 |
/** |
54 |
|
|
\brief |
55 |
|
|
Copy constructor. Performs a deep copy. |
56 |
|
|
*/ |
57 |
|
|
DataConstant(const DataConstant& other); |
58 |
jgs |
102 |
|
59 |
jgs |
82 |
/** |
60 |
|
|
\brief |
61 |
jgs |
102 |
Alternative constructor for DataConstant objects. |
62 |
jgs |
82 |
|
63 |
|
|
Description: |
64 |
jgs |
102 |
Alternative Constructor for DataConstant objects. |
65 |
|
|
\param value - Input - Data value for a single point. |
66 |
|
|
\param what - Input - A description of what this data object represents. |
67 |
jgs |
82 |
*/ |
68 |
jgs |
102 |
DataConstant(const DataArrayView& value, |
69 |
|
|
const FunctionSpace& what); |
70 |
|
|
|
71 |
jgs |
82 |
/** |
72 |
|
|
\brief |
73 |
jgs |
102 |
Alternative constructor for DataConstant objects. |
74 |
jgs |
82 |
|
75 |
|
|
Description: |
76 |
jgs |
102 |
Alternative Constructor for DataConstant objects. |
77 |
|
|
\param other - Input - Data object to copy from. |
78 |
|
|
\param region - Input - region to copy. |
79 |
jgs |
82 |
*/ |
80 |
jgs |
102 |
DataConstant(const DataConstant& other, |
81 |
|
|
const DataArrayView::RegionType& region); |
82 |
|
|
|
83 |
jgs |
82 |
/** |
84 |
|
|
\brief |
85 |
|
|
Write the data as a string. |
86 |
|
|
*/ |
87 |
jgs |
102 |
std::string |
88 |
|
|
toString() const; |
89 |
|
|
|
90 |
jgs |
82 |
/** |
91 |
|
|
\brief |
92 |
jgs |
102 |
Return the offset for the given sample. This is a somewhat artificial notion |
93 |
jgs |
82 |
but returns the offset in bytes for the given point into the container |
94 |
|
|
holding the point data. Only really necessary to avoid many DataArrayView |
95 |
|
|
objects. |
96 |
jgs |
102 |
\param sampleNo - Input - sample number. |
97 |
|
|
\param dataPointNo - Input - data point number for the sample. |
98 |
jgs |
82 |
*/ |
99 |
jgs |
102 |
virtual |
100 |
|
|
DataArrayView::ValueType::size_type |
101 |
|
|
getPointOffset(int sampleNo, |
102 |
|
|
int dataPointNo) const; |
103 |
|
|
|
104 |
jgs |
82 |
/** |
105 |
|
|
\brief |
106 |
|
|
Return a view into the data for the data point specified. |
107 |
jgs |
102 |
\param sampleNo - Input - sample number. |
108 |
|
|
\param dataPointNo - Input - data point number for the sample. |
109 |
jgs |
82 |
*/ |
110 |
jgs |
102 |
virtual |
111 |
|
|
DataArrayView |
112 |
|
|
getDataPoint(int sampleNo, |
113 |
|
|
int dataPointNo); |
114 |
|
|
|
115 |
jgs |
82 |
/** |
116 |
|
|
\brief |
117 |
jgs |
102 |
Return the number of doubles stored for the Data object. |
118 |
jgs |
82 |
*/ |
119 |
jgs |
102 |
virtual |
120 |
|
|
ValueType::size_type |
121 |
|
|
getLength() const; |
122 |
|
|
|
123 |
jgs |
82 |
/** |
124 |
|
|
\brief |
125 |
jgs |
102 |
Factory method that returns a newly created DataConstant object |
126 |
|
|
sliced from the specified region of this object. |
127 |
jgs |
82 |
The caller is reponsible for managing the object created. |
128 |
jgs |
102 |
\param region - Input - region to slice from this object. |
129 |
jgs |
82 |
*/ |
130 |
jgs |
102 |
virtual |
131 |
|
|
DataAbstract* |
132 |
|
|
getSlice(const DataArrayView::RegionType& region) const; |
133 |
|
|
|
134 |
|
|
/** |
135 |
jgs |
82 |
\brief |
136 |
|
|
Copy the specified region from the given value. |
137 |
jgs |
102 |
\param value - Input - Data object to copy from. |
138 |
|
|
\param region - Input - Region to copy. |
139 |
jgs |
82 |
*/ |
140 |
jgs |
102 |
virtual |
141 |
|
|
void |
142 |
|
|
setSlice(const DataAbstract* value, |
143 |
|
|
const DataArrayView::RegionType& region); |
144 |
|
|
|
145 |
jgs |
82 |
/** |
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 |
|
|
|
154 |
jgs |
82 |
protected: |
155 |
|
|
|
156 |
|
|
private: |
157 |
|
|
// |
158 |
jgs |
102 |
// the actual data |
159 |
jgs |
82 |
DataArrayView::ValueType m_data; |
160 |
jgs |
102 |
|
161 |
jgs |
82 |
}; |
162 |
|
|
|
163 |
|
|
} // end of namespace |
164 |
|
|
#endif |