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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (hide 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 jgs 102 //$Id$
2 jgs 82 /*
3 elspeth 615 ************************************************************
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 jgs 82 */
13 jgs 480
14 jgs 102 #if !defined escript_DataConstant_20040323_H
15 jgs 82 #define escript_DataConstant_20040323_H
16    
17 jgs 474 #include "DataAbstract.h"
18     #include "DataArrayView.h"
19 jgs 82
20     #include <boost/python/numeric.hpp>
21    
22     namespace escript {
23 jgs 102
24 jgs 82 /**
25     \brief
26 jgs 102 DataConstant stores a single data point which represents the entire
27 jgs 82 function space.
28    
29     Description:
30 jgs 102 DataConstant stores a single data point which represents the entire
31 jgs 82 function space.
32     */
33 jgs 102 class DataConstant : public DataAbstract {
34 jgs 82
35     public:
36    
37     /**
38     \brief
39 jgs 102 Constructor for DataConstant objects.
40 jgs 82
41     Description:
42 jgs 102 Constructor for DataConstant objects.
43 jgs 82
44 jgs 102 \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 jgs 100
50 jgs 82 /**
51     \brief
52     Copy constructor. Performs a deep copy.
53     */
54     DataConstant(const DataConstant& other);
55 jgs 102
56 jgs 82 /**
57     \brief
58 jgs 102 Alternative constructor for DataConstant objects.
59 jgs 82
60     Description:
61 jgs 102 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 jgs 82 */
65 jgs 102 DataConstant(const DataArrayView& value,
66     const FunctionSpace& what);
67    
68 jgs 82 /**
69     \brief
70 jgs 102 Alternative constructor for DataConstant objects.
71 jgs 82
72     Description:
73 jgs 102 Alternative Constructor for DataConstant objects.
74     \param other - Input - Data object to copy from.
75     \param region - Input - region to copy.
76 jgs 82 */
77 jgs 102 DataConstant(const DataConstant& other,
78     const DataArrayView::RegionType& region);
79    
80 jgs 82 /**
81     \brief
82 jgs 119 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 jgs 82 Write the data as a string.
97     */
98 jgs 102 std::string
99     toString() const;
100    
101 jgs 82 /**
102     \brief
103 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
104 jgs 82 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 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::ValueType::size_type
112     getPointOffset(int sampleNo,
113     int dataPointNo) const;
114    
115 jgs 82 /**
116     \brief
117     Return a view into the data for the data point specified.
118 jgs 102 \param sampleNo - Input - sample number.
119     \param dataPointNo - Input - data point number for the sample.
120 jgs 82 */
121 jgs 102 virtual
122     DataArrayView
123     getDataPoint(int sampleNo,
124     int dataPointNo);
125    
126 jgs 82 /**
127     \brief
128 jgs 102 Return the number of doubles stored for the Data object.
129 jgs 82 */
130 jgs 102 virtual
131 jgs 117 DataArrayView::ValueType::size_type
132 jgs 102 getLength() const;
133    
134 jgs 82 /**
135     \brief
136 jgs 102 Factory method that returns a newly created DataConstant object
137     sliced from the specified region of this object.
138 jgs 82 The caller is reponsible for managing the object created.
139 jgs 102 \param region - Input - region to slice from this object.
140 jgs 82 */
141 jgs 102 virtual
142     DataAbstract*
143     getSlice(const DataArrayView::RegionType& region) const;
144    
145     /**
146 jgs 82 \brief
147     Copy the specified region from the given value.
148 jgs 102 \param value - Input - Data object to copy from.
149     \param region - Input - Region to copy.
150 jgs 82 */
151 jgs 102 virtual
152     void
153     setSlice(const DataAbstract* value,
154     const DataArrayView::RegionType& region);
155    
156 jgs 82 /**
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 jgs 102 void
163     reshapeDataPoint(const DataArrayView::ShapeType& shape);
164    
165 jgs 123 /**
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 gross 580 /**
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 jgs 82 protected:
214    
215     private:
216     //
217 jgs 102 // the actual data
218 jgs 82 DataArrayView::ValueType m_data;
219 jgs 102
220 jgs 82 };
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