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

revision 804 by gross, Thu Aug 10 01:12:16 2006 UTC revision 2653 by jfenwick, Tue Sep 8 04:26:30 2009 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   ************************************************************  *
4   *          Copyright 2006 by ACcESS MNRF                   *  * Copyright (c) 2003-2009 by University of Queensland
5   *                                                          *  * Earth Systems Science Computational Center (ESSCC)
6   *              http://www.access.edu.au                    *  * http://www.uq.edu.au/esscc
7   *       Primary Business: Queensland, Australia            *  *
8   *  Licensed under the Open Software License version 3.0    *  * Primary Business: Queensland, Australia
9   *     http://www.opensource.org/licenses/osl-3.0.php       *  * Licensed under the Open Software License version 3.0
10   *                                                          *  * 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 40  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 55  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 90  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 101  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 139  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 147  class DataExpanded : public DataAbstract
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       Reshape the data point if the data point is currently rank 0.       dumps the object into a netCDF file
      The original data point value is used for all values of the new  
      data point.  
161    */    */
162    ESCRIPT_DLL_API    ESCRIPT_DLL_API
163      virtual
164    void    void
165    reshapeDataPoint(const DataArrayView::ShapeType& shape);    dump(const std::string fileName) const;
166    
167     /**
168         \brief
169        sets all values to zero
170      */
171      ESCRIPT_DLL_API
172      virtual
173      void
174      setToZero();
175    
176    /**    /**
177       \brief       \brief
# Line 169  class DataExpanded : public DataAbstract Line 184  class DataExpanded : public DataAbstract
184    */    */
185    ESCRIPT_DLL_API    ESCRIPT_DLL_API
186    virtual    virtual
187    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
188    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
189                   int dataPointNo) const;                   int dataPointNo) const;
190    
191      ESCRIPT_DLL_API
192      virtual
193      DataTypes::ValueType::size_type
194      getPointOffset(int sampleNo,
195                     int dataPointNo);
196    
197    /**    /**
198       \brief       \brief
199       Return a view into the data array for the data point specified.       Return a a reference to the underlying DataVector.
200      */
201    
202       NOTE: Construction of the DataArrayView is a relatively expensive    ESCRIPT_DLL_API
203       operation.    DataTypes::ValueType&
204      getVectorRW();
205    
      \param sampleNo - Input - sample number.  
      \param dataPointNo - Input - data point number.  
      \return DataArrayView for the data point.  
   */  
206    ESCRIPT_DLL_API    ESCRIPT_DLL_API
207    DataArrayView    const DataTypes::ValueType&
208    getDataPoint(int sampleNo,    getVectorRO() const;
209                 int dataPointNo);  
210    
211    
212    /**    /**
213       \brief       \brief
# Line 208  class DataExpanded : public DataAbstract Line 228  class DataExpanded : public DataAbstract
228    ESCRIPT_DLL_API    ESCRIPT_DLL_API
229    virtual    virtual
230    DataAbstract*    DataAbstract*
231    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
232    
233    /**    /**
234       \brief       \brief
# Line 221  class DataExpanded : public DataAbstract Line 241  class DataExpanded : public DataAbstract
241    virtual    virtual
242    void    void
243    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
244             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
245    
246    /**    /**
247       \brief       \brief
248       Assign the given value to all data-points associated with the given       setTaggedValue
      reference number.  
   
      A reference number corresponds to a sample, and thus to all data-points  
      in that sample.  
   
      If the given reference number does not correspond to any sample in this  
      Data object, an exception will be thrown.  
249    
250       If the given value is a different shape to this Data object, an exception       Description:
251       will be thrown.       uses tag to set a new value
   
      \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.  
   */  
   ESCRIPT_DLL_API  
   virtual  
   void  
   setRefValue(int ref,  
               const DataArray& value);  
   
   /**  
      \brief  
      Return the value of the first data-point in the sample associated with  
      the given reference number.  
   
      A reference number corresponds to a sample, and thus to all data-points  
      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.  
   
      If the given reference number does not correspond to any sample in this  
      Data object, an exception will be thrown.  
   
      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 number to  
                           read from.  
      \param value - Output - Object to receive data-points associated with  
                             the given reference number.  
   */  
   ESCRIPT_DLL_API  
   virtual  
   void  
   getRefValue(int ref,  
               DataArray& value);  
   
   /**  
     \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.  
252    
253      The return value indicates success (0) or otherwise (1).       \param tagKey - Input - Integer key.
254    */       \param pointshape - Input - The shape of the value parameter
255    ESCRIPT_DLL_API       \param value - Input -
256    int       \param dataOffset - Input - where in the value parameter to start reading the data point value.
257    archiveData(std::ofstream& archiveFile,    */
258                const DataArrayView::ValueType::size_type noValues) const;    void  
259      setTaggedValue(int tagKey,
260                 const DataTypes::ShapeType& pointshape,
261                     const DataTypes::ValueType& value,
262             int dataOffset=0);
263    
   /**  
     \brief  
     Extract the number of values specified by noValues from the file  
     referenced by ifstream to the underlying data structure.  
264    
     The return value indicates success (0) or otherwise (1).  
   */  
   ESCRIPT_DLL_API  
   int  
   extractData(std::ifstream& archiveFile,  
               const DataArrayView::ValueType::size_type noValues);  
