/[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 119 by jgs, Tue Apr 12 04:45:05 2005 UTC trunk/escript/src/DataExpanded.h revision 964 by gross, Tue Feb 13 05:10:26 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13                                                                              
14  #if !defined escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
15  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
16    #include "system_dep.h"
17    
18  #include "DataAbstract.h"  #include "DataAbstract.h"
19  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
20  #include "DataArrayView.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    
# Line 78  class DataExpanded : public DataAbstract Line 76  class DataExpanded : public DataAbstract
76       \param value - Input - A single data value.       \param value - Input - A single data value.
77       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
78    */    */
79      ESCRIPT_DLL_API
80    DataExpanded(const DataArrayView& value,    DataExpanded(const DataArrayView& value,
81                 const FunctionSpace& what);                 const FunctionSpace& what);
82    
# Line 89  class DataExpanded : public DataAbstract Line 88  class DataExpanded : public DataAbstract
88       \param other - Input - DataExpanded object to slice from.       \param other - Input - DataExpanded object to slice from.
89       \param region - Input - region to copy.       \param region - Input - region to copy.
90    */    */
91      ESCRIPT_DLL_API
92    DataExpanded(const DataExpanded& other,    DataExpanded(const DataExpanded& other,
93                 const DataArrayView::RegionType& region);                 const DataArrayView::RegionType& region);
94    
# Line 100  class DataExpanded : public DataAbstract Line 100  class DataExpanded : public DataAbstract
100       Alternative Constructor for DataExpanded objects.       Alternative Constructor for DataExpanded objects.
101       \param what - Input - A description of what this data object represents.       \param what - Input - A description of what this data object represents.
102       \param shape - Input - the shape of each data-point.       \param shape - Input - the shape of each data-point.
103       \param data - the data values for each data-point.       \param data - the array of data values for the data-points.
104    */    */
105      ESCRIPT_DLL_API
106    DataExpanded(const FunctionSpace& what,    DataExpanded(const FunctionSpace& what,
107                 const DataArrayView::ShapeType &shape,                 const DataArrayView::ShapeType &shape,
108                 const DataArrayView::ValueType &data);                 const DataArrayView::ValueType &data);
# Line 111  class DataExpanded : public DataAbstract Line 112  class DataExpanded : public DataAbstract
112       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
113       Performs a deep copy from another DataExpanded.       Performs a deep copy from another DataExpanded.
114    */    */
115      ESCRIPT_DLL_API
116    DataExpanded(const DataExpanded& other);    DataExpanded(const DataExpanded& other);
117    
118    /**    /**
# Line 118  class DataExpanded : public DataAbstract Line 120  class DataExpanded : public DataAbstract
120       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
121       Construct a DataExpanded from a DataConstant.       Construct a DataExpanded from a DataConstant.
122    */    */
123      ESCRIPT_DLL_API
124    DataExpanded(const DataConstant& other);    DataExpanded(const DataConstant& other);
125    
126    /**    /**
# Line 125  class DataExpanded : public DataAbstract Line 128  class DataExpanded : public DataAbstract
128       Copy constructor for DataExpanded.       Copy constructor for DataExpanded.
129       Construct a DataExpanded from a DataTagged.       Construct a DataExpanded from a DataTagged.
130    */    */
131      ESCRIPT_DLL_API
132    DataExpanded(const DataTagged& other);    DataExpanded(const DataTagged& other);
133    
134    /**    /**
135       \brief       \brief
136       Default destructor for DataExpanded.       Default destructor for DataExpanded.
137    */    */
138      ESCRIPT_DLL_API
139    virtual    virtual
140    ~DataExpanded();    ~DataExpanded();
141    
# Line 138  class DataExpanded : public DataAbstract Line 143  class DataExpanded : public DataAbstract
143       \brief       \brief
144       Return a textual representation of the data.       Return a textual representation of the data.
145    */    */
146      ESCRIPT_DLL_API
147    virtual    virtual
148    std::string    std::string
149    toString() const;    toString() const;
150     /**
   /**  
151       \brief       \brief
152       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.  
153    */    */
154      ESCRIPT_DLL_API
155      virtual
156    void    void
157    reshapeDataPoint(const DataArrayView::ShapeType& shape);    dump(const std::string fileName) const;
158    
159    /**    /**
160       \brief       \brief
# Line 160  class DataExpanded : public DataAbstract Line 165  class DataExpanded : public DataAbstract
165       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
166       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
167    */    */
168      ESCRIPT_DLL_API
169    virtual    virtual
170    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
171    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 176  class DataExpanded : public DataAbstract Line 182  class DataExpanded : public DataAbstract
182       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
183       \return DataArrayView for the data point.       \return DataArrayView for the data point.
184    */    */
185      ESCRIPT_DLL_API
186    DataArrayView    DataArrayView
187    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
188                 int dataPointNo);                 int dataPointNo);
# Line 184  class DataExpanded : public DataAbstract Line 191  class DataExpanded : public DataAbstract
191       \brief       \brief
192       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
193    */    */
194      ESCRIPT_DLL_API
195    virtual    virtual
196    ValueType::size_type    ValueType::size_type
197    getLength() const;    getLength() const;
# Line 195  class DataExpanded : public DataAbstract Line 203  class DataExpanded : public DataAbstract
203    
204       \param region - Input - Region to copy.       \param region - Input - Region to copy.
205    */    */
206      ESCRIPT_DLL_API
207    virtual    virtual
208    DataAbstract*    DataAbstract*
209    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 206  class DataExpanded : public DataAbstract Line 215  class DataExpanded : public DataAbstract
215       \param value - Input - Data object to copy from.       \param value - Input - Data object to copy from.
216       \param region - Input - Region to copy.       \param region - Input - Region to copy.
217    */    */
218      ESCRIPT_DLL_API
219    virtual    virtual
220    void    void
221    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
222             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
223    
224    /**    /**
225        \brief
226        Archive the underlying data values to the file referenced
227        by ofstream. A count of the number of values expected to be written
228        is provided as a cross-check.
229    
230        The return value indicates success (0) or otherwise (1).
231      */
232      ESCRIPT_DLL_API
233      int
234      archiveData(std::ofstream& archiveFile,
235                  const DataArrayView::ValueType::size_type noValues) const;
236    
237      /**
238        \brief
239        Extract the number of values specified by noValues from the file
240        referenced by ifstream to the underlying data structure.
241    
242        The return value indicates success (0) or otherwise (1).
243      */
244      ESCRIPT_DLL_API
245      int
246      extractData(std::ifstream& archiveFile,
247                  const DataArrayView::ValueType::size_type noValues);
248    
249      /**
250       \brief       \brief
251       Assign the given value to all data-points associated with the given       Computes a symmetric matrix (A + AT) / 2
252       reference number.  
253         \param ev - Output - symmetric matrix
254    
255      */
256      ESCRIPT_DLL_API
257      virtual void
258      symmetric(DataAbstract* ev);
259    
260       A reference number corresponds to a sample, and thus to all data-points    /**
261       in that sample.       \brief
262         Computes a nonsymmetric matrix (A - AT) / 2
263    
264       If the given reference number does not correspond to any sample in this       \param ev - Output - nonsymmetric matrix
      Data object, an exception will be thrown.  
265    
      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 numebr to  
                           assign given values to.  
      \param value - Input - Value to assign to data-point associated with  
                             the given reference number.  
266    */    */
267    virtual    ESCRIPT_DLL_API
268    void    virtual void
269    setRefValue(int ref,    nonsymmetric(DataAbstract* ev);
               const DataArray& value);  
