/[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/escript/src/Data/DataExpanded.h revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC trunk/escript/src/DataExpanded.h revision 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   ******************************************************************************  *
4   *                                                                            *  * Copyright (c) 2003-2008 by University of Queensland
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Earth Systems Science Computational Center (ESSCC)
6   *                                                                            *  * http://www.uq.edu.au/esscc
7   * This software is the property of ACcESS. No part of this code              *  *
8   * may be copied in any form or by any means without the expressed written    *  * Primary Business: Queensland, Australia
9   * consent of ACcESS.  Copying, use or modification of this software          *  * Licensed under the Open Software License version 3.0
10   * by any unauthorised person is illegal unless that person has a software    *  * http://www.opensource.org/licenses/osl-3.0.php
11   * license agreement with ACcESS.                                             *  *
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"
18    
19  #include "DataAbstract.h"  #include "DataAbstract.h"
20  #include "DataBlocks2D.h"  #include "DataBlocks2D.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    
65    /**    /**
66       \brief       \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.  
   */  
   DataExpanded(const DataArrayView& value,  
                const FunctionSpace& what);  
   
   /**  
      \brief  
67       Alternative constructor for DataExpanded that copies a slice from       Alternative constructor for DataExpanded that copies a slice from
68       another DataExpanded.       another DataExpanded.
69    
70       \param other - Input - DataExpanded object to slice from.       \param other - Input - DataExpanded object to slice from.
71       \param region - Input - region to copy.       \param region - Input - region to copy.
72    */    */
73      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
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
96       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
97       Performs a deep copy from another DataExpanded.       Performs a deep copy from another DataExpanded.
98    */    */
99      ESCRIPT_DLL_API
100    DataExpanded(const DataExpanded& other);    DataExpanded(const DataExpanded& other);
101    
102    /**    /**
# Line 118  class DataExpanded : public DataAbstract Line 104  class DataExpanded : public DataAbstract
104       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
105       Construct a DataExpanded from a DataConstant.       Construct a DataExpanded from a DataConstant.
106    */    */
107      ESCRIPT_DLL_API
108    DataExpanded(const DataConstant& other);    DataExpanded(const DataConstant& other);
109    
110    /**    /**
# Line 125  class DataExpanded : public DataAbstract Line 112  class DataExpanded : public DataAbstract
112       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
113       Construct a DataExpanded from a DataTagged.       Construct a DataExpanded from a DataTagged.
114    */    */
115      ESCRIPT_DLL_API
116    DataExpanded(const DataTagged& other);    DataExpanded(const DataTagged& other);
117    
118    /**    /**
119       \brief       \brief
120       Default destructor for DataExpanded.       Default destructor for DataExpanded.
121    */    */
122      ESCRIPT_DLL_API
123    virtual    virtual
124    ~DataExpanded();    ~DataExpanded();
125    
# Line 138  class DataExpanded : public DataAbstract Line 127  class DataExpanded : public DataAbstract
127       \brief       \brief
128       Return a textual representation of the data.       Return a textual representation of the data.
129    */    */
130      ESCRIPT_DLL_API
131    virtual    virtual
132    std::string    std::string
133    toString() const;    toString() const;
134    
135    /**    /**
136         \brief Return a deep copy of the current object.
137      */
138      ESCRIPT_DLL_API
139      virtual
140      DataAbstract*
141      deepCopy();
142    
143    
144     /**
145       \brief       \brief
146       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.  
147    */    */
148      ESCRIPT_DLL_API
149      virtual
150    void    void
151    reshapeDataPoint(const DataArrayView::ShapeType& shape);    dump(const std::string fileName) const;
152    
153     /**
154         \brief
155        sets all values to zero
156      */
157      ESCRIPT_DLL_API
158      virtual
159      void
160      setToZero();
161    
162    /**    /**
163       \brief       \brief
# Line 160  class DataExpanded : public DataAbstract Line 168  class DataExpanded : public DataAbstract
168       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
169       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
170    */    */
171      ESCRIPT_DLL_API
172    virtual    virtual
173    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
174    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
175                   int dataPointNo) const;                   int dataPointNo) const;
176    
177    /**    /**
178       \brief       \brief
179       Return a view into the data array for the data point specified.       Return a a reference to the underlying DataVector.
180      */
181    
182       NOTE: Construction of the DataArrayView is a relatively expensive    ESCRIPT_DLL_API
183       operation.    DataTypes::ValueType&
184      getVector();
185    
186      ESCRIPT_DLL_API
187      const DataTypes::ValueType&
188      getVector() const;
189    
      \param sampleNo - Input - sample number.  
      \param dataPointNo - Input - data point number.  
      \return DataArrayView for the data point.  
   */  
   DataArrayView  
   getDataPoint(int sampleNo,  
                int dataPointNo);  