265    
266    /**    /**
267       \brief       \brief
# Line 326  class DataExpanded : public DataAbstract Line 290  class DataExpanded : public DataAbstract
290       Computes the trace of a matrix       Computes the trace of a matrix
291    
292       \param ev - Output - trace of your matrix       \param ev - Output - trace of your matrix
293         \param axis_offset -
294    
295    */    */
296    ESCRIPT_DLL_API    ESCRIPT_DLL_API
# Line 337  class DataExpanded : public DataAbstract Line 302  class DataExpanded : public DataAbstract
302       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
303    
304       \param ev - Output - transpose of your matrix       \param ev - Output - transpose of your matrix
305         \param axis_offset -
306    */    */
307    ESCRIPT_DLL_API    ESCRIPT_DLL_API
308    virtual void    virtual void
# Line 348  class DataExpanded : public DataAbstract Line 313  class DataExpanded : public DataAbstract
313       swaps components axis0 and axis1       swaps components axis0 and axis1
314    
315       \param ev - Output - swapped components       \param ev - Output - swapped components
316         \param axis0
317         \param axis1
318    */    */
319    ESCRIPT_DLL_API    ESCRIPT_DLL_API
320    virtual void    virtual void
# Line 381  class DataExpanded : public DataAbstract Line 347  class DataExpanded : public DataAbstract
347    virtual void    virtual void
348    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);
349    
350    /**
351     *      \brief
352     *           reorders data sample ordered by reference_ids to the ordering of the functions space
353     *
354     *                \param reference_ids - Input - reference_ids used for current ordering
355     *                  */
356      ESCRIPT_DLL_API
357      virtual void
358      reorderByReferenceIDs(int *reference_ids);
359    
360    
361    
362   protected:   protected:
363    
# Line 397  class DataExpanded : public DataAbstract Line 374  class DataExpanded : public DataAbstract
374       given shape and number of data points, and creates the corresponding       given shape and number of data points, and creates the corresponding
375       DataArrayView of this data.       DataArrayView of this data.
376    
      \param shape - Input - The shape of the point data.  
377       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
378       \param noDataPointsPerSample - Input - number of data points per sample.       \param noDataPointsPerSample - Input - number of data points per sample.
379    */    */
380    void    void
381    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
382               int noDataPointsPerSample);               int noDataPointsPerSample);
383    
384    /**    /**
# Line 416  class DataExpanded : public DataAbstract Line 391  class DataExpanded : public DataAbstract
391       \param value Input - A single data point value.       \param value Input - A single data point value.
392    */    */
393    void    void
394    copy(const DataArrayView& value);    copy(const DataConstant& value);
395    
396    
397    
398    /**    /**
399       \brief       \brief
400       Copy the given data point value given a numarray object to all data points in this object.       Copy the given data point value to all data points in this object.
   
      Description:  
      Copy the given data point value given a numarray object to all data points in this object.  
401    
402       \param value Input - A single data point value.       \param value Input - A single data point value.
403    */    */
404    
405    void    void
406    copy(const boost::python::numeric::array& value);    copy(const WrappedArray& value);
407    
408    
409    /**    /**
410       \brief       \brief
411       Copy the numarray object to the data points in this object.       Copy a double value to the data point dataPointNo of sample sampleNo in this object.
412    
413       Description:       Description:
414       Copy the numarray object to the data points in this object.       Copy a double value to the data point dataPointNo of sample sampleNo in this object.
415    
416       \param value Input - new values for the data points       \param sampleNo Input - sample number
417         \param dataPointNo Input - data point of the sample
418         \param value Input - new values for the data point
419    */    */
420    void    ESCRIPT_DLL_API
421    copyAll(const boost::python::numeric::array& value);    virtual void
422      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
423    
424    
425      /**
426         \brief
427         Copy the value to the data point dataPointNo of sample sampleNo in this object.
428    
429         \param sampleNo Input - sample number
430         \param dataPointNo Input - data point of the sample
431         \param value Input - new values for the data point
432      */
433      ESCRIPT_DLL_API
434      virtual void
435      copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
436    
437    //    //
438    // 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.804  
changed lines
  Added in v.2653

  ViewVC Help
Powered by ViewVC 1.1.26