/[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 6116 - (hide annotations)
Fri Apr 1 06:56:23 2016 UTC (3 years, 3 months ago) by caltinay
File MIME type: text/plain
File size: 8176 byte(s)
sync with trunk and relicense new/moved files.

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 caltinay 6116 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
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 caltinay 6105 explicit 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 caltinay 6105 explicit 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 caltinay 6105 explicit DataConstant(const FunctionSpace& what,
89 jfenwick 1796 const DataTypes::ShapeType &shape,
90 caltinay 5963 const DataTypes::RealVectorType &data);
91 jgs 119
92 jfenwick 2005 ESCRIPT_DLL_API
93 caltinay 6105 explicit DataConstant(const FunctionSpace& what,
94 jfenwick 3468 const DataTypes::ShapeType &shape,
95     const double v);
96 caltinay 5963
97    
98 jfenwick 3468 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 caltinay 5963 replaceNaN(DataTypes::real_t value);
118 jduplessis 5056
119 caltinay 5963 ESCRIPT_DLL_API
120     void
121     replaceNaN(DataTypes::cplx_t value);
122    
123 jduplessis 5056 /**
124 jgs 119 \brief
125 jgs 82 Write the data as a string.
126     */
127 woo409 757 ESCRIPT_DLL_API
128 jgs 102 std::string
129     toString() const;
130 jfenwick 1799
131     /**
132     \brief Return a deep copy of the current object.
133     */
134     ESCRIPT_DLL_API
135     virtual
136     DataAbstract*
137 caltinay 5963 deepCopy() const;
138 jfenwick 1799
139    
140 gross 950 /**
141     \brief
142     dumps the object into a netCDF file
143     */
144     ESCRIPT_DLL_API
145     virtual
146     void
147     dump(const std::string fileName) const;
148 jgs 102
149 gross 1118 /**
150     \brief
151     sets all values to zero
152     */
153     ESCRIPT_DLL_API
154     virtual
155     void
156     setToZero();
157 gross 950
158 jgs 82 /**
159     \brief
160 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
161 jgs 82 but returns the offset in bytes for the given point into the container
162     holding the point data. Only really necessary to avoid many DataArrayView
163     objects.
164 jgs 102 \param sampleNo - Input - sample number.
165     \param dataPointNo - Input - data point number for the sample.
166 jgs 82 */
167 woo409 757 ESCRIPT_DLL_API
168 jgs 102 virtual
169 caltinay 5963 DataTypes::RealVectorType::size_type
170 jgs 102 getPointOffset(int sampleNo,
171     int dataPointNo) const;
172    
173 jfenwick 2005 ESCRIPT_DLL_API
174     virtual
175 caltinay 5963 DataTypes::RealVectorType::size_type
176 jfenwick 2005 getPointOffset(int sampleNo,
177     int dataPointNo);
178    
179 jgs 82 /**
180     \brief
181 jgs 102 Return the number of doubles stored for the Data object.
182 jgs 82 */
183 woo409 757 ESCRIPT_DLL_API
184 jgs 102 virtual
185 caltinay 5963 DataTypes::RealVectorType::size_type
186 jgs 102 getLength() const;
187    
188 jgs 82 /**
189     \brief
190 jgs 102 Factory method that returns a newly created DataConstant object
191     sliced from the specified region of this object.
192 jgs 82 The caller is reponsible for managing the object created.
193 jgs 102 \param region - Input - region to slice from this object.
194 jgs 82 */
195 woo409 757 ESCRIPT_DLL_API
196 jgs 102 virtual
197     DataAbstract*
198 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
199 jgs 102
200     /**
201 jgs 82 \brief
202     Copy the specified region from the given value.
203 jgs 102 \param value - Input - Data object to copy from.
204     \param region - Input - Region to copy.
205 jgs 82 */
206 woo409 757 ESCRIPT_DLL_API
207 jgs 102 virtual
208     void
209     setSlice(const DataAbstract* value,
210 jfenwick 1796 const DataTypes::RegionType& region);
211 jgs 102
212 jgs 123
213     /**
214 gross 580 \brief
215 ksteube 775 Computes a symmetric matrix (A + AT) / 2
216    
217     \param ev - Output - symmetric matrix
218    
219     */
220 gross 800 ESCRIPT_DLL_API
221 ksteube 775 virtual void
222     symmetric(DataAbstract* ev);
223    
224     /**
225     \brief
226     Computes a nonsymmetric matrix (A - AT) / 2
227    
228     \param ev - Output - nonsymmetric matrix
229    
230     */
231 gross 800 ESCRIPT_DLL_API
232 ksteube 775 virtual void
233 caltinay 6116 antisymmetric(DataAbstract* ev);
234 ksteube 775
235     /**
236     \brief
237     Computes the trace of a matrix
238    
239     \param ev - Output - trace of matrix
240 jfenwick 2519 \param axis_offset
241 ksteube 775
242     */
243 gross 800 ESCRIPT_DLL_API
244 ksteube 775 virtual void
245 gross 800 trace(DataAbstract* ev, int axis_offset);
246 ksteube 775
247     /**
248     \brief
249     Transpose each data point of this Data object around the given axis.
250    
251     \param ev - Output - transpose of matrix
252 jfenwick 2519 \param axis_offset
253 ksteube 775 */
254 gross 800 ESCRIPT_DLL_API
255 ksteube 775 virtual void
256     transpose(DataAbstract* ev, int axis_offset);
257    
258     /**
259     \brief
260 gross 804 swaps components axis0 and axis1
261 gross 800
262     \param ev - Output - swapped components
263 jfenwick 2519 \param axis0
264     \param axis1
265 gross 800 */
266     ESCRIPT_DLL_API
267     virtual void
268 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
269 gross 800
270    
271     /**
272     \brief
273 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
274    
275     \param ev - Output - eigenvalues in increasing order at each data point
276    
277     */
278 woo409 757 ESCRIPT_DLL_API
279 gross 580 virtual void
280     eigenvalues(DataAbstract* ev);
281    
282     /**
283     \brief
284     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
285    
286     \param ev - Output - eigenvalues in increasing order at each data point
287     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
288     and the first nonzero component is positive.
289     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
290    
291     */
292    
293 woo409 757 ESCRIPT_DLL_API
294 gross 580 virtual void
295     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
296    
297    
298 jfenwick 1796 /**
299 jfenwick 2742 \brief invert square matricies
300     \param out - Where to store the results
301 jfenwick 2792 \return errorcode (0 indicates success)
302 jfenwick 2742 */
303     ESCRIPT_DLL_API
304 jfenwick 2792 virtual int
305 jfenwick 2742 matrixInverse(DataAbstract* out) const;
306    
307     /**
308 jfenwick 1796 \brief
309     Return a reference to the underlying DataVector.
310     */
311     ESCRIPT_DLL_API
312 caltinay 5963 DataTypes::RealVectorType&
313 jfenwick 2271 getVectorRW();
314 jfenwick 1796
315 jfenwick 2271
316 jfenwick 1796 ESCRIPT_DLL_API
317 caltinay 5963 const DataTypes::RealVectorType&
318 jfenwick 2271 getVectorRO() const;
319 jfenwick 1796
320 caltinay 5963 ESCRIPT_DLL_API
321     DataTypes::CplxVectorType&
322     getVectorRWC();
323    
324    
325     ESCRIPT_DLL_API
326     const DataTypes::CplxVectorType&
327     getVectorROC() const;
328    
329    
330    
331     ESCRIPT_DLL_API
332     virtual DataTypes::RealVectorType&
333     getTypedVectorRW(DataTypes::real_t dummy);
334    
335     ESCRIPT_DLL_API
336     virtual const DataTypes::RealVectorType&
337     getTypedVectorRO(DataTypes::real_t dummy) const;
338    
339     ESCRIPT_DLL_API
340     virtual DataTypes::CplxVectorType&
341     getTypedVectorRW(DataTypes::cplx_t dummy);
342    
343     ESCRIPT_DLL_API
344     virtual const DataTypes::CplxVectorType&
345     getTypedVectorRO(DataTypes::cplx_t dummy) const;
346    
347    
348    
349    
350     /**
351     * \brief Convert from real data to complex data.
352     */
353     ESCRIPT_DLL_API
354     void complicate();
355    
356 jgs 82 protected:
357    
358     private:
359     //
360 jgs 102 // the actual data
361 caltinay 5963 DataTypes::RealVectorType m_data_r;
362     DataTypes::CplxVectorType m_data_c;
363 jgs 102
364 jgs 82 };
365    
366     } // end of namespace
367     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26