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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5863 - (show annotations)
Wed Jan 13 02:25:48 2016 UTC (3 years, 6 months ago) by jfenwick
Original Path: trunk/escriptcore/src/DataConstant.h
File MIME type: text/plain
File size: 7284 byte(s)
Copyright dates updated.
\version for doxygen to read

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
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 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 #if !defined escript_DataConstant_20040323_H
19 #define escript_DataConstant_20040323_H
20 #include "system_dep.h"
21
22 #include "DataReady.h"
23 #include "WrappedArray.h"
24
25
26 namespace escript {
27
28 /**
29 \brief
30 DataConstant stores a single data point which represents the entire
31 function space.
32
33 Description:
34 DataConstant stores a single data point which represents the entire
35 function space.
36 */
37 class DataConstant : public DataReady {
38 typedef DataReady parent;
39 public:
40
41 /**
42 \brief
43 Constructor for DataConstant objects.
44
45 Description:
46 Constructor for DataConstant objects.
47
48 \param value - Input - Data value for a single point.
49 \param what - Input - A description of what this data object represents.
50 */
51 ESCRIPT_DLL_API
52 DataConstant(const WrappedArray& value,
53 const FunctionSpace& what);
54
55
56 /**
57 \brief
58 Copy constructor. Performs a deep copy.
59 */
60 ESCRIPT_DLL_API
61 DataConstant(const DataConstant& other);
62
63
64 /**
65 \brief
66 Alternative constructor for DataConstant objects.
67
68 Description:
69 Alternative Constructor for DataConstant objects.
70 \param other - Input - Data object to copy from.
71 \param region - Input - region to copy.
72 */
73 ESCRIPT_DLL_API
74 DataConstant(const DataConstant& other,
75 const DataTypes::RegionType& region);
76
77 /**
78 \brief
79 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 ESCRIPT_DLL_API
88 DataConstant(const FunctionSpace& what,
89 const DataTypes::ShapeType &shape,
90 const DataTypes::ValueType &data);
91
92 ESCRIPT_DLL_API
93 DataConstant(const FunctionSpace& what,
94 const DataTypes::ShapeType &shape,
95 const double v);
96
97
98 ESCRIPT_DLL_API
99 bool
100 isConstant() const
101 {
102 return true;
103 };
104
105 /**
106 \brief Return true if the value contains a NaN.
107 */
108 ESCRIPT_DLL_API
109 bool
110 hasNaN() const;
111
112 /**
113 \brief replaces all NaN values with value
114 */
115 ESCRIPT_DLL_API
116 void
117 replaceNaN(double value);
118
119 /**
120 \brief
121 Write the data as a string.
122 */
123 ESCRIPT_DLL_API
124 std::string
125 toString() const;
126
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 /**
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
145 /**
146 \brief
147 sets all values to zero
148 */
149 ESCRIPT_DLL_API
150 virtual
151 void
152 setToZero();
153
154 /**
155 \brief
156 Return the offset for the given sample. This is a somewhat artificial notion
157 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 \param sampleNo - Input - sample number.
161 \param dataPointNo - Input - data point number for the sample.
162 */
163 ESCRIPT_DLL_API
164 virtual
165 DataTypes::ValueType::size_type
166 getPointOffset(int sampleNo,
167 int dataPointNo) const;
168
169 ESCRIPT_DLL_API
170 virtual
171 DataTypes::ValueType::size_type
172 getPointOffset(int sampleNo,
173 int dataPointNo);
174
175 /**
176 \brief
177 Return the number of doubles stored for the Data object.
178 */
179 ESCRIPT_DLL_API
180 virtual
181 DataTypes::ValueType::size_type
182 getLength() const;
183
184 /**
185 \brief
186 Factory method that returns a newly created DataConstant object
187 sliced from the specified region of this object.
188 The caller is reponsible for managing the object created.
189 \param region - Input - region to slice from this object.
190 */
191 ESCRIPT_DLL_API
192 virtual
193 DataAbstract*
194 getSlice(const DataTypes::RegionType& region) const;
195
196 /**
197 \brief
198 Copy the specified region from the given value.
199 \param value - Input - Data object to copy from.
200 \param region - Input - Region to copy.
201 */
202 ESCRIPT_DLL_API
203 virtual
204 void
205 setSlice(const DataAbstract* value,
206 const DataTypes::RegionType& region);
207
208
209 /**
210 \brief
211 Computes a symmetric matrix (A + AT) / 2
212
213 \param ev - Output - symmetric matrix
214
215 */
216 ESCRIPT_DLL_API
217 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 ESCRIPT_DLL_API
228 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 \param axis_offset
237
238 */
239 ESCRIPT_DLL_API
240 virtual void
241 trace(DataAbstract* ev, int axis_offset);
242
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 \param axis_offset
249 */
250 ESCRIPT_DLL_API
251 virtual void
252 transpose(DataAbstract* ev, int axis_offset);
253
254 /**
255 \brief
256 swaps components axis0 and axis1
257
258 \param ev - Output - swapped components
259 \param axis0
260 \param axis1
261 */
262 ESCRIPT_DLL_API
263 virtual void
264 swapaxes(DataAbstract* ev, int axis0, int axis1);
265
266
267 /**
268 \brief
269 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 ESCRIPT_DLL_API
275 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 ESCRIPT_DLL_API
290 virtual void
291 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
292
293
294 /**
295 \brief invert square matricies
296 \param out - Where to store the results
297 \return errorcode (0 indicates success)
298 */
299 ESCRIPT_DLL_API
300 virtual int
301 matrixInverse(DataAbstract* out) const;
302
303 /**
304 \brief
305 Return a reference to the underlying DataVector.
306 */
307 ESCRIPT_DLL_API
308 DataTypes::ValueType&
309 getVectorRW();
310
311
312 ESCRIPT_DLL_API
313 const DataTypes::ValueType&
314 getVectorRO() const;
315
316 protected:
317
318 private:
319 //
320 // the actual data
321 DataTypes::ValueType m_data;
322
323 };
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