/[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 1799 by jfenwick, Wed Sep 17 06:33:18 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /* $Id$ */
3   ******************************************************************************  
4   *                                                                            *  /*******************************************************
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *
6   *                                                                            *   *           Copyright 2003-2007 by ACceSS MNRF
7   * This software is the property of ACcESS. No part of this code              *   *       Copyright 2007 by University of Queensland
8   * may be copied in any form or by any means without the expressed written    *   *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *                http://esscc.uq.edu.au
10   * by any unauthorised person is illegal unless that person has a software    *   *        Primary Business: Queensland, Australia
11   * license agreement with ACcESS.                                             *   *  Licensed under the Open Software License version 3.0
12   *                                                                            *   *     http://www.opensource.org/licenses/osl-3.0.php
13   ******************************************************************************   *
14  */   *******************************************************/
15                                                                              
16  #if !defined escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
17  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
18    #include "system_dep.h"
19    
20  #include "DataAbstract.h"  #include "DataAbstract.h"
21  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
 #include "DataArrayView.h"  
22    
 #include <boost/scoped_ptr.hpp>  
23  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
24    
25  namespace escript {  namespace escript {
26    
27  //  //
28  // Forward declarations of other Data types.  // Forward declarations of other Data types.
 class DataEmpty;  
29  class DataConstant;  class DataConstant;
30  class DataTagged;  class DataTagged;
31    
# Line 61  class DataExpanded : public DataAbstract Line 59  class DataExpanded : public DataAbstract
59       \param value - Input - A single data value.       \param value - Input - A single data value.
60       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
61    */    */
62      ESCRIPT_DLL_API
63    DataExpanded(const boost::python::numeric::array& value,    DataExpanded(const boost::python::numeric::array& value,
64                 const FunctionSpace& what);                 const FunctionSpace& what);
65    
66    /**  //  /**
67       \brief  //      \brief
68       Alternative constructor for DataExpanded.  //      Alternative constructor for DataExpanded.
69    //
70       Description:  //      Description:
71       Alternative Constructor for DataExpanded.  //      Alternative Constructor for DataExpanded.
72    //
73       The given single data value is copied to all the data points in  //      The given single data value is copied to all the data points in
74       this data object, where the number of data points is defined by  //      this data object, where the number of data points is defined by
75       the given function space.  //      the given function space.
76    //
77       \param value - Input - A single data value.  //      \param value - Input - A single data value.
78       \param what - Input - A description of what this data represents.  //      \param what - Input - A description of what this data represents.
79    */  //  */
80    DataExpanded(const DataArrayView& value,  //   ESCRIPT_DLL_API
81                 const FunctionSpace& what);  //   DataExpanded(const DataArrayView& value,
82    //                const FunctionSpace& what);
83    
84    /**    /**
85       \brief       \brief
# Line 89  class DataExpanded : public DataAbstract Line 89  class DataExpanded : public DataAbstract
89       \param other - Input - DataExpanded object to slice from.       \param other - Input - DataExpanded object to slice from.
90       \param region - Input - region to copy.       \param region - Input - region to copy.
91    */    */
92      ESCRIPT_DLL_API
93    DataExpanded(const DataExpanded& other,    DataExpanded(const DataExpanded& other,
94                 const DataArrayView::RegionType& region);                 const DataTypes::RegionType& region);
95    
96    /**    /**
97       \brief       \brief
# Line 101  class DataExpanded : public DataAbstract Line 102  class DataExpanded : public DataAbstract
102       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.
103       \param shape - Input - the shape of each data-point.       \param shape - Input - the shape of each data-point.
104       \param data - the array of data values for the data-points.       \param data - the array of data values for the data-points.
105    
106    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.
107    */    */
108      ESCRIPT_DLL_API
109    DataExpanded(const FunctionSpace& what,    DataExpanded(const FunctionSpace& what,
110                 const DataArrayView::ShapeType &shape,                 const DataTypes::ShapeType &shape,
111                 const DataArrayView::ValueType &data);                 const DataTypes::ValueType &data);
112    
113    /**    /**
114       \brief       \brief
115       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
116       Performs a deep copy from another DataExpanded.       Performs a deep copy from another DataExpanded.
117    */    */
118      ESCRIPT_DLL_API
119    DataExpanded(const DataExpanded& other);    DataExpanded(const DataExpanded& other);
120    
121    /**    /**
# Line 118  class DataExpanded : public DataAbstract Line 123  class DataExpanded : public DataAbstract
123       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
124       Construct a DataExpanded from a DataConstant.       Construct a DataExpanded from a DataConstant.
125    */    */
126      ESCRIPT_DLL_API
127    DataExpanded(const DataConstant& other);    DataExpanded(const DataConstant& other);
128    
129    /**    /**
# Line 125  class DataExpanded : public DataAbstract Line 131  class DataExpanded : public DataAbstract
131       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
132       Construct a DataExpanded from a DataTagged.       Construct a DataExpanded from a DataTagged.
133    */    */
134      ESCRIPT_DLL_API
135    DataExpanded(const DataTagged& other);    DataExpanded(const DataTagged& other);
136    
137    /**    /**
138       \brief       \brief
139       Default destructor for DataExpanded.       Default destructor for DataExpanded.
140    */    */
141      ESCRIPT_DLL_API
142    virtual    virtual
143    ~DataExpanded();    ~DataExpanded();
144    
# Line 138  class DataExpanded : public DataAbstract Line 146  class DataExpanded : public DataAbstract
146       \brief       \brief
147       Return a textual representation of the data.       Return a textual representation of the data.
148    */    */
149      ESCRIPT_DLL_API
150    virtual    virtual
151    std::string    std::string
152    toString() const;    toString() const;
153    
154    /**    /**
155         \brief Return a deep copy of the current object.
156      */
157      ESCRIPT_DLL_API
158      virtual
159      DataAbstract*
160      deepCopy();
161    
162    
163     /**
164         \brief
165         dumps the object into a netCDF file
166      */
167      ESCRIPT_DLL_API
168      virtual
169      void
170      dump(const std::string fileName) const;
171    
172     /**
173       \brief       \brief
174       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.  
175    */    */
176      ESCRIPT_DLL_API
177      virtual
178    void    void
179    reshapeDataPoint(const DataArrayView::ShapeType& shape);    setToZero();
180    
181    /**    /**
182       \brief       \brief
# Line 160  class DataExpanded : public DataAbstract Line 187  class DataExpanded : public DataAbstract
187       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
188       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
189    */    */
190      ESCRIPT_DLL_API
191    virtual    virtual
192    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
193    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
194                   int dataPointNo) const;                   int dataPointNo) const;
195    
196    /**  //  /**
197       \brief  /*     \brief
198       Return a view into the data array for the data point specified.       Return a view into the data array for the data point specified.
199    
200       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
# Line 174  class DataExpanded : public DataAbstract Line 202  class DataExpanded : public DataAbstract
202    
203       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
204       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
205       \return DataArrayView for the data point.       \return DataArrayView for the data point.*/
206    //  */
207    //   ESCRIPT_DLL_API
208    //   DataArrayView
209    //   getDataPoint(int sampleNo,
210    //                int dataPointNo);
211    
212    
213      /**
214         \brief
215         Return a a reference to the underlying DataVector.
216    */    */
217    DataArrayView  
218    getDataPoint(int sampleNo,    ESCRIPT_DLL_API
219                 int dataPointNo);    DataTypes::ValueType&
220      getVector();
221    
222      ESCRIPT_DLL_API
223      const DataTypes::ValueType&
224      getVector() const;
225    
226    
227    /**    /**
228       \brief       \brief
229       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
230    */    */
231      ESCRIPT_DLL_API
232    virtual    virtual
233    ValueType::size_type    ValueType::size_type
234    getLength() const;    getLength() const;
# Line 195  class DataExpanded : public DataAbstract Line 240  class DataExpanded : public DataAbstract
240    
241       \param region - Input - Region to copy.       \param region - Input - Region to copy.
242    */    */
243      ESCRIPT_DLL_API
244    virtual    virtual
245    DataAbstract*    DataAbstract*
246    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
247    
248    /**    /**
249       \brief       \brief
# Line 206  class DataExpanded : public DataAbstract Line 252  class DataExpanded : public DataAbstract
252       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
253       \param region - Input - Region to copy.       \param region - Input - Region to copy.
254    */    */
255      ESCRIPT_DLL_API
256    virtual    virtual
257    void    void
258    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
259             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
260    
261    
262    //  /**
263    /*     \brief
264         setTaggedValue
265    
266         Description:
267         uses tag to set a new value
268    
269         \param tagKey - Input - Integer key.
270         \param value - Input - Single DataArrayView value to be assigned to the tag.*/
271    //  */
272    //   ESCRIPT_DLL_API
273    //   virtual
274    //   void
275    //   setTaggedValue(int tagKey,
276    //                  const DataArrayView& value);
277    
278    
279    
280      /**
281         \brief
282         setTaggedValue
283    
284         Description:
285         uses tag to set a new value
286    
287         \param tagKey - Input - Integer key.
288         \param pointshape - Input - The shape of the value parameter
289         \param value - Input - .
290      */
291      void  
292      setTaggedValue(int tagKey,
293                 const DataTypes::ShapeType& pointshape,
294                     const DataTypes::ValueType& value,
295             int dataOffset=0);
296    
297    
298    
299    /**    /**
300       \brief       \brief
301       Assign the given value to all data-points associated with the given       Computes a symmetric matrix (A + AT) / 2
      reference number.  
302    
303       A reference number corresponds to a sample, and thus to all data-points       \param ev - Output - symmetric matrix
      in that sample.  
304    
305       If the given reference number does not correspond to any sample in this    */
306       Data object, an exception will be thrown.    ESCRIPT_DLL_API
307      virtual void
308      symmetric(DataAbstract* ev);
309    
310       If the given value is a different shape to this Data object, an exception    /**
311       will be thrown.       \brief
312         Computes a nonsymmetric matrix (A - AT) / 2
313    
314         \param ev - Output - nonsymmetric matrix
315    
      \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.  
316    */    */
317    virtual    ESCRIPT_DLL_API
318    void    virtual void
319    setRefValue(int ref,    nonsymmetric(DataAbstract* ev);
               const DataArray& value);  
320    
321    /**    /**
322       \brief       \brief
323       Return the value of the first data-point in the sample associated with       Computes the trace of a matrix
      the given reference number.  
324    
325       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.  
326    
327       If the given reference number does not correspond to any sample in this    */
328       Data object, an exception will be thrown.    ESCRIPT_DLL_API
329      virtual void
330      trace(DataAbstract* ev, int axis_offset);
331    
332       If the given value is a different shape to this Data object, an exception    /**
333       will be thrown.       \brief
334         Transpose each data point of this Data object around the given axis.
335    
336         \param ev - Output - transpose of your matrix
337    
      \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.  
338    */    */
339    virtual    ESCRIPT_DLL_API
340    void    virtual void
341    getRefValue(int ref,    transpose(DataAbstract* ev, int axis_offset);
342                DataArray& value);  
343      /**
344         \brief
345         swaps components axis0 and axis1
346    
347         \param ev - Output - swapped components
348    
349      */
350      ESCRIPT_DLL_API
351      virtual void
352      swapaxes(DataAbstract* ev, int axis0, int axis1);
353    
354    
355    /**    /**
356      \brief       \brief
357      Archive the underlying data values to the file referenced       solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
358      by ofstream. A count of the number of values expected to be written  
359      is provided as a cross-check.       \param ev - Output - eigenvalues in increasing order at each data point
360    
     The return value indicates success (0) or otherwise (1).  
361    */    */
362    int    ESCRIPT_DLL_API
363    archiveData(std::ofstream& archiveFile,    virtual void
364                const DataArrayView::ValueType::size_type noValues) const;    eigenvalues(DataAbstract* ev);
365    
366    /**    /**
367      \brief       \brief
368      Extract the number of values specified by noValues from the file       solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
369      referenced by ifstream to the underlying data structure.  
370         \param ev - Output - eigenvalues in increasing order at each data point
371         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
372                             and the first nonzero component is positive.
373         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
374    
     The return value indicates success (0) or otherwise (1).  
375    */    */
376    int  
377    extractData(std::ifstream& archiveFile,    ESCRIPT_DLL_API
378                const DataArrayView::ValueType::size_type noValues);    virtual void
379      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
380    
381    /**
382     *      \brief
383     *           reorders data sample ordered by reference_ids to the ordering of the functions space
384     *
385     *                \param reference_ids - Input - reference_ids used for current ordering
386     *                  */
387      ESCRIPT_DLL_API
388      virtual void
389      reorderByReferenceIDs(int *reference_ids);
390    
391    
392    
393   protected:   protected:
394    
# Line 298  class DataExpanded : public DataAbstract Line 405  class DataExpanded : public DataAbstract
405       given shape and number of data points, and creates the corresponding       given shape and number of data points, and creates the corresponding
406       DataArrayView of this data.       DataArrayView of this data.
407    
      \param shape - Input - The shape of the point data.  
408       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
409       \param noDataPointsPerSample - Input - number of data points per sample.       \param noDataPointsPerSample - Input - number of data points per sample.
410    */    */
411    void    void
412    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
413               int noDataPointsPerSample);               int noDataPointsPerSample);
414    
415    /**    /**
# Line 317  class DataExpanded : public DataAbstract Line 422  class DataExpanded : public DataAbstract
422       \param value Input - A single data point value.       \param value Input - A single data point value.
423    */    */
424    void    void
425    copy(const DataArrayView& value);    copy(const DataConstant& value);
426    
427    
428    
429    /**    /**
430       \brief       \brief
# Line 343  class DataExpanded : public DataAbstract Line 450  class DataExpanded : public DataAbstract
450    void    void
451    copyAll(const boost::python::numeric::array& value);    copyAll(const boost::python::numeric::array& value);
452    
453      /**
454         \brief
455         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
456    
457         Description:
458         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
459    
460         \param sampleNo Input - sample number
461         \param dataPointNo Input - data point of the sample
462         \param value Input - new values for the data point
463      */
464      ESCRIPT_DLL_API
465      virtual void
466      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
467    
468    
469      /**
470         \brief
471         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
472    
473         Description:
474         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
475    
476         \param sampleNo Input - sample number
477         \param dataPointNo Input - data point of the sample
478         \param value Input - new values for the data point
479      */
480      void
481      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
482    
483    //    //
484    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
485    // noSamples * noDataPointsPerSample    // noSamples * noDataPointsPerSample

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

  ViewVC Help
Powered by ViewVC 1.1.26