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

Contents of /trunk/escript/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations)
Wed Mar 22 02:12:00 2006 UTC (13 years, 6 months ago) by elspeth
File MIME type: text/plain
File size: 6274 byte(s)
More copyright information.

1 //$Id$
2 /*
3 ************************************************************
4 * Copyright 2006 by ACcESS MNRF *
5 * *
6 * http://www.access.edu.au *
7 * Primary Business: Queensland, Australia *
8 * Licensed under the Open Software License version 3.0 *
9 * http://www.opensource.org/licenses/osl-3.0.php *
10 * *
11 ************************************************************
12 */
13
14 #if !defined escript_DataConstant_20040323_H
15 #define escript_DataConstant_20040323_H
16
17 #include "DataAbstract.h"
18 #include "DataArrayView.h"
19
20 #include <boost/python/numeric.hpp>
21
22 namespace escript {
23
24 /**
25 \brief
26 DataConstant stores a single data point which represents the entire
27 function space.
28
29 Description:
30 DataConstant stores a single data point which represents the entire
31 function space.
32 */
33 class DataConstant : public DataAbstract {
34
35 public:
36
37 /**
38 \brief
39 Constructor for DataConstant objects.
40
41 Description:
42 Constructor for DataConstant objects.
43
44 \param value - Input - Data value for a single point.
45 \param what - Input - A description of what this data object represents.
46 */
47 DataConstant(const boost::python::numeric::array& value,
48 const FunctionSpace& what);
49
50 /**
51 \brief
52 Copy constructor. Performs a deep copy.
53 */
54 DataConstant(const DataConstant& other);
55
56 /**
57 \brief
58 Alternative constructor for DataConstant objects.
59
60 Description:
61 Alternative Constructor for DataConstant objects.
62 \param value - Input - Data value for a single point.
63 \param what - Input - A description of what this data object represents.
64 */
65 DataConstant(const DataArrayView& value,
66 const FunctionSpace& what);
67
68 /**
69 \brief
70 Alternative constructor for DataConstant objects.
71
72 Description:
73 Alternative Constructor for DataConstant objects.
74 \param other - Input - Data object to copy from.
75 \param region - Input - region to copy.
76 */
77 DataConstant(const DataConstant& other,
78 const DataArrayView::RegionType& region);
79
80 /**
81 \brief
82 Alternative constructor for DataConstant objects.
83
84 Description:
85 Alternative Constructor for DataConstant objects.
86 \param what - Input - A description of what this data object represents.
87 \param shape - Input - the shape of each data-point.
88 \param data - the data values for each data-point.
89 */
90 DataConstant(const FunctionSpace& what,
91 const DataArrayView::ShapeType &shape,
92 const DataArrayView::ValueType &data);
93
94 /**
95 \brief
96 Write the data as a string.
97 */
98 std::string
99 toString() const;
100
101 /**
102 \brief
103 Return the offset for the given sample. This is a somewhat artificial notion
104 but returns the offset in bytes for the given point into the container
105 holding the point data. Only really necessary to avoid many DataArrayView
106 objects.
107 \param sampleNo - Input - sample number.
108 \param dataPointNo - Input - data point number for the sample.
109 */
110 virtual
111 DataArrayView::ValueType::size_type
112 getPointOffset(int sampleNo,
113 int dataPointNo) const;
114
115 /**
116 \brief
117 Return a view into the data for the data point specified.
118 \param sampleNo - Input - sample number.
119 \param dataPointNo - Input - data point number for the sample.
120 */
121 virtual
122 DataArrayView
123 getDataPoint(int sampleNo,
124 int dataPointNo);
125
126 /**
127 \brief
128 Return the number of doubles stored for the Data object.
129 */
130 virtual
131 DataArrayView::ValueType::size_type
132 getLength() const;
133
134 /**
135 \brief
136 Factory method that returns a newly created DataConstant object
137 sliced from the specified region of this object.
138 The caller is reponsible for managing the object created.
139 \param region - Input - region to slice from this object.
140 */
141 virtual
142 DataAbstract*
143 getSlice(const DataArrayView::RegionType& region) const;
144
145 /**
146 \brief
147 Copy the specified region from the given value.
148 \param value - Input - Data object to copy from.
149 \param region - Input - Region to copy.
150 */
151 virtual
152 void
153 setSlice(const DataAbstract* value,
154 const DataArrayView::RegionType& region);
155
156 /**
157 \brief
158 Reshape the data point if the data point is currently rank 0.
159 The original data point value is used for all values of the new
160 data point.
161 */
162 void
163 reshapeDataPoint(const DataArrayView::ShapeType& shape);
164
165 /**
166 \brief
167 Archive the underlying data values to the file referenced
168 by ofstream. A count of the number of values expected to be written
169 is provided as a cross-check.
170
171 The return value indicates success (0) or otherwise (1).
172 */
173 int
174 archiveData(std::ofstream& archiveFile,
175 const DataArrayView::ValueType::size_type noValues) const;
176
177 /**
178 \brief
179 Extract the number of values specified by noValues from the file
180 referenced by ifstream to the underlying data structure.
181
182 The return value indicates success (0) or otherwise (1).
183 */
184 int
185 extractData(std::ifstream& archiveFile,
186 const DataArrayView::ValueType::size_type noValues);
187
188 /**
189 \brief
190 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
191
192 \param ev - Output - eigenvalues in increasing order at each data point
193
194 */
195 virtual void
196 eigenvalues(DataAbstract* ev);
197
198 /**
199 \brief
200 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
201
202 \param ev - Output - eigenvalues in increasing order at each data point
203 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
204 and the first nonzero component is positive.
205 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
206
207 */
208
209 virtual void
210 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
211
212
213 protected:
214
215 private:
216 //
217 // the actual data
218 DataArrayView::ValueType m_data;
219
220 };
221
222 } // end of namespace
223 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26