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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2653 - (hide annotations)
Tue Sep 8 04:26:30 2009 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 6485 byte(s)
Fix bug in maxGlobalDataPoint and minGlobalDataPoint.
They now give the correct answers and the datapoint ids returned are globally
correct.

Removed some #defines from before COW
Removed hasNoSamples() - I don't trust myself to use that properly let alone anybody else.


1 jgs 480
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 102 #if !defined escript_DataConstant_20040323_H
16 jgs 82 #define escript_DataConstant_20040323_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19 jfenwick 2005 #include "DataReady.h"
20 jfenwick 2271 #include "WrappedArray.h"
21 jgs 82
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 jfenwick 2005 class DataConstant : public DataReady {
35     typedef DataReady parent;
36 jgs 82 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 jfenwick 2271 DataConstant(const WrappedArray& value,
50 jgs 102 const FunctionSpace& what);
51 jgs 100
52 jfenwick 2271
53 jgs 82 /**
54     \brief
55     Copy constructor. Performs a deep copy.
56     */
57 woo409 757 ESCRIPT_DLL_API
58 jgs 82 DataConstant(const DataConstant& other);
59 jgs 102
60 jgs 82
61     /**
62     \brief
63 jgs 102 Alternative constructor for DataConstant objects.
64 jgs 82
65     Description:
66 jgs 102 Alternative Constructor for DataConstant objects.
67     \param other - Input - Data object to copy from.
68     \param region - Input - region to copy.
69 jgs 82 */
70 woo409 757 ESCRIPT_DLL_API
71 jgs 102 DataConstant(const DataConstant& other,
72 jfenwick 1796 const DataTypes::RegionType& region);
73 jgs 102
74 jgs 82 /**
75     \brief
76 jgs 119 Alternative constructor for DataConstant objects.
77    
78     Description:
79     Alternative Constructor for DataConstant objects.
80     \param what - Input - A description of what this data object represents.
81     \param shape - Input - the shape of each data-point.
82     \param data - the data values for each data-point.
83     */
84 woo409 757 ESCRIPT_DLL_API
85 jgs 119 DataConstant(const FunctionSpace& what,
86 jfenwick 1796 const DataTypes::ShapeType &shape,
87     const DataTypes::ValueType &data);
88 jgs 119
89 jfenwick 2005
90     ESCRIPT_DLL_API
91     bool
92     isConstant() const
93     {
94     return true;
95     };
96    
97 jgs 119 /**
98     \brief
99 jgs 82 Write the data as a string.
100     */
101 woo409 757 ESCRIPT_DLL_API
102 jgs 102 std::string
103     toString() const;
104 jfenwick 1799
105     /**
106     \brief Return a deep copy of the current object.
107     */
108     ESCRIPT_DLL_API
109     virtual
110     DataAbstract*
111     deepCopy();
112    
113    
114 gross 950 /**
115     \brief
116     dumps the object into a netCDF file
117     */
118     ESCRIPT_DLL_API
119     virtual
120     void
121     dump(const std::string fileName) const;
122 jgs 102
123 gross 1118 /**
124     \brief
125     sets all values to zero
126     */
127     ESCRIPT_DLL_API
128     virtual
129     void
130     setToZero();
131 gross 950
132 jgs 82 /**
133     \brief
134 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
135 jgs 82 but returns the offset in bytes for the given point into the container
136     holding the point data. Only really necessary to avoid many DataArrayView
137     objects.
138 jgs 102 \param sampleNo - Input - sample number.
139     \param dataPointNo - Input - data point number for the sample.
140 jgs 82 */
141 woo409 757 ESCRIPT_DLL_API
142 jgs 102 virtual
143 jfenwick 1796 DataTypes::ValueType::size_type
144 jgs 102 getPointOffset(int sampleNo,
145     int dataPointNo) const;
146    
147 jfenwick 2005 ESCRIPT_DLL_API
148     virtual
149     DataTypes::ValueType::size_type
150     getPointOffset(int sampleNo,
151     int dataPointNo);
152    
153 jgs 82 /**
154     \brief
155 jgs 102 Return the number of doubles stored for the Data object.
156 jgs 82 */
157 woo409 757 ESCRIPT_DLL_API
158 jgs 102 virtual
159 jfenwick 1796 DataTypes::ValueType::size_type
160 jgs 102 getLength() const;
161    
162 jgs 82 /**
163     \brief
164 jgs 102 Factory method that returns a newly created DataConstant object
165     sliced from the specified region of this object.
166 jgs 82 The caller is reponsible for managing the object created.
167 jgs 102 \param region - Input - region to slice from this object.
168 jgs 82 */
169 woo409 757 ESCRIPT_DLL_API
170 jgs 102 virtual
171     DataAbstract*
172 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
173 jgs 102
174     /**
175 jgs 82 \brief
176     Copy the specified region from the given value.
177 jgs 102 \param value - Input - Data object to copy from.
178     \param region - Input - Region to copy.
179 jgs 82 */
180 woo409 757 ESCRIPT_DLL_API
181 jgs 102 virtual
182     void
183     setSlice(const DataAbstract* value,
184 jfenwick 1796 const DataTypes::RegionType& region);
185 jgs 102
186 jgs 123
187     /**
188 gross 580 \brief
189 ksteube 775 Computes a symmetric matrix (A + AT) / 2
190    
191     \param ev - Output - symmetric matrix
192    
193     */
194 gross 800 ESCRIPT_DLL_API
195 ksteube 775 virtual void
196     symmetric(DataAbstract* ev);
197    
198     /**
199     \brief
200     Computes a nonsymmetric matrix (A - AT) / 2
201    
202     \param ev - Output - nonsymmetric matrix
203    
204     */
205 gross 800 ESCRIPT_DLL_API
206 ksteube 775 virtual void
207     nonsymmetric(DataAbstract* ev);
208    
209     /**
210     \brief
211     Computes the trace of a matrix
212    
213     \param ev - Output - trace of matrix
214 jfenwick 2519 \param axis_offset
215 ksteube 775
216     */
217 gross 800 ESCRIPT_DLL_API
218 ksteube 775 virtual void
219 gross 800 trace(DataAbstract* ev, int axis_offset);
220 ksteube 775
221     /**
222     \brief
223     Transpose each data point of this Data object around the given axis.
224    
225     \param ev - Output - transpose of matrix
226 jfenwick 2519 \param axis_offset
227 ksteube 775 */
228 gross 800 ESCRIPT_DLL_API
229 ksteube 775 virtual void
230     transpose(DataAbstract* ev, int axis_offset);
231    
232     /**
233     \brief
234 gross 804 swaps components axis0 and axis1
235 gross 800
236     \param ev - Output - swapped components
237 jfenwick 2519 \param axis0
238     \param axis1
239 gross 800 */
240     ESCRIPT_DLL_API
241     virtual void
242 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
243 gross 800
244    
245     /**
246     \brief
247 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
248    
249     \param ev - Output - eigenvalues in increasing order at each data point
250    
251     */
252 woo409 757 ESCRIPT_DLL_API
253 gross 580 virtual void
254     eigenvalues(DataAbstract* ev);
255    
256     /**
257     \brief
258     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
259    
260     \param ev - Output - eigenvalues in increasing order at each data point
261     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
262     and the first nonzero component is positive.
263     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
264    
265     */
266    
267 woo409 757 ESCRIPT_DLL_API
268 gross 580 virtual void
269     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
270    
271    
272 jfenwick 1796 /**
273     \brief
274     Return a reference to the underlying DataVector.
275     */
276     ESCRIPT_DLL_API
277     DataTypes::ValueType&
278 jfenwick 2271 getVectorRW();
279 jfenwick 1796
280 jfenwick 2271
281 jfenwick 1796 ESCRIPT_DLL_API
282     const DataTypes::ValueType&
283 jfenwick 2271 getVectorRO() const;
284 jfenwick 1796
285 jgs 82 protected:
286    
287     private:
288     //
289 jgs 102 // the actual data
290 jfenwick 1796 DataTypes::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