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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/DataExpanded.h revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC trunk/escript/src/DataExpanded.h revision 1118 by gross, Tue Apr 24 08:55:04 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13                                                                              
14  #if !defined escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
15  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
16    #include "system_dep.h"
17    
18  #include "DataAbstract.h"  #include "DataAbstract.h"
19  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
20  #include "DataArrayView.h"  #include "DataArrayView.h"
21    
 #include <boost/scoped_ptr.hpp>  
22  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
23    
24  namespace escript {  namespace escript {
25    
26  //  //
27  // Forward declarations of other Data types.  // Forward declarations of other Data types.
 class DataEmpty;  
28  class DataConstant;  class DataConstant;
29  class DataTagged;  class DataTagged;
30    
# Line 61  class DataExpanded : public DataAbstract Line 58  class DataExpanded : public DataAbstract
58       \param value - Input - A single data value.       \param value - Input - A single data value.
59       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
60    */    */
61      ESCRIPT_DLL_API
62    DataExpanded(const boost::python::numeric::array& value,    DataExpanded(const boost::python::numeric::array& value,
63                 const FunctionSpace& what);                 const FunctionSpace& what);
64    
# Line 78  class DataExpanded : public DataAbstract Line 76  class DataExpanded : public DataAbstract
76       \param value - Input - A single data value.       \param value - Input - A single data value.
77       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
78    */    */
79      ESCRIPT_DLL_API
80    DataExpanded(const DataArrayView& value,    DataExpanded(const DataArrayView& value,
81                 const FunctionSpace& what);                 const FunctionSpace& what);
82    
# Line 89  class DataExpanded : public DataAbstract Line 88  class DataExpanded : public DataAbstract
88       \param other - Input - DataExpanded object to slice from.       \param other - Input - DataExpanded object to slice from.
89       \param region - Input - region to copy.       \param region - Input - region to copy.
90    */    */
91      ESCRIPT_DLL_API
92    DataExpanded(const DataExpanded& other,    DataExpanded(const DataExpanded& other,
93                 const DataArrayView::RegionType& region);                 const DataArrayView::RegionType& region);
94    
95    /**    /**
96       \brief       \brief
97         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         \param data - the array of data values for the data-points.
104      */
105      ESCRIPT_DLL_API
106      DataExpanded(const FunctionSpace& what,
107                   const DataArrayView::ShapeType &shape,
108                   const DataArrayView::ValueType &data);
109    
110      /**
111         \brief
112       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
113       Performs a deep copy from another DataExpanded.       Performs a deep copy from another DataExpanded.
114    */    */
115      ESCRIPT_DLL_API
116    DataExpanded(const DataExpanded& other);    DataExpanded(const DataExpanded& other);
117    
118    /**    /**
# Line 104  class DataExpanded : public DataAbstract Line 120  class DataExpanded : public DataAbstract
120       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
121       Construct a DataExpanded from a DataConstant.       Construct a DataExpanded from a DataConstant.
122    */    */
123      ESCRIPT_DLL_API
124    DataExpanded(const DataConstant& other);    DataExpanded(const DataConstant& other);
125    
126    /**    /**
# Line 111  class DataExpanded : public DataAbstract Line 128  class DataExpanded : public DataAbstract
128       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
129       Construct a DataExpanded from a DataTagged.       Construct a DataExpanded from a DataTagged.
130    */    */
131      ESCRIPT_DLL_API
132    DataExpanded(const DataTagged& other);    DataExpanded(const DataTagged& other);
133    
134    /**    /**
135       \brief       \brief
136       Default destructor for DataExpanded.       Default destructor for DataExpanded.
137    */    */
138      ESCRIPT_DLL_API
139    virtual    virtual
140    ~DataExpanded();    ~DataExpanded();
141    
# Line 124  class DataExpanded : public DataAbstract Line 143  class DataExpanded : public DataAbstract
143       \brief       \brief
144       Return a textual representation of the data.       Return a textual representation of the data.
145    */    */
146      ESCRIPT_DLL_API
147    virtual    virtual
148    std::string    std::string
149    toString() const;    toString() const;
150     /**
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    
159    /**   /**
160       \brief       \brief
161       Reshape the data point if the data point is currently rank 0.      sets all values to zero
      The original data point value is used for all values of the new  
      data point.  
162    */    */
163      ESCRIPT_DLL_API
164      virtual
165    void    void
166    reshapeDataPoint(const DataArrayView::ShapeType& shape);    setToZero();
167    
168    /**    /**
169       \brief       \brief
# Line 146  class DataExpanded : public DataAbstract Line 174  class DataExpanded : public DataAbstract
174       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
175       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
176    */    */
177      ESCRIPT_DLL_API
178    virtual    virtual
179    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
180    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 162  class DataExpanded : public DataAbstract Line 191  class DataExpanded : public DataAbstract
191       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
192       \return DataArrayView for the data point.       \return DataArrayView for the data point.
193    */    */
194      ESCRIPT_DLL_API
195    DataArrayView    DataArrayView
196    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
197                 int dataPointNo);                 int dataPointNo);
# Line 170  class DataExpanded : public DataAbstract Line 200  class DataExpanded : public DataAbstract
200       \brief       \brief
201       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
202    */    */
203      ESCRIPT_DLL_API
204    virtual    virtual
205    ValueType::size_type    ValueType::size_type
206    getLength() const;    getLength() const;
# Line 181  class DataExpanded : public DataAbstract Line 212  class DataExpanded : public DataAbstract
212    
213       \param region - Input - Region to copy.       \param region - Input - Region to copy.
214    */    */
215      ESCRIPT_DLL_API
216    virtual    virtual
217    DataAbstract*    DataAbstract*
218    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 192  class DataExpanded : public DataAbstract Line 224  class DataExpanded : public DataAbstract
224       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
225       \param region - Input - Region to copy.       \param region - Input - Region to copy.
226    */    */
227      ESCRIPT_DLL_API
228    virtual    virtual
229    void    void
230    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
231             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
232    
233    /**    /**
234        \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      ESCRIPT_DLL_API
242      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      ESCRIPT_DLL_API
254      int
255      extractData(std::ifstream& archiveFile,
256                  const DataArrayView::ValueType::size_type noValues);
257    
258      /**
259       \brief       \brief
260       Assign the given value to all data-points associated with the given       Computes a symmetric matrix (A + AT) / 2
      reference number.  
261    
262       A reference number corresponds to a sample, and thus to all data-points       \param ev - Output - symmetric matrix
      in that sample.  
263    
264       If the given reference number does not correspond to any sample in this    */
265       Data object, an exception will be thrown.    ESCRIPT_DLL_API
266      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    
      If the given value is a different shape to this Data object, an exception  
      will be thrown.  
   
      \param ref - Input - reference number which determines sample numebr to  
                           assign given values to.  
      \param value - Input - Value to assign to data-point associated with  
                             the given reference number.  
