/[escript]/branches/trilinos_from_5897/escriptcore/src/DataConstant.h
ViewVC logotype

Annotation of /branches/trilinos_from_5897/escriptcore/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5898 - (hide annotations)
Fri Feb 5 03:37:49 2016 UTC (3 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 7284 byte(s)
trilinos playground

1 jgs 480
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 5863 * Copyright (c) 2003-2016 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 ksteube 1312
17 ksteube 1811
18 jgs 102 #if !defined escript_DataConstant_20040323_H
19 jgs 82 #define escript_DataConstant_20040323_H
20 woo409 757 #include "system_dep.h"
21 jgs 82
22 jfenwick 2005 #include "DataReady.h"
23 jfenwick 2271 #include "WrappedArray.h"
24 jgs 82
25    
26     namespace escript {
27 jgs 102
28 jgs 82 /**
29     \brief
30 jgs 102 DataConstant stores a single data point which represents the entire
31 jgs 82 function space.
32    
33     Description:
34 jgs 102 DataConstant stores a single data point which represents the entire
35 jgs 82 function space.
36     */
37 jfenwick 2005 class DataConstant : public DataReady {
38     typedef DataReady parent;
39 jgs 82 public:
40    
41     /**
42     \brief
43 jgs 102 Constructor for DataConstant objects.
44 jgs 82
45     Description:
46 jgs 102 Constructor for DataConstant objects.
47 jgs 82
48 jgs 102 \param value - Input - Data value for a single point.
49     \param what - Input - A description of what this data object represents.
50     */
51 woo409 757 ESCRIPT_DLL_API
52 jfenwick 2271 DataConstant(const WrappedArray& value,
53 jgs 102 const FunctionSpace& what);
54 jgs 100
55 jfenwick 2271
56 jgs 82 /**
57     \brief
58     Copy constructor. Performs a deep copy.
59     */
60 woo409 757 ESCRIPT_DLL_API
61 jgs 82 DataConstant(const DataConstant& other);
62 jgs 102
63 jgs 82
64     /**
65     \brief
66 jgs 102 Alternative constructor for DataConstant objects.
67 jgs 82
68     Description:
69 jgs 102 Alternative Constructor for DataConstant objects.
70     \param other - Input - Data object to copy from.
71     \param region - Input - region to copy.
72 jgs 82 */
73 woo409 757 ESCRIPT_DLL_API
74 jgs 102 DataConstant(const DataConstant& other,
75 jfenwick 1796 const DataTypes::RegionType& region);
76 jgs 102
77 jgs 82 /**
78     \brief
79 jgs 119 Alternative constructor for DataConstant objects.
80    
81     Description:
82     Alternative Constructor for DataConstant objects.
83     \param what - Input - A description of what this data object represents.
84     \param shape - Input - the shape of each data-point.
85     \param data - the data values for each data-point.
86     */
87 woo409 757 ESCRIPT_DLL_API
88 jgs 119 DataConstant(const FunctionSpace& what,
89 jfenwick 1796 const DataTypes::ShapeType &shape,
90     const DataTypes::ValueType &data);
91 jgs 119
92 jfenwick 2005 ESCRIPT_DLL_API
93 jfenwick 3468 DataConstant(const FunctionSpace& what,
94     const DataTypes::ShapeType &shape,
95     const double v);
96    
97    
98     ESCRIPT_DLL_API
99 jfenwick 2005 bool
100     isConstant() const
101     {
102     return true;
103     };
104    
105 jgs 119 /**
106 jfenwick 2766 \brief Return true if the value contains a NaN.
107     */
108     ESCRIPT_DLL_API
109     bool
110     hasNaN() const;
111    
112     /**
113 jduplessis 5056 \brief replaces all NaN values with value
114     */
115     ESCRIPT_DLL_API
116     void
117     replaceNaN(double value);
118    
119     /**
120 jgs 119 \brief
121 jgs 82 Write the data as a string.
122     */
123 woo409 757 ESCRIPT_DLL_API
124 jgs 102 std::string
125     toString() const;
126 jfenwick 1799
127     /**
128     \brief Return a deep copy of the current object.
129     */
130     ESCRIPT_DLL_API
131     virtual
132     DataAbstract*
133     deepCopy();
134    
135    
136 gross 950 /**
137     \brief
138     dumps the object into a netCDF file
139     */
140     ESCRIPT_DLL_API
141     virtual
142     void
143     dump(const std::string fileName) const;
144 jgs 102
145 gross 1118 /**
146     \brief
147     sets all values to zero
148     */
149     ESCRIPT_DLL_API
150     virtual
151     void
152     setToZero();
153 gross 950
154 jgs 82 /**
155     \brief
156 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
157 jgs 82 but returns the offset in bytes for the given point into the container
158     holding the point data. Only really necessary to avoid many DataArrayView
159     objects.
160 jgs 102 \param sampleNo - Input - sample number.
161     \param dataPointNo - Input - data point number for the sample.
162 jgs 82 */
163 woo409 757 ESCRIPT_DLL_API
164 jgs 102 virtual
165 jfenwick 1796 DataTypes::ValueType::size_type
166 jgs 102 getPointOffset(int sampleNo,
167     int dataPointNo) const;
168    
169 jfenwick 2005 ESCRIPT_DLL_API
170     virtual
171     DataTypes::ValueType::size_type
172     getPointOffset(int sampleNo,
173     int dataPointNo);
174    
175 jgs 82 /**
176     \brief
177 jgs 102 Return the number of doubles stored for the Data object.
178 jgs 82 */
179 woo409 757 ESCRIPT_DLL_API
180 jgs 102 virtual
181 jfenwick 1796 DataTypes::ValueType::size_type
182 jgs 102 getLength() const;
183    
184 jgs 82 /**
185     \brief
186 jgs 102 Factory method that returns a newly created DataConstant object
187     sliced from the specified region of this object.
188 jgs 82 The caller is reponsible for managing the object created.
189 jgs 102 \param region - Input - region to slice from this object.
190 jgs 82 */
191 woo409 757 ESCRIPT_DLL_API
192 jgs 102 virtual
193     DataAbstract*
194 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
195 jgs 102
196     /**
197 jgs 82 \brief
198     Copy the specified region from the given value.
199 jgs 102 \param value - Input - Data object to copy from.
200     \param region - Input - Region to copy.
201 jgs 82 */
202 woo409 757 ESCRIPT_DLL_API
203 jgs 102 virtual
204     void
205     setSlice(const DataAbstract* value,
206 jfenwick 1796 const DataTypes::RegionType& region);
207 jgs 102
208 jgs 123
209     /**
210 gross 580 \brief
211 ksteube 775 Computes a symmetric matrix (A + AT) / 2
212    
213     \param ev - Output - symmetric matrix
214    
215     */
216 gross 800 ESCRIPT_DLL_API
217 ksteube 775 virtual void
218     symmetric(DataAbstract* ev);
219    
220     /**
221     \brief
222     Computes a nonsymmetric matrix (A - AT) / 2
223    
224     \param ev - Output - nonsymmetric matrix
225    
226     */
227 gross 800 ESCRIPT_DLL_API
228 ksteube 775 virtual void
229     nonsymmetric(DataAbstract* ev);
230    
231     /**
232     \brief
233     Computes the trace of a matrix
234    
235     \param ev - Output - trace of matrix
236 jfenwick 2519 \param axis_offset
237 ksteube 775
238     */
239 gross 800 ESCRIPT_DLL_API
240 ksteube 775 virtual void
241 gross 800 trace(DataAbstract* ev, int axis_offset);
242 ksteube 775
243     /**
244     \brief
245     Transpose each data point of this Data object around the given axis.
246    
247     \param ev - Output - transpose of matrix
248 jfenwick 2519 \param axis_offset
249 ksteube 775 */
250 gross 800 ESCRIPT_DLL_API
251 ksteube 775 virtual void
252     transpose(DataAbstract* ev, int axis_offset);
253    
254     /**
255     \brief
256 gross 804 swaps components axis0 and axis1
257 gross 800
258     \param ev - Output - swapped components
259 jfenwick 2519 \param axis0
260     \param axis1
261 gross 800 */
262     ESCRIPT_DLL_API
263     virtual void
264 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
265 gross 800
266    
267     /**
268     \brief
269 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
270    
271     \param ev - Output - eigenvalues in increasing order at each data point
272    
273     */
274 woo409 757 ESCRIPT_DLL_API
275 gross 580 virtual void
276     eigenvalues(DataAbstract* ev);
277    
278     /**
279     \brief
280     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
281    
282     \param ev - Output - eigenvalues in increasing order at each data point
283     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
284     and the first nonzero component is positive.
285     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
286    
287     */
288    
289 woo409 757 ESCRIPT_DLL_API
290 gross 580 virtual void
291     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
292    
293    
294 jfenwick 1796 /**
295 jfenwick 2742 \brief invert square matricies
296     \param out - Where to store the results
297 jfenwick 2792 \return errorcode (0 indicates success)
298 jfenwick 2742 */
299     ESCRIPT_DLL_API
300 jfenwick 2792 virtual int
301 jfenwick 2742 matrixInverse(DataAbstract* out) const;
302    
303     /**
304 jfenwick 1796 \brief
305     Return a reference to the underlying DataVector.
306     */
307     ESCRIPT_DLL_API
308     DataTypes::ValueType&
309 jfenwick 2271 getVectorRW();
310 jfenwick 1796
311 jfenwick 2271
312 jfenwick 1796 ESCRIPT_DLL_API
313     const DataTypes::ValueType&
314 jfenwick 2271 getVectorRO() const;
315 jfenwick 1796
316 jgs 82 protected:
317    
318     private:
319     //
320 jgs 102 // the actual data
321 jfenwick 1796 DataTypes::ValueType m_data;
322 jgs 102
323 jgs 82 };
324    
325     } // end of namespace
326     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26