/[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_trunk_copy/escript/src/DataExpanded.h revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC trunk/escript/src/DataExpanded.h revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2009 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.
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 boost::python::numeric::array& value,    DataExpanded(const WrappedArray& 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.  
      \param what - Input - A description of what this data represents.  
   */  
   ESCRIPT_DLL_API  
   DataExpanded(const DataArrayView& 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       \brief
142       Return a textual representation of the data.       Return a textual representation of the data.
# Line 149  class DataExpanded : public DataAbstract Line 145  class DataExpanded : public DataAbstract
145    virtual    virtual
146    std::string    std::string
147    toString() const;    toString() const;
148    
149      /**
150         \brief Return a deep copy of the current object.
151      */
152      ESCRIPT_DLL_API
153      virtual
154      DataAbstract*
155      deepCopy();
156    
157    
158   /**   /**
159       \brief       \brief
160       dumps the object into a netCDF file       dumps the object into a netCDF file
# Line 158  class DataExpanded : public DataAbstract Line 164  class DataExpanded : public DataAbstract
164    void    void
165    dump(const std::string fileName) const;    dump(const std::string fileName) const;
166    
167    
168      /**
169        \brief invert square matricies
170        \param out - Where to store the results
171      */
172      ESCRIPT_DLL_API
173      virtual void
174      matrixInverse(DataAbstract* out) const;
175    
176   /**   /**
177       \brief       \brief
178      sets all values to zero      sets all values to zero
# Line 178  class DataExpanded : public DataAbstract Line 193  class DataExpanded : public DataAbstract
193    */    */
194    ESCRIPT_DLL_API    ESCRIPT_DLL_API
195    virtual    virtual
196    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
197    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
198                   int dataPointNo) const;                   int dataPointNo) const;
199    
200      ESCRIPT_DLL_API
201      virtual
202      DataTypes::ValueType::size_type
203      getPointOffset(int sampleNo,
204                     int dataPointNo);
205    
206    /**    /**
207       \brief       \brief
208       Return a view into the data array for the data point specified.       Return a a reference to the underlying DataVector.
209      */
210    
211       NOTE: Construction of the DataArrayView is a relatively expensive    ESCRIPT_DLL_API
212       operation.    DataTypes::ValueType&
213      getVectorRW();
214    
      \param sampleNo - Input - sample number.  
      \param dataPointNo - Input - data point number.  
      \return DataArrayView for the data point.  
   */  
215    ESCRIPT_DLL_API    ESCRIPT_DLL_API
216    DataArrayView    const DataTypes::ValueType&
217    getDataPoint(int sampleNo,    getVectorRO() const;
218                 int dataPointNo);  
219    
220    
221    /**    /**
222       \brief       \brief
# Line 217  class DataExpanded : public DataAbstract Line 237  class DataExpanded : public DataAbstract
237    ESCRIPT_DLL_API    ESCRIPT_DLL_API
238    virtual    virtual
239    DataAbstract*    DataAbstract*
240    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
241    
242    /**    /**
243       \brief       \brief
# Line 230  class DataExpanded : public DataAbstract Line 250  class DataExpanded : public DataAbstract
250    virtual    virtual
251    void    void
252    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
253             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);  
254    
255    /**    /**
256       \brief       \brief
# Line 265  class DataExpanded : public DataAbstract Line 260  class DataExpanded : public DataAbstract
260       uses tag to set a new value       uses tag to set a new value
261    
262       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
263       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param pointshape - Input - The shape of the value parameter
264         \param value - Input -
265         \param dataOffset - Input - where in the value parameter to start reading the data point value.
266    */    */
267    ESCRIPT_DLL_API    void  
   virtual  
   void  
268    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
269                   const DataArrayView& value);               const DataTypes::ShapeType& pointshape,
270                     const DataTypes::ValueType& value,
271             int dataOffset=0);
272    
273    
274    
275    /**    /**
276       \brief       \brief
# Line 300  class DataExpanded : public DataAbstract Line 299  class DataExpanded : public DataAbstract
299       Computes the trace of a matrix       Computes the trace of a matrix
300    
301       \param ev - Output - trace of your matrix       \param ev - Output - trace of your matrix
302         \param axis_offset -
303    
304    */    */
305    ESCRIPT_DLL_API    ESCRIPT_DLL_API
# Line 311  class DataExpanded : public DataAbstract Line 311  class DataExpanded : public DataAbstract
311       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
312    
313       \param ev - Output - transpose of your matrix       \param ev - Output - transpose of your matrix
314         \param axis_offset -
315    */    */
316    ESCRIPT_DLL_API    ESCRIPT_DLL_API
317    virtual void    virtual void
# Line 322  class DataExpanded : public DataAbstract Line 322  class DataExpanded : public DataAbstract
322       swaps components axis0 and axis1       swaps components axis0 and axis1
323    
324       \param ev - Output - swapped components       \param ev - Output - swapped components
325         \param axis0
326         \param axis1
327    */    */
328    ESCRIPT_DLL_API    ESCRIPT_DLL_API
329    virtual void    virtual void
# Line 355  class DataExpanded : public DataAbstract Line 356  class DataExpanded : public DataAbstract
356    virtual void    virtual void
357    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);
358    
359    /**
360     *      \brief
361     *           reorders data sample ordered by reference_ids to the ordering of the functions space
362     *
363     *                \param reference_ids - Input - reference_ids used for current ordering
364     *                  */
365      ESCRIPT_DLL_API
366      virtual void
367      reorderByReferenceIDs(int *reference_ids);
368    
369    
370    
371   protected:   protected:
372    
# Line 371  class DataExpanded : public DataAbstract Line 383  class DataExpanded : public DataAbstract
383       given shape and number of data points, and creates the corresponding       given shape and number of data points, and creates the corresponding
384       DataArrayView of this data.       DataArrayView of this data.
385    
      \param shape - Input - The shape of the point data.  
386       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
387       \param noDataPointsPerSample - Input - number of data points per sample.       \param noDataPointsPerSample - Input - number of data points per sample.
388    */    */
389    void    void
390    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
391               int noDataPointsPerSample);               int noDataPointsPerSample);
392    
393    /**    /**
# Line 390  class DataExpanded : public DataAbstract Line 400  class DataExpanded : public DataAbstract
400       \param value Input - A single data point value.       \param value Input - A single data point value.
401    */    */
402    void    void
403    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.  
404    
      Description:  
      Copy the given data point value given a numarray object to all data points in this object.  
405    
      \param value Input - A single data point value.  
   */  
   void  
   copy(const boost::python::numeric::array& value);  
406    
407    /**    /**
408       \brief       \brief
409       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.  
410    
411       \param value Input - new values for the data points       \param value Input - A single data point value.
412    */    */
413    
414    void    void
415    copyAll(const boost::python::numeric::array& value);    copy(const WrappedArray& value);
416    
417    
418    /**    /**
419       \brief       \brief
# Line 434  class DataExpanded : public DataAbstract Line 433  class DataExpanded : public DataAbstract
433    
434    /**    /**
435       \brief       \brief
436       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.  
437    
438       \param sampleNo Input - sample number       \param sampleNo Input - sample number
439       \param dataPointNo Input - data point of the sample       \param dataPointNo Input - data point of the sample
440       \param value Input - new values for the data point       \param value Input - new values for the data point
441    */    */
442    void    ESCRIPT_DLL_API
443    copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);    virtual void
444      copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
445    
446    //    //
447    // 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.1384  
changed lines
  Added in v.2742

  ViewVC Help
Powered by ViewVC 1.1.26