/[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 1487 by gross, Thu Apr 10 05:28:01 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  class DataEmpty;  //
29    // Forward declarations of other Data types.
30  class DataConstant;  class DataConstant;
31  class DataTagged;  class DataTagged;
32    
# Line 34  class DataTagged; Line 35  class DataTagged;
35     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
36    
37     Description:     Description:
38     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
39    
40     Template Parameters:     Template Parameters:
41     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
42     template must satisfy     template must satisfy.
43  */  */
44    
45  class DataExpanded : public DataAbstract{  class DataExpanded : public DataAbstract {
46    
47   public:   public:
48    
49    /**    /**
50       \brief       \brief
51       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);  
52    
53    /**       Description:
54       \brief       Constructor for DataExpanded.
      Construct a DataExpanded from a DataTagged.  
   */  
   DataExpanded(const DataTagged& other);  
55    
56    /**       The given single data value is copied to all the data points in
57       \brief       this data object, where the number of data points is defined by
58       Constructor for DataExpanded       the given function space.
59    
60       Description:       \param value - Input - A single data value.
      Constructor for DataExpanded  
      \param value - Input - Data value for a single point.  
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    
67    /**    /**
68       \brief       \brief
69       Alternative constructor for DataExpanded       Alternative constructor for DataExpanded.
70    
71       Description:       Description:
72       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.  
73    
74         The given single data value is copied to all the data points in
75         this data object, where the number of data points is defined by
76         the given function space.
77    
78         \param value - Input - A single data value.
79         \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 96  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    
97    /**    /**
98       \brief       \brief
99       Destructor       Alternative constructor for DataExpanded objects.
100    
101         Description:
102         Alternative Constructor for DataExpanded objects.
103         \param what - Input - A description of what this data object represents.
104         \param shape - Input - the shape of each data-point.
105         \param data - the array of data values for the data-points.
106      */
107      ESCRIPT_DLL_API
108      DataExpanded(const FunctionSpace& what,
109                   const DataArrayView::ShapeType &shape,
110                   const DataArrayView::ValueType &data);
111    
112      /**
113         \brief
114         Copy constructor for DataExpanded.
115         Performs a deep copy from another DataExpanded.
116      */
117      ESCRIPT_DLL_API
118      DataExpanded(const DataExpanded& other);
119    
120      /**
121         \brief
122         Copy constructor for DataExpanded.
123         Construct a DataExpanded from a DataConstant.
124      */
125      ESCRIPT_DLL_API
126      DataExpanded(const DataConstant& other);
127    
128      /**
129         \brief
130         Copy constructor for DataExpanded.
131         Construct a DataExpanded from a DataTagged.
132      */
133      ESCRIPT_DLL_API
134      DataExpanded(const DataTagged& other);
135    
136      /**
137         \brief
138         Default destructor for DataExpanded.
139    */    */
140      ESCRIPT_DLL_API
141    virtual    virtual
142    ~DataExpanded();    ~DataExpanded();
143    
144    /**    /**
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
172       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
173       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
174       holding the point data.       holding the point data.
175       \param sampleNo - Input - number of samples.  
176       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
177         \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 138  class DataExpanded : public DataAbstract Line 184  class DataExpanded : public DataAbstract
184    
185    /**    /**
186       \brief       \brief
187       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
188    
189       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
190       operation.       operation.
191       \param sampleNo - Input  
192       \param dataPointNo - Input       \param sampleNo - Input - sample number.
193       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
194         \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 153  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 161  class DataExpanded : public DataAbstract Line 211  class DataExpanded : public DataAbstract
211       \brief       \brief
212       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
213       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
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 170  class DataExpanded : public DataAbstract Line 222  class DataExpanded : public DataAbstract
222    /**    /**
223       \brief       \brief
224       Copy the specified region from the given value.       Copy the specified region from the given value.
225       \param value - Input - Data to copy from  
226         \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
237        Archive the underlying data values to the file referenced
238        by ofstream. A count of the number of values expected to be written
239        is provided as a cross-check.
240    
241        The return value indicates success (0) or otherwise (1).
242      */
243      ESCRIPT_DLL_API
244      int
245      archiveData(std::ofstream& archiveFile,
246                  const DataArrayView::ValueType::size_type noValues) const;
247    
248      /**
249        \brief
250        Extract the number of values specified by noValues from the file
251        referenced by ifstream to the underlying data structure.
252    
253        The return value indicates success (0) or otherwise (1).
254      */
255      ESCRIPT_DLL_API
256      int
257      extractData(std::ifstream& archiveFile,
258                  const DataArrayView::ValueType::size_type noValues);
259    
260      /**
261       \brief       \brief
262       Assign the given value to the data-point associated with the given       setTaggedValue
263       reference number.  
264         Description:
265         uses tag to set a new value
266    
267       A reference number corresponds to a sample, and thus to all data-points       \param tagKey - Input - Integer key.
268       in that sample. If there is more than one data-point per sample number       \param value - Input - Single DataArrayView value to be assigned to the tag.
      in this Data object, an exception will be thrown. If the given reference  
      number does not correspond to any sample in this Data object, an exception  
      will be thrown.  
   
      If the given value is a different shape to this Data object, an exception  
      will be thrown.  
   
      \param ref - Input - reference number which determines data-point to assign to.  
      \param value - Input - Value to assign to data-point associated with  
                             the given reference number.  
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
278         Computes a symmetric matrix (A + AT) / 2
279    
280         \param ev - Output - symmetric matrix
281    
282      */
283      ESCRIPT_DLL_API
284      virtual void
285      symmetric(DataAbstract* ev);
286    
287    /**    /**
288       \brief       \brief
289       Return the value of the data-point associated with the given       Computes a nonsymmetric matrix (A - AT) / 2
      reference number.  
290    
291       A reference number corresponds to a sample, and thus to all data-points       \param ev - Output - nonsymmetric matrix
      in that sample. If there is more than one data-point per sample number  
      in this Data object, an exception will be thrown. If the given reference  
      number does not correspond to any sample in this Data object, an exception  
      will be thrown.  
292    
293       If the given value is a different shape to this Data object, an exception    */
294       will be thrown.    ESCRIPT_DLL_API
295      virtual void
296      nonsymmetric(DataAbstract* ev);
297    
298      /**
299         \brief
300         Computes the trace of a matrix
301    
302         \param ev - Output - trace of your matrix
303    
      \param ref - Input - reference number which determines data-point to read from.  
      \param value - Output - Object to receive data-points associated with  
                             the given reference number.  
304    */    */
305    virtual    ESCRIPT_DLL_API
306    void    virtual void
307    getRefValue(int ref,    trace(DataAbstract* ev, int axis_offset);
308                DataArray& value);  
309      /**
310         \brief
311         Transpose each data point of this Data object around the given axis.
312    
313         \param ev - Output - transpose of your matrix
314    
315      */
316      ESCRIPT_DLL_API
317      virtual void
318      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     *      \brief
360     *           reorders data sample ordered by reference_ids to the ordering of the functions space
361     *
362     *                \param reference_ids - Input - reference_ids used for current ordering
363     *                  */
364      ESCRIPT_DLL_API
365      virtual void
366      reorderByReferenceIDs(int *reference_ids);
367    
368    
369    
370   protected:   protected:
371    
# Line 230  class DataExpanded : public DataAbstract Line 373  class DataExpanded : public DataAbstract
373    
374    /**    /**
375       \brief       \brief
376       Common initialisation called from constructors       Common initialisation called from constructors.
377    
378       Description:       Description:
379       Common initialisation called from constructors       Common initialisation called from constructors.
380    
381         Resizes the underlying data array to provide sufficient storage for the
382         given shape and number of data points, and creates the corresponding
383         DataArrayView of this data.
384    
385       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
386       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
387       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
388    */    */
389    void    void
390    initialise(const DataArrayView::ShapeType& shape,    initialise(const DataArrayView::ShapeType& shape,
# Line 245  class DataExpanded : public DataAbstract Line 393  class DataExpanded : public DataAbstract
393    
394    /**    /**
395       \brief       \brief
396       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
397    
398       Description:       Description:
399       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
400       \param value Input - Value for a single data point.  
401         \param value Input - A single data point value.
402    */    */
403    void    void
404    copy(const DataArrayView& value);    copy(const DataArrayView& value);
405    
406      /**
407         \brief
408         Copy the given data point value given a numarray object to all data points in this object.
409    
410         Description:
411         Copy the given data point value given a numarray object to all data points in this object.
412    
413         \param value Input - A single data point value.
414      */
415    void    void
416    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
417    
418      /**
419         \brief
420         Copy the numarray object to the data points in this object.
421    
422         Description:
423         Copy the numarray object to the data points in this object.
424    
425         \param value Input - new values for the data points
426      */
427      void
428      copyAll(const boost::python::numeric::array& value);
429    
430      /**
431         \brief
432         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
433    
434         Description:
435         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
436    
437         \param sampleNo Input - sample number
438         \param dataPointNo Input - data point of the sample
439         \param value Input - new values for the data point
440      */
441      ESCRIPT_DLL_API
442      virtual void
443      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
444    
445    
446      /**
447         \brief
448         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
449    
450         Description:
451         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
452    
453         \param sampleNo Input - sample number
454         \param dataPointNo Input - data point of the sample
455         \param value Input - new values for the data point
456      */
457      void
458      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
459    
460    //    //
461    // The main data storage, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
462      // noSamples * noDataPointsPerSample
463    DataBlocks2D m_data;    DataBlocks2D m_data;
464    
465  };  };

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

  ViewVC Help
Powered by ViewVC 1.1.26