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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1118 - (hide annotations)
Tue Apr 24 08:55:04 2007 UTC (12 years, 3 months ago) by gross
File MIME type: text/plain
File size: 11059 byte(s)
problem with reset of faulty PDE rhs fixed.
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_DataExpanded_20040323_H
15 jgs 82 #define escript_DataExpanded_20040323_H
16 woo409 757 #include "system_dep.h"
17 jgs 82
18     #include "DataAbstract.h"
19     #include "DataBlocks2D.h"
20     #include "DataArrayView.h"
21    
22     #include <boost/python/numeric.hpp>
23    
24     namespace escript {
25    
26 jgs 117 //
27     // Forward declarations of other Data types.
28 jgs 102 class DataConstant;
29     class DataTagged;
30 jgs 82
31     /**
32     \brief
33     Give a short description of what DataExpanded does.
34    
35     Description:
36 jgs 117 Give a detailed description of DataExpanded.
37 jgs 82
38     Template Parameters:
39     For templates describe any conditions that the parameters used in the
40 jgs 117 template must satisfy.
41 jgs 82 */
42    
43 jgs 117 class DataExpanded : public DataAbstract {
44 jgs 82
45     public:
46    
47     /**
48     \brief
49 jgs 117 Constructor for DataExpanded.
50 jgs 82
51 jgs 117 Description:
52     Constructor for DataExpanded.
53 jgs 82
54 jgs 117 The given single data value is copied to all the data points in
55     this data object, where the number of data points is defined by
56     the given function space.
57 jgs 82
58 jgs 117 \param value - Input - A single data value.
59 jgs 82 \param what - Input - A description of what this data represents.
60     */
61 woo409 757 ESCRIPT_DLL_API
62 jgs 102 DataExpanded(const boost::python::numeric::array& value,
63     const FunctionSpace& what);
64 jgs 82
65     /**
66     \brief
67 jgs 117 Alternative constructor for DataExpanded.
68 jgs 82
69     Description:
70 jgs 102 Alternative Constructor for DataExpanded.
71 jgs 117
72     The given single data value is copied to all the data points in
73     this data object, where the number of data points is defined by
74     the given function space.
75    
76     \param value - Input - A single data value.
77 jgs 82 \param what - Input - A description of what this data represents.
78     */
79 woo409 757 ESCRIPT_DLL_API
80 jgs 102 DataExpanded(const DataArrayView& value,
81     const FunctionSpace& what);
82 jgs 82
83     /**
84     \brief
85     Alternative constructor for DataExpanded that copies a slice from
86     another DataExpanded.
87    
88 jgs 102 \param other - Input - DataExpanded object to slice from.
89     \param region - Input - region to copy.
90 jgs 82 */
91 woo409 757 ESCRIPT_DLL_API
92 jgs 102 DataExpanded(const DataExpanded& other,
93     const DataArrayView::RegionType& region);
94 jgs 82
95     /**
96     \brief
97 jgs 119 Alternative constructor for DataExpanded objects.
98    
99     Description:
100     Alternative Constructor for DataExpanded objects.
101     \param what - Input - A description of what this data object represents.
102     \param shape - Input - the shape of each data-point.
103 jgs 122 \param data - the array of data values for the data-points.
104 jgs 119 */
105 woo409 757 ESCRIPT_DLL_API
106 jgs 119 DataExpanded(const FunctionSpace& what,
107     const DataArrayView::ShapeType &shape,
108     const DataArrayView::ValueType &data);
109    
110     /**
111     \brief
112 jgs 117 Copy constructor for DataExpanded.
113     Performs a deep copy from another DataExpanded.
114 jgs 82 */
115 woo409 757 ESCRIPT_DLL_API
116 jgs 117 DataExpanded(const DataExpanded& other);
117    
118     /**
119     \brief
120     Copy constructor for DataExpanded.
121     Construct a DataExpanded from a DataConstant.
122     */
123 woo409 757 ESCRIPT_DLL_API
124 jgs 117 DataExpanded(const DataConstant& other);
125    
126     /**
127     \brief
128     Copy constructor for DataExpanded.
129     Construct a DataExpanded from a DataTagged.
130     */
131 woo409 757 ESCRIPT_DLL_API
132 jgs 117 DataExpanded(const DataTagged& other);
133    
134     /**
135     \brief
136     Default destructor for DataExpanded.
137     */
138 woo409 757 ESCRIPT_DLL_API
139 jgs 102 virtual
140     ~DataExpanded();
141 jgs 82
142     /**
143     \brief
144 jgs 117 Return a textual representation of the data.
145 jgs 82 */
146 woo409 757 ESCRIPT_DLL_API
147 jgs 102 virtual
148     std::string
149     toString() const;
150 gross 950 /**
151     \brief
152     dumps the object into a netCDF file
153     */
154     ESCRIPT_DLL_API
155     virtual
156     void
157     dump(const std::string fileName) const;
158 jgs 82
159 gross 1118 /**
160     \brief
161     sets all values to zero
162     */
163     ESCRIPT_DLL_API
164     virtual
165     void
166     setToZero();
167    
168 jgs 82 /**
169     \brief
170 jgs 117 Return the offset for the given given data point. This returns
171     the offset in bytes for the given point into the container
172 jgs 82 holding the point data.
173 jgs 117
174     \param sampleNo - Input - sample number.
175     \param dataPointNo - Input - data point number.
176 jgs 82 */
177 woo409 757 ESCRIPT_DLL_API
178 jgs 102 virtual
179     DataArrayView::ValueType::size_type
180     getPointOffset(int sampleNo,
181     int dataPointNo) const;
182 jgs 82
183     /**
184     \brief
185 jgs 117 Return a view into the data array for the data point specified.
186    
187 jgs 82 NOTE: Construction of the DataArrayView is a relatively expensive
188 jgs 102 operation.
189 jgs 117
190     \param sampleNo - Input - sample number.
191     \param dataPointNo - Input - data point number.
192     \return DataArrayView for the data point.
193 jgs 82 */
194 woo409 757 ESCRIPT_DLL_API
195 jgs 102 DataArrayView
196     getDataPoint(int sampleNo,
197     int dataPointNo);
198 jgs 82
199     /**
200     \brief
201 jgs 102 Return the number of doubles stored for the Data.
202 jgs 82 */
203 woo409 757 ESCRIPT_DLL_API
204 jgs 102 virtual
205     ValueType::size_type
206     getLength() const;
207 jgs 82
208     /**
209     \brief
210     Factory method that returns a newly created DataExpanded.
211     The caller is reponsible for managing the object created.
212 jgs 117
213 jgs 82 \param region - Input - Region to copy.
214     */
215 woo409 757 ESCRIPT_DLL_API
216 jgs 102 virtual
217     DataAbstract*
218     getSlice(const DataArrayView::RegionType& region) const;
219 jgs 82
220     /**
221     \brief
222     Copy the specified region from the given value.
223 jgs 117
224     \param value - Input - Data object to copy from.
225 jgs 82 \param region - Input - Region to copy.
226     */
227 woo409 757 ESCRIPT_DLL_API
228 jgs 102 virtual
229     void
230     setSlice(const DataAbstract* value,
231     const DataArrayView::RegionType& region);
232 jgs 82
233 jgs 110 /**
234 jgs 123 \brief
235     Archive the underlying data values to the file referenced
236     by ofstream. A count of the number of values expected to be written
237     is provided as a cross-check.
238    
239     The return value indicates success (0) or otherwise (1).
240     */
241 woo409 757 ESCRIPT_DLL_API
242 jgs 123 int
243     archiveData(std::ofstream& archiveFile,
244     const DataArrayView::ValueType::size_type noValues) const;
245    
246     /**
247     \brief
248     Extract the number of values specified by noValues from the file
249     referenced by ifstream to the underlying data structure.
250    
251     The return value indicates success (0) or otherwise (1).
252     */
253 woo409 757 ESCRIPT_DLL_API
254 jgs 123 int
255     extractData(std::ifstream& archiveFile,
256     const DataArrayView::ValueType::size_type noValues);
257    
258 gross 580 /**
259     \brief
260 ksteube 775 Computes a symmetric matrix (A + AT) / 2
261    
262     \param ev - Output - symmetric matrix
263    
264     */
265 gross 800 ESCRIPT_DLL_API
266 ksteube 775 virtual void
267     symmetric(DataAbstract* ev);
268    
269     /**
270     \brief
271     Computes a nonsymmetric matrix (A - AT) / 2
272    
273     \param ev - Output - nonsymmetric matrix
274    
275     */
276 gross 800 ESCRIPT_DLL_API
277 ksteube 775 virtual void
278     nonsymmetric(DataAbstract* ev);
279    
280     /**
281     \brief
282     Computes the trace of a matrix
283    
284     \param ev - Output - trace of your matrix
285    
286     */
287 gross 800 ESCRIPT_DLL_API
288 ksteube 775 virtual void
289 gross 800 trace(DataAbstract* ev, int axis_offset);
290 ksteube 775
291     /**
292     \brief
293     Transpose each data point of this Data object around the given axis.
294    
295     \param ev - Output - transpose of your matrix
296    
297     */
298 gross 800 ESCRIPT_DLL_API
299 ksteube 775 virtual void
300     transpose(DataAbstract* ev, int axis_offset);
301    
302     /**
303     \brief
304 gross 804 swaps components axis0 and axis1
305 gross 800
306     \param ev - Output - swapped components
307    
308     */
309     ESCRIPT_DLL_API
310     virtual void
311 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
312 gross 800
313    
314     /**
315     \brief
316 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
317    
318     \param ev - Output - eigenvalues in increasing order at each data point
319    
320     */
321 woo409 757 ESCRIPT_DLL_API
322 gross 580 virtual void
323     eigenvalues(DataAbstract* ev);
324    
325     /**
326     \brief
327     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
328    
329     \param ev - Output - eigenvalues in increasing order at each data point
330     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
331     and the first nonzero component is positive.
332     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
333    
334     */
335    
336 woo409 757 ESCRIPT_DLL_API
337 gross 580 virtual void
338     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
339    
340    
341 jgs 82 protected:
342    
343     private:
344    
345     /**
346     \brief
347 jgs 117 Common initialisation called from constructors.
348 jgs 82
349     Description:
350 jgs 117 Common initialisation called from constructors.
351    
352     Resizes the underlying data array to provide sufficient storage for the
353     given shape and number of data points, and creates the corresponding
354     DataArrayView of this data.
355    
356 jgs 82 \param shape - Input - The shape of the point data.
357     \param noSamples - Input - number of samples.
358 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
359 jgs 82 */
360 jgs 102 void
361     initialise(const DataArrayView::ShapeType& shape,
362     int noSamples,
363     int noDataPointsPerSample);
364 jgs 82
365     /**
366     \brief
367 jgs 126 Copy the given data point value to all data points in this object.
368 jgs 82
369     Description:
370 jgs 117 Copy the given data point to all data points in this object.
371    
372     \param value Input - A single data point value.
373 jgs 82 */
374 jgs 102 void
375     copy(const DataArrayView& value);
376 jgs 82
377 jgs 126 /**
378     \brief
379     Copy the given data point value given a numarray object to all data points in this object.
380    
381     Description:
382     Copy the given data point value given a numarray object to all data points in this object.
383    
384     \param value Input - A single data point value.
385     */
386 jgs 102 void
387     copy(const boost::python::numeric::array& value);
388    
389 jgs 126 /**
390     \brief
391     Copy the numarray object to the data points in this object.
392    
393     Description:
394     Copy the numarray object to the data points in this object.
395    
396     \param value Input - new values for the data points
397     */
398     void
399     copyAll(const boost::python::numeric::array& value);
400    
401 gross 921 /**
402     \brief
403 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
404    
405     Description:
406     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
407    
408     \param sampleNo Input - sample number
409     \param dataPointNo Input - data point of the sample
410     \param value Input - new values for the data point
411     */
412     ESCRIPT_DLL_API
413     virtual void
414     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
415    
416    
417     /**
418     \brief
419 gross 921 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
420    
421     Description:
422     Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
423    
424     \param sampleNo Input - sample number
425     \param dataPointNo Input - data point of the sample
426     \param value Input - new values for the data point
427     */
428     void
429     copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
430    
431 jgs 82 //
432 jgs 117 // The main data storage array, a 2D array of data blocks.
433     // noSamples * noDataPointsPerSample
434 jgs 82 DataBlocks2D m_data;
435    
436     };
437    
438     } // end of namespace
439 jgs 102
440 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26