/[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/esys2/escript/src/Data/DataExpanded.h revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC temp/escript/src/DataExpanded.h revision 1387 by trankine, Fri Jan 11 07:45:26 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"
22  #include "DataArrayView.h"  #include "DataArrayView.h"
23    
 #include <boost/scoped_ptr.hpp>  
24  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
25    
26  namespace escript {  namespace escript {
27    
28  //  //
29  // Forward declarations of other Data types.  // Forward declarations of other Data types.
 class DataEmpty;  
30  class DataConstant;  class DataConstant;
31  class DataTagged;  class DataTagged;
32    
# Line 61  class DataExpanded : public DataAbstract Line 60  class DataExpanded : public DataAbstract
60       \param value - Input - A single data value.       \param value - Input - A single data value.
61       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
62    */    */
63      ESCRIPT_DLL_API
64    DataExpanded(const boost::python::numeric::array& value,    DataExpanded(const boost::python::numeric::array& value,
65                 const FunctionSpace& what);                 const FunctionSpace& what);
66    
# Line 78  class DataExpanded : public DataAbstract Line 78  class DataExpanded : public DataAbstract
78       \param value - Input - A single data value.       \param value - Input - A single data value.
79       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
80    */    */
81      ESCRIPT_DLL_API
82    DataExpanded(const DataArrayView& value,    DataExpanded(const DataArrayView& value,
83                 const FunctionSpace& what);                 const FunctionSpace& what);
84    
# Line 89  class DataExpanded : public DataAbstract Line 90  class DataExpanded : public DataAbstract
90       \param other - Input - DataExpanded object to slice from.       \param other - Input - DataExpanded object to slice from.
91       \param region - Input - region to copy.       \param region - Input - region to copy.
92    */    */
93      ESCRIPT_DLL_API
94    DataExpanded(const DataExpanded& other,    DataExpanded(const DataExpanded& other,
95                 const DataArrayView::RegionType& region);                 const DataArrayView::RegionType& region);
96    
# Line 102  class DataExpanded : public DataAbstract Line 104  class DataExpanded : public DataAbstract
104       \param shape - Input - the shape of each data-point.       \param shape - Input - the shape of each data-point.
105       \param data - the array of data values for the data-points.       \param data - the array of data values for the data-points.
106    */    */
107      ESCRIPT_DLL_API
108    DataExpanded(const FunctionSpace& what,    DataExpanded(const FunctionSpace& what,
109                 const DataArrayView::ShapeType &shape,                 const DataArrayView::ShapeType &shape,
110                 const DataArrayView::ValueType &data);                 const DataArrayView::ValueType &data);
# Line 111  class DataExpanded : public DataAbstract Line 114  class DataExpanded : public DataAbstract
114       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
115       Performs a deep copy from another DataExpanded.       Performs a deep copy from another DataExpanded.
116    */    */
117      ESCRIPT_DLL_API
118    DataExpanded(const DataExpanded& other);    DataExpanded(const DataExpanded& other);
119    
120    /**    /**
# Line 118  class DataExpanded : public DataAbstract Line 122  class DataExpanded : public DataAbstract
122       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
123       Construct a DataExpanded from a DataConstant.       Construct a DataExpanded from a DataConstant.
124    */    */
125      ESCRIPT_DLL_API
126    DataExpanded(const DataConstant& other);    DataExpanded(const DataConstant& other);
127    
128    /**    /**
# Line 125  class DataExpanded : public DataAbstract Line 130  class DataExpanded : public DataAbstract
130       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
131       Construct a DataExpanded from a DataTagged.       Construct a DataExpanded from a DataTagged.
132    */    */
133      ESCRIPT_DLL_API
134    DataExpanded(const DataTagged& other);    DataExpanded(const DataTagged& other);
135    
136    /**    /**
137       \brief       \brief
138       Default destructor for DataExpanded.       Default destructor for DataExpanded.
139    */    */
140      ESCRIPT_DLL_API
141    virtual    virtual
142    ~DataExpanded();    ~DataExpanded();
143    
# Line 138  class DataExpanded : public DataAbstract Line 145  class DataExpanded : public DataAbstract
145       \brief       \brief
146       Return a textual representation of the data.       Return a textual representation of the data.
147    */    */
148      ESCRIPT_DLL_API
149    virtual    virtual
150    std::string    std::string
151    toString() const;    toString() const;
152     /**
153         \brief
154         dumps the object into a netCDF file
155      */
156      ESCRIPT_DLL_API
157      virtual
158      void
159      dump(const std::string fileName) const;
160    
161    /**   /**
162       \brief       \brief
163       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.  
164    */    */
165      ESCRIPT_DLL_API
166      virtual
167    void    void
168    reshapeDataPoint(const DataArrayView::ShapeType& shape);    setToZero();
169    
170    /**    /**
171       \brief       \brief
# Line 160  class DataExpanded : public DataAbstract Line 176  class DataExpanded : public DataAbstract
176       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
177       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
178    */    */
179      ESCRIPT_DLL_API
180    virtual    virtual
181    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
182    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 176  class DataExpanded : public DataAbstract Line 193  class DataExpanded : public DataAbstract
193       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
194       \return DataArrayView for the data point.       \return DataArrayView for the data point.
195    */    */
196      ESCRIPT_DLL_API
197    DataArrayView    DataArrayView
198    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
199                 int dataPointNo);                 int dataPointNo);
# Line 184  class DataExpanded : public DataAbstract Line 202  class DataExpanded : public DataAbstract
202       \brief       \brief
203       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
204    */    */
205      ESCRIPT_DLL_API
206    virtual    virtual
207    ValueType::size_type    ValueType::size_type
208    getLength() const;    getLength() const;
# Line 195  class DataExpanded : public DataAbstract Line 214  class DataExpanded : public DataAbstract
214    
215       \param region - Input - Region to copy.       \param region - Input - Region to copy.
216    */    */
217      ESCRIPT_DLL_API
218    virtual    virtual
219    DataAbstract*    DataAbstract*
220    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 206  class DataExpanded : public DataAbstract Line 226  class DataExpanded : public DataAbstract
226       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
227       \param region - Input - Region to copy.       \param region - Input - Region to copy.
228    */    */
229      ESCRIPT_DLL_API
230    virtual    virtual
231    void    void
232    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
233             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
234    
235    /**    /**
236       \brief      \brief
237       Assign the given value to all data-points associated with the given      Archive the underlying data values to the file referenced
238       reference number.      by ofstream. A count of the number of values expected to be written
239        is provided as a cross-check.
240    
241       A reference number corresponds to a sample, and thus to all data-points      The return value indicates success (0) or otherwise (1).
242       in that sample.    */
243      ESCRIPT_DLL_API
244      int
245      archiveData(std::ofstream& archiveFile,
246                  const DataArrayView::ValueType::size_type noValues) const;
247    
248       If the given reference number does not correspond to any sample in this    /**
249       Data object, an exception will be thrown.      \brief
250        Extract the number of values specified by noValues from the file
251        referenced by ifstream to the underlying data structure.
252    
253       If the given value is a different shape to this Data object, an exception      The return value indicates success (0) or otherwise (1).
      will be thrown.  
   
      \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.  
254    */    */
255      ESCRIPT_DLL_API
256      int
257      extractData(std::ifstream& archiveFile,
258                  const DataArrayView::ValueType::size_type noValues);
259    
260      /**
261         \brief
262         setTaggedValue
263    
264         Description:
265         uses tag to set a new value
266    
267         \param tagKey - Input - Integer key.
268         \param value - Input - Single DataArrayView value to be assigned to the tag.
269      */
270      ESCRIPT_DLL_API
271    virtual    virtual
272    void    void
273    setRefValue(int ref,    setTaggedValue(int tagKey,
274                const DataArray& value);                   const DataArrayView& value);
275    
276    /**    /**
277       \brief       \brief
278       Return the value of the first data-point in the sample associated with       Computes a symmetric matrix (A + AT) / 2
279       the given reference number.  
280         \param ev - Output - symmetric matrix
281    
282       A reference number corresponds to a sample, and thus to all data-points    */
283       in that sample. If there is more than one data-point per sample number    ESCRIPT_DLL_API
284       in this Data object, the value of the first data-point will be returned.    virtual void
285      symmetric(DataAbstract* ev);
286    
287       If the given reference number does not correspond to any sample in this    /**
288       Data object, an exception will be thrown.       \brief
289         Computes a nonsymmetric matrix (A - AT) / 2
290    
291       If the given value is a different shape to this Data object, an exception       \param ev - Output - nonsymmetric matrix
      will be thrown.  
292    
      \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.  
293    */    */
294    virtual    ESCRIPT_DLL_API
295    void    virtual void
296    getRefValue(int ref,    nonsymmetric(DataAbstract* ev);
               DataArray& value);  
297    
298    /**    /**
299      \brief       \brief
300      Archive the underlying data values to the file referenced       Computes the trace of a matrix
301      by ofstream. A count of the number of values expected to be written  
302      is provided as a cross-check.       \param ev - Output - trace of your matrix
303    
     The return value indicates success (0) or otherwise (1).  
304    */    */
305    int    ESCRIPT_DLL_API
306    archiveData(std::ofstream& archiveFile,    virtual void
307                const DataArrayView::ValueType::size_type noValues) const;    trace(DataAbstract* ev, int axis_offset);
308    
309    /**    /**
310      \brief       \brief
311      Extract the number of values specified by noValues from the file       Transpose each data point of this Data object around the given axis.
312      referenced by ifstream to the underlying data structure.  
313         \param ev - Output - transpose of your matrix
314    
     The return value indicates success (0) or otherwise (1).  
315    */    */
316    int    ESCRIPT_DLL_API
317    extractData(std::ifstream& archiveFile,    virtual void
318                const DataArrayView::ValueType::size_type noValues);    transpose(DataAbstract* ev, int axis_offset);
319    
320      /**
321         \brief
322         swaps components axis0 and axis1
323    
324         \param ev - Output - swapped components
325    
326      */
327      ESCRIPT_DLL_API
328      virtual void
329      swapaxes(DataAbstract* ev, int axis0, int axis1);
330    
331    
332      /**
333         \brief
334         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
335    
336         \param ev - Output - eigenvalues in increasing order at each data point
337    
338      */
339      ESCRIPT_DLL_API
340      virtual void
341      eigenvalues(DataAbstract* ev);
342    
343      /**
344         \brief
345         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
346    
347         \param ev - Output - eigenvalues in increasing order at each data point
348         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
349                             and the first nonzero component is positive.
350         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
351    
352      */
353    
354      ESCRIPT_DLL_API
355      virtual void
356      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
357    
358    
359   protected:   protected:
360    
# Line 309  class DataExpanded : public DataAbstract Line 382  class DataExpanded : public DataAbstract
382    
383    /**    /**
384       \brief       \brief
385       Copy the given data point to all data points in this object.       Copy the given data point value to all data points in this object.
386    
387       Description:       Description:
388       Copy the given data point to all data points in this object.       Copy the given data point to all data points in this object.
# Line 319  class DataExpanded : public DataAbstract Line 392  class DataExpanded : public DataAbstract
392    void    void
393    copy(const DataArrayView& value);    copy(const DataArrayView& value);
394    
395      /**
396         \brief
397         Copy the given data point value given a numarray object to all data points in this object.
398    
399         Description:
400         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.
403      */
404    void    void
405    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
406    
407      /**
408         \brief
409         Copy the numarray object to the data points in this object.
410    
411         Description:
412         Copy the numarray object to the data points in this object.
413    
414         \param value Input - new values for the data points
415      */
416      void
417      copyAll(const boost::python::numeric::array& value);
418    
419      /**
420         \brief
421         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
422    
423         Description:
424         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
425    
426         \param sampleNo Input - sample number
427         \param dataPointNo Input - data point of the sample
428         \param value Input - new values for the data point
429      */
430      ESCRIPT_DLL_API
431      virtual void
432      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
433    
434    
435      /**
436         \brief
437         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
438    
439         Description:
440         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
441    
442         \param sampleNo Input - sample number
443         \param dataPointNo Input - data point of the sample
444         \param value Input - new values for the data point
445      */
446      void
447      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
448    
449    //    //
450    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
451    // noSamples * noDataPointsPerSample    // noSamples * noDataPointsPerSample

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

  ViewVC Help
Powered by ViewVC 1.1.26