/[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

temp/escript/src/DataExpanded.h revision 1387 by trankine, Fri Jan 11 07:45:26 2008 UTC trunk/escript/src/DataExpanded.h revision 2881 by jfenwick, Thu Jan 28 02:03:15 2010 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2010 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #if !defined escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
16  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
17  #include "system_dep.h"  #include "system_dep.h"
18    
19  #include "DataAbstract.h"  #include "DataReady.h"
20  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
 #include "DataArrayView.h"  
   
 #include <boost/python/numeric.hpp>  
21    
22  namespace escript {  namespace escript {
23    
# Line 42  class DataTagged; Line 38  class DataTagged;
38     template must satisfy.     template must satisfy.
39  */  */
40    
41  class DataExpanded : public DataAbstract {  class DataExpanded : public DataReady {
42    
43    typedef DataReady parent;
44    
45   public:   public:
46    
# Line 57  class DataExpanded : public DataAbstract Line 55  class DataExpanded : public DataAbstract
55       this data object, where the number of data points is defined by       this data object, where the number of data points is defined by
56       the given function space.       the given function space.
57    
58       \param value - Input - A single data value.       \param value - Input - The value of a single data point.
      \param what - Input - A description of what this data represents.  
   */  
   ESCRIPT_DLL_API  
   DataExpanded(const boost::python::numeric::array& value,  
                const FunctionSpace& what);  
   
   /**  
      \brief  
      Alternative constructor for DataExpanded.  
   
      Description:  
      Alternative Constructor for DataExpanded.  
   
      The given single data value is copied to all the data points in  
      this data object, where the number of data points is defined by  
      the given function space.  
   
      \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    ESCRIPT_DLL_API
62    DataExpanded(const DataArrayView& value,    DataExpanded(const WrappedArray& value,
63                 const FunctionSpace& what);                 const FunctionSpace& what);
64    
65    /**    /**
# Line 92  class DataExpanded : public DataAbstract Line 72  class DataExpanded : public DataAbstract
72    */    */
73    ESCRIPT_DLL_API    ESCRIPT_DLL_API
74    DataExpanded(const DataExpanded& other,    DataExpanded(const DataExpanded& other,
75                 const DataArrayView::RegionType& region);                 const DataTypes::RegionType& region);
76    
77    /**    /**
78       \brief       \brief
# Line 103  class DataExpanded : public DataAbstract Line 83  class DataExpanded : public DataAbstract
83       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.
84       \param shape - Input - the shape of each data-point.       \param shape - Input - the shape of each data-point.
85       \param data - the array of data values for the data-points.       \param data - the array of data values for the data-points.
86    
87    TODO Note that this constructor will also copy data to all points if it only contains enough elements to hold a single point.  ie this is the merge of two separate constructors.
88    */    */
89    ESCRIPT_DLL_API    ESCRIPT_DLL_API
90    DataExpanded(const FunctionSpace& what,    DataExpanded(const FunctionSpace& what,
91                 const DataArrayView::ShapeType &shape,                 const DataTypes::ShapeType &shape,
92                 const DataArrayView::ValueType &data);                 const DataTypes::ValueType &data);
93    
94    /**    /**
95       \brief       \brief
# Line 141  class DataExpanded : public DataAbstract Line 123  class DataExpanded : public DataAbstract
123    virtual    virtual
124    ~DataExpanded();    ~DataExpanded();
125    
126      ESCRIPT_DLL_API
127      bool
128      isExpanded() const
129      {
130        return true;
131      };
132    
133      ESCRIPT_DLL_API
134      bool
135      actsExpanded() const
136      {
137        return true;
138      }
139    
140      /**
141      \brief Return true if any value in the data contains a NaN.
142      */
143      ESCRIPT_DLL_API
144      bool
145      hasNaN() const;
146    
147    /**    /**
148       \brief       \brief
149       Return a textual representation of the data.       Return a textual representation of the data.
# Line 149  class DataExpanded : public DataAbstract Line 152  class DataExpanded : public DataAbstract
152    virtual    virtual
153    std::string    std::string
154    toString() const;    toString() const;
155    
156      /**
157         \brief Return a deep copy of the current object.
158      */
159      ESCRIPT_DLL_API
160      virtual
161      DataAbstract*
162      deepCopy();
163    
164    
165   /**   /**
166       \brief       \brief
167       dumps the object into a netCDF file       dumps the object into a netCDF file
# Line 158  class DataExpanded : public DataAbstract Line 171  class DataExpanded : public DataAbstract
171    void    void
172    dump(const std::string fileName) const;    dump(const std::string fileName) const;
173    
174    
175      /**
176        \brief invert square matricies
177        \param out - Where to store the results
178        \return errorcode (0 indicates success)
179      */
180      ESCRIPT_DLL_API
181      virtual int
182      matrixInverse(DataAbstract* out) const;
183    
184   /**   /**
185       \brief       \brief
186      sets all values to zero      sets all values to zero
# Line 178  class DataExpanded : public DataAbstract Line 201  class DataExpanded : public DataAbstract
201    */    */
202    ESCRIPT_DLL_API    ESCRIPT_DLL_API
203    virtual    virtual
204    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
205    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
206                   int dataPointNo) const;                   int dataPointNo) const;
207    
208      ESCRIPT_DLL_API
209      virtual
210      DataTypes::ValueType::size_type
211      getPointOffset(int sampleNo,
212                     int dataPointNo);
213    
214    /**    /**
215       \brief       \brief
216       Return a view into the data array for the data point specified.       Return a a reference to the underlying DataVector.
217      */
218    
219       NOTE: Construction of the DataArrayView is a relatively expensive    ESCRIPT_DLL_API
220       operation.    DataTypes::ValueType&
221      getVectorRW();
222    
      \param sampleNo - Input - sample number.  
      \param dataPointNo - Input - data point number.  
      \return DataArrayView for the data point.  
   */  
223    ESCRIPT_DLL_API    ESCRIPT_DLL_API
224    DataArrayView    const DataTypes::ValueType&
225    getDataPoint(int sampleNo,    getVectorRO() const;
226                 int dataPointNo);  
227    
228    
229    /**    /**
230       \brief       \brief
# Line 217  class DataExpanded : public DataAbstract Line 245  class DataExpanded : public DataAbstract
245    ESCRIPT_DLL_API    ESCRIPT_DLL_API
246    virtual    virtual
247    DataAbstract*    DataAbstract*
248    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
249    
250    /**    /**
251       \brief       \brief
# Line 230  class DataExpanded : public DataAbstract Line 258  class DataExpanded : public DataAbstract
258    virtual    virtual
259    void    void
260    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
261             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
   
   /**  
     \brief  
     Archive the underlying data values to the file referenced  
     by ofstream. A count of the number of values expected to be written  
     is provided as a cross-check.  
   
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   int  
   archiveData(std::ofstream& archiveFile,  
               const DataArrayView::ValueType::size_type noValues) const;  
   
   /**  
     \brief  
     Extract the number of values specified by noValues from the file  
     referenced by ifstream to the underlying data structure.  
   
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   int  
   extractData(std::ifstream& archiveFile,  
               const DataArrayView::ValueType::size_type noValues);  
262    
263    /**    /**
264       \brief       \brief
# Line 265  class DataExpanded : public DataAbstract Line 268  class DataExpanded : public DataAbstract
268       uses tag to set a new value       uses tag to set a new value
269    
270       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
271       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param pointshape - Input - The shape of the value parameter
272         \param value - Input -
273         \param dataOffset - Input - where in the value parameter to start reading the data point value.
274    */    */
275    ESCRIPT_DLL_API    void  
   virtual  
   void  
276    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
277                   const DataArrayView& value);               const DataTypes::ShapeType& pointshape,
278                     const DataTypes::ValueType& value,
279             int dataOffset=0);
280    
281    
282    
283    /**    /**
284       \brief       \brief
# Line 300  class DataExpanded : public DataAbstract Line 307  class DataExpanded : public DataAbstract
307       Computes the trace of a matrix       Computes the trace of a matrix
308    
309       \param ev - Output - trace of your matrix       \param ev - Output - trace of your matrix
310         \param axis_offset -
311    
312    */    */
313    ESCRIPT_DLL_API    ESCRIPT_DLL_API
# Line 311  class DataExpanded : public DataAbstract Line 319  class DataExpanded : public DataAbstract
319       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
320    
321       \param ev - Output - transpose of your matrix       \param ev - Output - transpose of your matrix
322         \param axis_offset -
323    */    */
324    ESCRIPT_DLL_API    ESCRIPT_DLL_API
325    virtual void    virtual void
# Line 322  class DataExpanded : public DataAbstract Line 330  class DataExpanded : public DataAbstract
330       swaps components axis0 and axis1       swaps components axis0 and axis1
331    
332       \param ev - Output - swapped components       \param ev - Output - swapped components
333         \param axis0
334         \param axis1
335    */    */
336    ESCRIPT_DLL_API    ESCRIPT_DLL_API
337    virtual void    virtual void
# Line 355  class DataExpanded : public DataAbstract Line 364  class DataExpanded : public DataAbstract
364    virtual void    virtual void
365    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
366    
367    /**
368     *      \brief
369     *           reorders data sample ordered by reference_ids to the ordering of the functions space
370     *
371     *                \param reference_ids - Input - reference_ids used for current ordering
372     *                  */
373      ESCRIPT_DLL_API
374      virtual void
375      reorderByReferenceIDs(int *reference_ids);
376    
377    
378    
379   protected:   protected:
380    
# Line 371  class DataExpanded : public DataAbstract Line 391  class DataExpanded : public DataAbstract
391       given shape and number of data points, and creates the corresponding       given shape and number of data points, and creates the corresponding
392       DataArrayView of this data.       DataArrayView of this data.
393    
      \param shape - Input - The shape of the point data.  
394       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
395       \param noDataPointsPerSample - Input - number of data points per sample.       \param noDataPointsPerSample - Input - number of data points per sample.
396    */    */
397    void    void
398    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
399               int noDataPointsPerSample);               int noDataPointsPerSample);
400    
401    /**    /**
# Line 390  class DataExpanded : public DataAbstract Line 408  class DataExpanded : public DataAbstract
408       \param value Input - A single data point value.       \param value Input - A single data point value.
409    */    */
410    void    void
411    copy(const DataArrayView& value);    copy(const DataConstant& value);
   
   /**  
      \brief  
      Copy the given data point value given a numarray object to all data points in this object.  
412    
      Description:  
      Copy the given data point value given a numarray object to all data points in this object.  
413    
      \param value Input - A single data point value.  
   */  
   void  
   copy(const boost::python::numeric::array& value);  
414    
415    /**    /**
416       \brief       \brief
417       Copy the numarray object to the data points in this object.       Copy the given data point value to all data points in this object.
   
      Description:  
      Copy the numarray object to the data points in this object.  
418    
419       \param value Input - new values for the data points       \param value Input - A single data point value.
420    */    */
421    
422    void    void
423    copyAll(const boost::python::numeric::array& value);    copy(const WrappedArray& value);
424    
425    
426    /**    /**
427       \brief       \brief
# Line 434  class DataExpanded : public DataAbstract Line 441  class DataExpanded : public DataAbstract
441    
442    /**    /**
443       \brief       \brief
444       Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.       Copy the value to the data point dataPointNo of sample sampleNo in this object.
   
      Description:  
      Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.  
445    
446       \param sampleNo Input - sample number       \param sampleNo Input - sample number
447       \param dataPointNo Input - data point of the sample       \param dataPointNo Input - data point of the sample
448       \param value Input - new values for the data point       \param value Input - new values for the data point
449    */    */
450    void    ESCRIPT_DLL_API
451    copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);    virtual void
452      copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
453    
454    //    //
455    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.

Legend:
Removed from v.1387  
changed lines
  Added in v.2881

  ViewVC Help
Powered by ViewVC 1.1.26