190    
191    /**    /**
192       \brief       \brief
193       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
194    */    */
195      ESCRIPT_DLL_API
196    virtual    virtual
197    ValueType::size_type    ValueType::size_type
198    getLength() const;    getLength() const;
# Line 195  class DataExpanded : public DataAbstract Line 204  class DataExpanded : public DataAbstract
204    
205       \param region - Input - Region to copy.       \param region - Input - Region to copy.
206    */    */
207      ESCRIPT_DLL_API
208    virtual    virtual
209    DataAbstract*    DataAbstract*
210    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
211    
212    /**    /**
213       \brief       \brief
# Line 206  class DataExpanded : public DataAbstract Line 216  class DataExpanded : public DataAbstract
216       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
217       \param region - Input - Region to copy.       \param region - Input - Region to copy.
218    */    */
219      ESCRIPT_DLL_API
220    virtual    virtual
221    void    void
222    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
223             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
224    
225    /**    /**
226       \brief       \brief
227       Assign the given value to all data-points associated with the given       setTaggedValue
228       reference number.  
229         Description:
230         uses tag to set a new value
231    
232       A reference number corresponds to a sample, and thus to all data-points       \param tagKey - Input - Integer key.
233       in that sample.       \param pointshape - Input - The shape of the value parameter
234         \param value - Input - .
235      */
236      void  
237      setTaggedValue(int tagKey,
238                 const DataTypes::ShapeType& pointshape,
239                     const DataTypes::ValueType& value,
240             int dataOffset=0);
241    
      If the given reference number does not correspond to any sample in this  
      Data object, an exception will be thrown.  
242    
      If the given value is a different shape to this Data object, an exception  
      will be thrown.  
243    
244       \param ref - Input - reference number which determines sample numebr to    /**
245                            assign given values to.       \brief
246       \param value - Input - Value to assign to data-point associated with       Computes a symmetric matrix (A + AT) / 2
247                              the given reference number.  
248         \param ev - Output - symmetric matrix
249    
250    */    */
251    virtual    ESCRIPT_DLL_API
252    void    virtual void
253    setRefValue(int ref,    symmetric(DataAbstract* ev);
254                const DataArray& value);  
255      /**
256         \brief
257         Computes a nonsymmetric matrix (A - AT) / 2
258    
259         \param ev - Output - nonsymmetric matrix
260    
261      */
262      ESCRIPT_DLL_API
263      virtual void
264      nonsymmetric(DataAbstract* ev);
265    
266    /**    /**
267       \brief       \brief
268       Return the value of the first data-point in the sample associated with       Computes the trace of a matrix
269       the given reference number.  
270         \param ev - Output - trace of your matrix
271    
272       A reference number corresponds to a sample, and thus to all data-points    */
273       in that sample. If there is more than one data-point per sample number    ESCRIPT_DLL_API
274       in this Data object, the value of the first data-point will be returned.    virtual void
275      trace(DataAbstract* ev, int axis_offset);
276    
277       If the given reference number does not correspond to any sample in this    /**
278       Data object, an exception will be thrown.       \brief
279         Transpose each data point of this Data object around the given axis.
280    
281       If the given value is a different shape to this Data object, an exception       \param ev - Output - transpose of your matrix
      will be thrown.  
282    
      \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.  
283    */    */
284    virtual    ESCRIPT_DLL_API
285    void    virtual void
286    getRefValue(int ref,    transpose(DataAbstract* ev, int axis_offset);
               DataArray& value);  
