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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26