/[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 110 by jgs, Mon Feb 14 04:14:42 2005 UTC trunk/escript/src/DataExpanded.h revision 757 by woo409, Mon Jun 26 13:12:56 2006 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  class DataEmpty;  //
27    // Forward declarations of other Data types.
28  class DataConstant;  class DataConstant;
29  class DataTagged;  class DataTagged;
30    
# Line 34  class DataTagged; Line 33  class DataTagged;
33     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
34    
35     Description:     Description:
36     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
37    
38     Template Parameters:     Template Parameters:
39     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
40     template must satisfy     template must satisfy.
41  */  */
42    
43  class DataExpanded : public DataAbstract{  class DataExpanded : public DataAbstract {
44    
45   public:   public:
46    
47    /**    /**
48       \brief       \brief
49       Copy constructor for DataExpanded. Performs a deep copy.       Constructor for DataExpanded.
   */  
   DataExpanded(const DataExpanded& other);  
   
   /**  
      \brief  
      Construct a DataExpanded from a DataConstant.  
   */  
   DataExpanded(const DataConstant& other);  
50    
51    /**       Description:
52       \brief       Constructor for DataExpanded.
      Construct a DataExpanded from a DataTagged.  
   */  
   DataExpanded(const DataTagged& other);  
53    
54    /**       The given single data value is copied to all the data points in
55       \brief       this data object, where the number of data points is defined by
56       Constructor for DataExpanded       the given function space.
57    
58       Description:       \param value - Input - A single data value.
      Constructor for DataExpanded  
      \param value - Input - Data value for a single 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
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
67       Alternative constructor for DataExpanded       Alternative constructor for DataExpanded.
68    
69       Description:       Description:
70       Alternative Constructor for DataExpanded.       Alternative Constructor for DataExpanded.
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data represents.  
71    
72         The given single data value is copied to all the data points in
73         this data object, where the number of data points is defined by
74         the given function space.
75    
76         \param value - Input - A single data value.
77         \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 96  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    
95    /**    /**
96       \brief       \brief
97       Destructor       Alternative constructor for DataExpanded objects.
98    
99         Description:
100         Alternative Constructor for DataExpanded objects.
101         \param what - Input - A description of what this data object represents.
102         \param shape - Input - the shape of each data-point.
103         \param data - the array of data values for the data-points.
104    */    */
105      ESCRIPT_DLL_API
106      DataExpanded(const FunctionSpace& what,
107                   const DataArrayView::ShapeType &shape,
108                   const DataArrayView::ValueType &data);
109    
110      /**
111         \brief
112         Copy constructor for DataExpanded.
113         Performs a deep copy from another DataExpanded.
114      */
115      ESCRIPT_DLL_API
116      DataExpanded(const DataExpanded& other);
117    
118      /**
119         \brief
120         Copy constructor for DataExpanded.
121         Construct a DataExpanded from a DataConstant.
122      */
123      ESCRIPT_DLL_API
124      DataExpanded(const DataConstant& other);
125    
126      /**
127         \brief
128         Copy constructor for DataExpanded.
129         Construct a DataExpanded from a DataTagged.
130      */
131      ESCRIPT_DLL_API
132      DataExpanded(const DataTagged& other);
133    
134      /**
135         \brief
136         Default destructor for DataExpanded.
137      */
138      ESCRIPT_DLL_API
139    virtual    virtual
140    ~DataExpanded();    ~DataExpanded();
141    
142    /**    /**
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;
# Line 120  class DataExpanded : public DataAbstract Line 154  class DataExpanded : public DataAbstract
154       The original data point value is used for all values of the new       The original data point value is used for all values of the new
155       data point.       data point.
156    */    */
157      ESCRIPT_DLL_API
158    void    void
159    reshapeDataPoint(const DataArrayView::ShapeType& shape);    reshapeDataPoint(const DataArrayView::ShapeType& shape);
160    
161    /**    /**
162       \brief       \brief
163       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
164       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
165       holding the point data.       holding the point data.
166       \param sampleNo - Input - number of samples.  
167       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
168         \param dataPointNo - Input - data point number.
169    */    */
170      ESCRIPT_DLL_API
171    virtual    virtual
172    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
173    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 138  class DataExpanded : public DataAbstract Line 175  class DataExpanded : public DataAbstract
175    
176    /**    /**
177       \brief       \brief
178       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
179    
180       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
181       operation.       operation.
182       \param sampleNo - Input  
183       \param dataPointNo - Input       \param sampleNo - Input - sample number.
184       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
185         \return DataArrayView for the data point.
186    */    */
187      ESCRIPT_DLL_API
188    DataArrayView    DataArrayView
189    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
190                 int dataPointNo);                 int dataPointNo);
# Line 153  class DataExpanded : public DataAbstract Line 193  class DataExpanded : public DataAbstract
193       \brief       \brief
194       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
195    */    */
196      ESCRIPT_DLL_API
197    virtual    virtual
198    ValueType::size_type    ValueType::size_type
199    getLength() const;    getLength() const;
# Line 161  class DataExpanded : public DataAbstract Line 202  class DataExpanded : public DataAbstract
202       \brief       \brief
203       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
204       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
205    
206       \param region - Input - Region to copy.       \param region - Input - Region to copy.
207    */    */
208      ESCRIPT_DLL_API
209    virtual    virtual
210    DataAbstract*    DataAbstract*
211    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 170  class DataExpanded : public DataAbstract Line 213  class DataExpanded : public DataAbstract
213    /**    /**
214       \brief       \brief
215       Copy the specified region from the given value.       Copy the specified region from the given value.
216       \param value - Input - Data to copy from  
217         \param value - Input - Data object to copy from.
218       \param region - Input - Region to copy.       \param region - Input - Region to copy.
219    */    */
220      ESCRIPT_DLL_API
221    virtual    virtual
222    void    void
223    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
# Line 180  class DataExpanded : public DataAbstract Line 225  class DataExpanded : public DataAbstract
225    
226    /**    /**
227       \brief       \brief
228       Assign the given value to the data-point associated with the given       Assign the given value to all data-points associated with the given
229       reference number.       reference number.
230    
231       A reference number corresponds to a sample, and thus to all data-points       A reference number corresponds to a sample, and thus to all data-points
232       in that sample. If there is more than one data-point per sample number       in that sample.
233       in this Data object, an exception will be thrown. If the given reference  
234       number does not correspond to any sample in this Data object, an exception       If the given reference number does not correspond to any sample in this
235       will be thrown.       Data object, an exception will be thrown.
236    
237       If the given value is a different shape to this Data object, an exception       If the given value is a different shape to this Data object, an exception
238       will be thrown.       will be thrown.
239    
240       \param ref - Input - reference number which determines data-point to assign to.       \param ref - Input - reference number which determines sample numebr to
241                              assign given values to.
242       \param value - Input - Value to assign to data-point associated with       \param value - Input - Value to assign to data-point associated with
243                              the given reference number.                              the given reference number.
244    */    */
245      ESCRIPT_DLL_API
246    virtual    virtual
247    void    void
248    setRefValue(int ref,    setRefValue(int ref,
# Line 203  class DataExpanded : public DataAbstract Line 250  class DataExpanded : public DataAbstract
250    
251    /**    /**
252       \brief       \brief
253       Return the value of the data-point associated with the given       Return the value of the first data-point in the sample associated with
254       reference number.       the given reference number.
255    
256       A reference number corresponds to a sample, and thus to all data-points       A reference number corresponds to a sample, and thus to all data-points
257       in that sample. If there is more than one data-point per sample number       in that sample. If there is more than one data-point per sample number
258       in this Data object, an exception will be thrown. If the given reference       in this Data object, the value of the first data-point will be returned.
259       number does not correspond to any sample in this Data object, an exception  
260       will be thrown.       If the given reference number does not correspond to any sample in this
261         Data object, an exception will be thrown.
262    
263       If the given value is a different shape to this Data object, an exception       If the given value is a different shape to this Data object, an exception
264       will be thrown.       will be thrown.
265    
266       \param ref - Input - reference number which determines data-point to read from.       \param ref - Input - reference number which determines sample number to
267                              read from.
268       \param value - Output - Object to receive data-points associated with       \param value - Output - Object to receive data-points associated with
269                              the given reference number.                              the given reference number.
270    */    */
271      ESCRIPT_DLL_API
272    virtual    virtual
273    void    void
274    getRefValue(int ref,    getRefValue(int ref,
275                DataArray& value);                DataArray& value);
276    
277      /**
278        \brief
279        Archive the underlying data values to the file referenced
280        by ofstream. A count of the number of values expected to be written
281        is provided as a cross-check.
282    
283        The return value indicates success (0) or otherwise (1).
284      */
285      ESCRIPT_DLL_API
286      int
287      archiveData(std::ofstream& archiveFile,
288                  const DataArrayView::ValueType::size_type noValues) const;
289    
290      /**
291        \brief
292        Extract the number of values specified by noValues from the file
293        referenced by ifstream to the underlying data structure.
294    
295        The return value indicates success (0) or otherwise (1).
296      */
297      ESCRIPT_DLL_API
298      int
299      extractData(std::ifstream& archiveFile,
300                  const DataArrayView::ValueType::size_type noValues);
301    
302      /**
303         \brief
304         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
305    
306         \param ev - Output - eigenvalues in increasing order at each data point
307    
308      */
309      ESCRIPT_DLL_API
310      virtual void
311      eigenvalues(DataAbstract* ev);
312    
313      /**
314         \brief
315         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
316    
317         \param ev - Output - eigenvalues in increasing order at each data point
318         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
319                             and the first nonzero component is positive.
320         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
321    
322      */
323    
324      ESCRIPT_DLL_API
325      virtual void
326      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
327    
328    
329   protected:   protected:
330    
331   private:   private:
332    
333    /**    /**
334       \brief       \brief
335       Common initialisation called from constructors       Common initialisation called from constructors.
336    
337       Description:       Description:
338       Common initialisation called from constructors       Common initialisation called from constructors.
339    
340         Resizes the underlying data array to provide sufficient storage for the
341         given shape and number of data points, and creates the corresponding
342         DataArrayView of this data.
343    
344       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
345       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
346       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
347    */    */
348    void    void
349    initialise(const DataArrayView::ShapeType& shape,    initialise(const DataArrayView::ShapeType& shape,
# Line 245  class DataExpanded : public DataAbstract Line 352  class DataExpanded : public DataAbstract
352    
353    /**    /**
354       \brief       \brief
355       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
356    
357       Description:       Description:
358       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
359       \param value Input - Value for a single data point.  
360         \param value Input - A single data point value.
361    */    */
362    void    void
363    copy(const DataArrayView& value);    copy(const DataArrayView& value);
364    
365      /**
366         \brief
367         Copy the given data point value given a numarray object to all data points in this object.
368    
369         Description:
370         Copy the given data point value given a numarray object to all data points in this object.
371    
372         \param value Input - A single data point value.
373      */
374    void    void
375    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
376    
377      /**
378         \brief
379         Copy the numarray object to the data points in this object.
380    
381         Description:
382         Copy the numarray object to the data points in this object.
383    
384         \param value Input - new values for the data points
385      */
386      void
387      copyAll(const boost::python::numeric::array& value);
388    
389    //    //
390    // The main data storage, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
391      // noSamples * noDataPointsPerSample
392    DataBlocks2D m_data;    DataBlocks2D m_data;
393    
394  };  };

Legend:
Removed from v.110  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC 1.1.26