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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 950 - (hide annotations)
Tue Feb 6 07:01:11 2007 UTC (12 years, 2 months ago) by gross
File MIME type: text/plain
File size: 7436 byte(s)
escript data objects can now be saved to netCDF files, see http://www.unidata.ucar.edu/software/netcdf/.
Currently only constant data are implemented with expanded and tagged data to follow.
There are two new functions to dump a data object

   s=Data(...)
   s.dump(<filename>)

and to recover it

   s=load(<filename>, domain)

Notice that the function space of s is recovered but domain is still need. 

dump and load will replace archive and extract.

The installation needs now the netCDF installed. 


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 woo409 757 #include "system_dep.h"
17 jgs 82
18 jgs 474 #include "DataAbstract.h"
19     #include "DataArrayView.h"
20 jgs 82
21     #include <boost/python/numeric.hpp>
22    
23     namespace escript {
24 jgs 102
25 jgs 82 /**
26     \brief
27 jgs 102 DataConstant stores a single data point which represents the entire
28 jgs 82 function space.
29    
30     Description:
31 jgs 102 DataConstant stores a single data point which represents the entire
32 jgs 82 function space.
33     */
34 jgs 102 class DataConstant : public DataAbstract {
35 jgs 82
36     public:
37    
38     /**
39     \brief
40 jgs 102 Constructor for DataConstant objects.
41 jgs 82
42     Description:
43 jgs 102 Constructor for DataConstant objects.
44 jgs 82
45 jgs 102 \param value - Input - Data value for a single point.
46     \param what - Input - A description of what this data object represents.
47     */
48 woo409 757 ESCRIPT_DLL_API
49 jgs 102 DataConstant(const boost::python::numeric::array& value,
50     const FunctionSpace& what);
51 jgs 100
52 jgs 82 /**
53     \brief
54     Copy constructor. Performs a deep copy.
55     */
56 woo409 757 ESCRIPT_DLL_API
57 jgs 82 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 woo409 757 ESCRIPT_DLL_API
69 jgs 102 DataConstant(const DataArrayView& value,
70     const FunctionSpace& what);
71    
72 jgs 82 /**
73     \brief
74 jgs 102 Alternative constructor for DataConstant objects.
75 jgs 82
76     Description:
77 jgs 102 Alternative Constructor for DataConstant objects.
78     \param other - Input - Data object to copy from.
79     \param region - Input - region to copy.
80 jgs 82 */
81 woo409 757 ESCRIPT_DLL_API
82 jgs 102 DataConstant(const DataConstant& other,
83     const DataArrayView::RegionType& region);
84    
85 jgs 82 /**
86     \brief
87 jgs 119 Alternative constructor for DataConstant objects.
88    
89     Description:
90     Alternative Constructor for DataConstant objects.
91     \param what - Input - A description of what this data object represents.
92     \param shape - Input - the shape of each data-point.
93     \param data - the data values for each data-point.
94     */
95 woo409 757 ESCRIPT_DLL_API
96 jgs 119 DataConstant(const FunctionSpace& what,
97     const DataArrayView::ShapeType &shape,
98     const DataArrayView::ValueType &data);
99    
100     /**
101     \brief
102 jgs 82 Write the data as a string.
103     */
104 woo409 757 ESCRIPT_DLL_API
105 jgs 102 std::string
106     toString() const;
107 gross 950 /**
108     \brief
109     dumps the object into a netCDF file
110     */
111     ESCRIPT_DLL_API
112     virtual
113     void
114     dump(const std::string fileName) const;
115 jgs 102
116 gross 950
117 jgs 82 /**
118     \brief
119 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
120 jgs 82 but returns the offset in bytes for the given point into the container
121     holding the point data. Only really necessary to avoid many DataArrayView
122     objects.
123 jgs 102 \param sampleNo - Input - sample number.
124     \param dataPointNo - Input - data point number for the sample.
125 jgs 82 */
126 woo409 757 ESCRIPT_DLL_API
127 jgs 102 virtual
128     DataArrayView::ValueType::size_type
129     getPointOffset(int sampleNo,
130     int dataPointNo) const;
131    
132 jgs 82 /**
133     \brief
134     Return a view into the data for the data point specified.
135 jgs 102 \param sampleNo - Input - sample number.
136     \param dataPointNo - Input - data point number for the sample.
137 jgs 82 */
138 woo409 757 ESCRIPT_DLL_API
139 jgs 102 virtual
140     DataArrayView
141     getDataPoint(int sampleNo,
142     int dataPointNo);
143    
144 jgs 82 /**
145     \brief
146 jgs 102 Return the number of doubles stored for the Data object.
147 jgs 82 */
148 woo409 757 ESCRIPT_DLL_API
149 jgs 102 virtual
150 jgs 117 DataArrayView::ValueType::size_type
151 jgs 102 getLength() const;
152    
153 jgs 82 /**
154     \brief
155 jgs 102 Factory method that returns a newly created DataConstant object
156     sliced from the specified region of this object.
157 jgs 82 The caller is reponsible for managing the object created.
158 jgs 102 \param region - Input - region to slice from this object.
159 jgs 82 */
160 woo409 757 ESCRIPT_DLL_API
161 jgs 102 virtual
162     DataAbstract*
163     getSlice(const DataArrayView::RegionType& region) const;
164    
165     /**
166 jgs 82 \brief
167     Copy the specified region from the given value.
168 jgs 102 \param value - Input - Data object to copy from.
169     \param region - Input - Region to copy.
170 jgs 82 */
171 woo409 757 ESCRIPT_DLL_API
172 jgs 102 virtual
173     void
174     setSlice(const DataAbstract* value,
175     const DataArrayView::RegionType& region);
176    
177 jgs 82 /**
178 jgs 123 \brief
179     Archive the underlying data values to the file referenced
180     by ofstream. A count of the number of values expected to be written
181     is provided as a cross-check.
182    
183     The return value indicates success (0) or otherwise (1).
184     */
185 woo409 757 ESCRIPT_DLL_API
186 jgs 123 int
187     archiveData(std::ofstream& archiveFile,
188     const DataArrayView::ValueType::size_type noValues) const;
189    
190     /**
191     \brief
192     Extract the number of values specified by noValues from the file
193     referenced by ifstream to the underlying data structure.
194    
195     The return value indicates success (0) or otherwise (1).
196     */
197 woo409 757 ESCRIPT_DLL_API
198 jgs 123 int
199     extractData(std::ifstream& archiveFile,
200     const DataArrayView::ValueType::size_type noValues);
201    
202 gross 580 /**
203     \brief
204 ksteube 775 Computes a symmetric matrix (A + AT) / 2
205    
206     \param ev - Output - symmetric matrix
207    
208     */
209 gross 800 ESCRIPT_DLL_API
210 ksteube 775 virtual void
211     symmetric(DataAbstract* ev);
212    
213     /**
214     \brief
215     Computes a nonsymmetric matrix (A - AT) / 2
216    
217     \param ev - Output - nonsymmetric matrix
218    
219     */
220 gross 800 ESCRIPT_DLL_API
221 ksteube 775 virtual void
222     nonsymmetric(DataAbstract* ev);
223    
224     /**
225     \brief
226     Computes the trace of a matrix
227    
228     \param ev - Output - trace of matrix
229    
230     */
231 gross 800 ESCRIPT_DLL_API
232 ksteube 775 virtual void
233 gross 800 trace(DataAbstract* ev, int axis_offset);
234 ksteube 775
235     /**
236     \brief
237     Transpose each data point of this Data object around the given axis.
238    
239     \param ev - Output - transpose of matrix
240    
241     */
242 gross 800 ESCRIPT_DLL_API
243 ksteube 775 virtual void
244     transpose(DataAbstract* ev, int axis_offset);
245    
246     /**
247     \brief
248 gross 804 swaps components axis0 and axis1
249 gross 800
250     \param ev - Output - swapped components
251    
252     */
253     ESCRIPT_DLL_API
254     virtual void
255 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
256 gross 800
257    
258     /**
259     \brief
260 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
261    
262     \param ev - Output - eigenvalues in increasing order at each data point
263    
264     */
265 woo409 757 ESCRIPT_DLL_API
266 gross 580 virtual void
267     eigenvalues(DataAbstract* ev);
268    
269     /**
270     \brief
271     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
272    
273     \param ev - Output - eigenvalues in increasing order at each data point
274     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
275     and the first nonzero component is positive.
276     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
277    
278     */
279    
280 woo409 757 ESCRIPT_DLL_API
281 gross 580 virtual void
282     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
283    
284    
285 jgs 82 protected:
286    
287     private:
288     //
289 jgs 102 // the actual data
290 jgs 82 DataArrayView::ValueType m_data;
291 jgs 102
292 jgs 82 };
293    
294     } // end of namespace
295     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26