275    */    */
276    virtual    ESCRIPT_DLL_API
277    void    virtual void
278    setRefValue(int ref,    nonsymmetric(DataAbstract* ev);
               const DataArray& value);  
279    
280    /**    /**
281       \brief       \brief
282       Return the value of the first data-point in the sample associated with       Computes the trace of a matrix
      the given reference number.  
283    
284       A reference number corresponds to a sample, and thus to all data-points       \param ev - Output - trace of your matrix
      in that sample. If there is more than one data-point per sample number  
      in this Data object, the value of the first data-point will be returned.  
285    
286       If the given reference number does not correspond to any sample in this    */
287       Data object, an exception will be thrown.    ESCRIPT_DLL_API
288      virtual void
289      trace(DataAbstract* ev, int axis_offset);
290    
291       If the given value is a different shape to this Data object, an exception    /**
292       will be thrown.       \brief
293         Transpose each data point of this Data object around the given axis.
294    
295         \param ev - Output - transpose of your matrix
296    
      \param ref - Input - reference number which determines sample number to  
                           read from.  
      \param value - Output - Object to receive data-points associated with  
                             the given reference number.  
297    */    */
298    virtual    ESCRIPT_DLL_API
299    void    virtual void
300    getRefValue(int ref,    transpose(DataAbstract* ev, int axis_offset);
301                DataArray& value);  
302      /**
303         \brief
304         swaps components axis0 and axis1
305    
306         \param ev - Output - swapped components
307    
308      */
309      ESCRIPT_DLL_API
310      virtual void
311      swapaxes(DataAbstract* ev, int axis0, int axis1);
312    
313    
314      /**
315         \brief
316         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      ESCRIPT_DLL_API
322      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      ESCRIPT_DLL_API
337      virtual void
338      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
339    
340    
341   protected:   protected:
342    
# Line 272  class DataExpanded : public DataAbstract Line 364  class DataExpanded : public DataAbstract
364    
365    /**    /**
366       \brief       \brief
367       Copy the given data point to all data points in this object.       Copy the given data point value to all data points in this object.
368    
369       Description:       Description:
370       Copy the given data point to all data points in this object.       Copy the given data point to all data points in this object.
# Line 282  class DataExpanded : public DataAbstract Line 374  class DataExpanded : public DataAbstract
374    void    void
375    copy(const DataArrayView& value);    copy(const DataArrayView& value);
376    
377      /**
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    void    void
387    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
388    
389      /**
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      /**
402         \brief
403         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         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    //    //
432    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
433    // noSamples * noDataPointsPerSample    // noSamples * noDataPointsPerSample

Legend:
Removed from v.117  
changed lines
  Added in v.1118

  ViewVC Help
Powered by ViewVC 1.1.26