270    
271    /**    /**
272       \brief       \brief
273       Return the value of the first data-point in the sample associated with       Computes the trace of a matrix
      the given reference number.  
274    
275       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.  
276    
277       If the given reference number does not correspond to any sample in this    */
278       Data object, an exception will be thrown.    ESCRIPT_DLL_API
279      virtual void
280      trace(DataAbstract* ev, int axis_offset);
281    
282       If the given value is a different shape to this Data object, an exception    /**
283       will be thrown.       \brief
284         Transpose each data point of this Data object around the given axis.
285    
286         \param ev - Output - transpose of your matrix
287    
288      */
289      ESCRIPT_DLL_API
290      virtual void
291      transpose(DataAbstract* ev, int axis_offset);
292    
293      /**
294         \brief
295         swaps components axis0 and axis1
296    
297         \param ev - Output - swapped components
298    
299      */
300      ESCRIPT_DLL_API
301      virtual void
302      swapaxes(DataAbstract* ev, int axis0, int axis1);
303    
304    
305      /**
306         \brief
307         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
308    
309         \param ev - Output - eigenvalues in increasing order at each data point
310    
311      */
312      ESCRIPT_DLL_API
313      virtual void
314      eigenvalues(DataAbstract* ev);
315    
316      /**
317         \brief
318         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
319    
320         \param ev - Output - eigenvalues in increasing order at each data point
321         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
322                             and the first nonzero component is positive.
323         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
324    
      \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.  
325    */    */
326    virtual  
327    void    ESCRIPT_DLL_API
328    getRefValue(int ref,    virtual void
329                DataArray& value);    eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
330    
331    
332   protected:   protected:
333    
# Line 286  class DataExpanded : public DataAbstract Line 355  class DataExpanded : public DataAbstract
355    
356    /**    /**
357       \brief       \brief
358       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.
359    
360       Description:       Description:
361       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 296  class DataExpanded : public DataAbstract Line 365  class DataExpanded : public DataAbstract
365    void    void
366    copy(const DataArrayView& value);    copy(const DataArrayView& value);
367    
368      /**
369         \brief
370         Copy the given data point value given a numarray object to all data points in this object.
371    
372         Description:
373         Copy the given data point value given a numarray object to all data points in this object.
374    
375         \param value Input - A single data point value.
376      */
377    void    void
378    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
379    
380      /**
381         \brief
382         Copy the numarray object to the data points in this object.
383    
384         Description:
385         Copy the numarray object to the data points in this object.
386    
387         \param value Input - new values for the data points
388      */
389      void
390      copyAll(const boost::python::numeric::array& value);
391    
392      /**
393         \brief
394         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
395    
396         Description:
397         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
398    
399         \param sampleNo Input - sample number
400         \param dataPointNo Input - data point of the sample
401         \param value Input - new values for the data point
402      */
403      ESCRIPT_DLL_API
404      virtual void
405      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
406    
407    
408      /**
409         \brief
410         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
411    
412         Description:
413         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
414    
415         \param sampleNo Input - sample number
416         \param dataPointNo Input - data point of the sample
417         \param value Input - new values for the data point
418      */
419      void
420      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
421    
422    //    //
423    // The main data storage array, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
424    // noSamples * noDataPointsPerSample    // noSamples * noDataPointsPerSample

Legend:
Removed from v.119  
changed lines
  Added in v.964

  ViewVC Help
Powered by ViewVC 1.1.26