287    
288    /**    /**
289      \brief       \brief
290      Archive the underlying data values to the file referenced       swaps components axis0 and axis1
291      by ofstream. A count of the number of values expected to be written  
292      is provided as a cross-check.       \param ev - Output - swapped components
293    
     The return value indicates success (0) or otherwise (1).  
294    */    */
295    int    ESCRIPT_DLL_API
296    archiveData(std::ofstream& archiveFile,    virtual void
297                const DataArrayView::ValueType::size_type noValues) const;    swapaxes(DataAbstract* ev, int axis0, int axis1);
298    
299    
300    /**    /**
301      \brief       \brief
302      Extract the number of values specified by noValues from the file       solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
303      referenced by ifstream to the underlying data structure.  
304         \param ev - Output - eigenvalues in increasing order at each data point
305    
     The return value indicates success (0) or otherwise (1).  
306    */    */
307    int    ESCRIPT_DLL_API
308    extractData(std::ifstream& archiveFile,    virtual void
309                const DataArrayView::ValueType::size_type noValues);    eigenvalues(DataAbstract* ev);
310    
311      /**
312         \brief
313         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
314    
315         \param ev - Output - eigenvalues in increasing order at each data point
316         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
317                             and the first nonzero component is positive.
318         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
319    
320      */
321    
322      ESCRIPT_DLL_API
323      virtual void
324      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
325    
326    /**
327     *      \brief
328     *           reorders data sample ordered by reference_ids to the ordering of the functions space
329     *
330     *                \param reference_ids - Input - reference_ids used for current ordering
331     *                  */
332      ESCRIPT_DLL_API
333      virtual void
334      reorderByReferenceIDs(int *reference_ids);
335    
336    
337    
338   protected:   protected:
339    
# Line 298  class DataExpanded : public DataAbstract Line 350  class DataExpanded : public DataAbstract
350       given shape and number of data points, and creates the corresponding       given shape and number of data points, and creates the corresponding
351       DataArrayView of this data.       DataArrayView of this data.
352    
      \param shape - Input - The shape of the point data.  
353       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
354       \param noDataPointsPerSample - Input - number of data points per sample.       \param noDataPointsPerSample - Input - number of data points per sample.
355    */    */
356    void    void
357    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
358               int noDataPointsPerSample);               int noDataPointsPerSample);
359    
360    /**    /**
# Line 317  class DataExpanded : public DataAbstract Line 367  class DataExpanded : public DataAbstract
367       \param value Input - A single data point value.       \param value Input - A single data point value.
368    */    */
369    void    void
370    copy(const DataArrayView& value);    copy(const DataConstant& value);
371    
372    
373    
374    /**    /**
375       \brief       \brief
# Line 343  class DataExpanded : public DataAbstract Line 395  class DataExpanded : public DataAbstract
395    void    void
396    copyAll(const boost::python::numeric::array& value);    copyAll(const boost::python::numeric::array& value);
397    
398      /**
399         \brief
400         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
401    
402         Description:
403         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
404    
405         \param sampleNo Input - sample number
406         \param dataPointNo Input - data point of the sample
407         \param value Input - new values for the data point
408      */
409      ESCRIPT_DLL_API
410      virtual void
411      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
412    
413    
414      /**
415         \brief
416         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
417    
418         Description:
419         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
420    
421         \param sampleNo Input - sample number
422         \param dataPointNo Input - data point of the sample
423         \param value Input - new values for the data point
424      */
425      void
426      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
427    
428    //    //
429    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
430    // noSamples * noDataPointsPerSample    // noSamples * noDataPointsPerSample

Legend:
Removed from v.155  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.26