/[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 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/escript/src/DataExpanded.h revision 1796 by jfenwick, Wed Sep 17 01:45:46 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  class DataEmpty;  //
28    // Forward declarations of other Data types.
29  class DataConstant;  class DataConstant;
30  class DataTagged;  class DataTagged;
31    
# Line 34  class DataTagged; Line 34  class DataTagged;
34     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
35    
36     Description:     Description:
37     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
38    
39     Template Parameters:     Template Parameters:
40     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
41     template must satisfy     template must satisfy.
42  */  */
43    
44  class DataExpanded : public DataAbstract{  class DataExpanded : public DataAbstract {
45    
46   public:   public:
47    
48    /**    /**
49       \brief       \brief
50       Copy constructor for DataExpanded. Performs a deep copy.       Constructor for DataExpanded.
   */  
   DataExpanded(const DataExpanded& other);  
51    
52    /**       Description:
53       \brief       Constructor for DataExpanded.
54       Construct a DataExpanded from a DataConstant.  
55         The given single data value is copied to all the data points in
56         this data object, where the number of data points is defined by
57         the given function space.
58    
59         \param value - Input - A single data value.
60         \param what - Input - A description of what this data represents.
61    */    */
62    DataExpanded(const DataConstant& other);    ESCRIPT_DLL_API
63      DataExpanded(const boost::python::numeric::array& value,
64                   const FunctionSpace& what);
65    
66    //  /**
67    //      \brief
68    //      Alternative constructor for DataExpanded.
69    //
70    //      Description:
71    //      Alternative Constructor for DataExpanded.
72    //
73    //      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
75    //      the given function space.
76    //
77    //      \param value - Input - A single data value.
78    //      \param what - Input - A description of what this data represents.
79    //  */
80    //   ESCRIPT_DLL_API
81    //   DataExpanded(const DataArrayView& value,
82    //                const FunctionSpace& what);
83    
84    /**    /**
85       \brief       \brief
86       Construct a DataExpanded from a DataTagged.       Alternative constructor for DataExpanded that copies a slice from
87         another DataExpanded.
88    
89         \param other - Input - DataExpanded object to slice from.
90         \param region - Input - region to copy.
91    */    */
92    DataExpanded(const DataTagged& other);    ESCRIPT_DLL_API
93      DataExpanded(const DataExpanded& other,
94                   const DataTypes::RegionType& region);
95    
96    /**    /**
97       \brief       \brief
98       Constructor for DataExpanded       Alternative constructor for DataExpanded objects.
99    
100       Description:       Description:
101       Constructor for DataExpanded       Alternative Constructor for DataExpanded objects.
102       \param value - Input - Data value for a single point.       \param what - Input - A description of what this data object represents.
103       \param what - Input - A description of what this data represents.       \param shape - Input - the shape of each data-point.
104         \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    DataExpanded(const boost::python::numeric::array& value,    ESCRIPT_DLL_API
109                 const FunctionSpace& what);    DataExpanded(const FunctionSpace& what,
110                   const DataTypes::ShapeType &shape,
111                   const DataTypes::ValueType &data);
112    
113    /**    /**
114       \brief       \brief
115       Alternative constructor for DataExpanded       Copy constructor for DataExpanded.
116         Performs a deep copy from another DataExpanded.
      Description:  
      Alternative Constructor for DataExpanded.  
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data represents.  
   
117    */    */
118    DataExpanded(const DataArrayView& value,    ESCRIPT_DLL_API
119                 const FunctionSpace& what);    DataExpanded(const DataExpanded& other);
120    
121    /**    /**
122       \brief       \brief
123       Alternative constructor for DataExpanded that copies a slice from       Copy constructor for DataExpanded.
124       another DataExpanded.       Construct a DataExpanded from a DataConstant.
125      */
126      ESCRIPT_DLL_API
127      DataExpanded(const DataConstant& other);
128    
129       \param other - Input - DataExpanded object to slice from.    /**
130       \param region - Input - region to copy.       \brief
131         Copy constructor for DataExpanded.
132         Construct a DataExpanded from a DataTagged.
133    */    */
134    DataExpanded(const DataExpanded& other,    ESCRIPT_DLL_API
135                 const DataArrayView::RegionType& region);    DataExpanded(const DataTagged& other);
136    
137    /**    /**
138       \brief       \brief
139       Destructor       Default destructor for DataExpanded.
140    */    */
141      ESCRIPT_DLL_API
142    virtual    virtual
143    ~DataExpanded();    ~DataExpanded();
144    
145    /**    /**
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         \brief
155         dumps the object into a netCDF file
156      */
157      ESCRIPT_DLL_API
158      virtual
159      void
160      dump(const std::string fileName) const;
161    
162    /**   /**
163       \brief       \brief
164       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.  
165    */    */
166      ESCRIPT_DLL_API
167      virtual
168    void    void
169    reshapeDataPoint(const DataArrayView::ShapeType& shape);    setToZero();
170    
171    /**    /**
172       \brief       \brief
173       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
174       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
175       holding the point data.       holding the point data.
176       \param sampleNo - Input - number of samples.  
177       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
178         \param dataPointNo - Input - data point number.
179    */    */
180      ESCRIPT_DLL_API
181    virtual    virtual
182    DataArrayView::ValueType::size_type    DataTypes::ValueType::size_type
183    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
184                   int dataPointNo) const;                   int dataPointNo) const;
185    
186    /**  //  /**
187       \brief  /*     \brief
188       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
189    
190       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
191       operation.       operation.
192       \param sampleNo - Input  
193       \param dataPointNo - Input       \param sampleNo - Input - sample number.
194       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
195    */       \return DataArrayView for the data point.*/
196    DataArrayView  //  */
197    getDataPoint(int sampleNo,  //   ESCRIPT_DLL_API
198                 int dataPointNo);  //   DataArrayView
199    //   getDataPoint(int sampleNo,
200    //                int dataPointNo);
201    
202    
203      /**
204         \brief
205         Return a a reference to the underlying DataVector.
206      */
207    
208      ESCRIPT_DLL_API
209      DataTypes::ValueType&
210      getVector();
211    
212      ESCRIPT_DLL_API
213      const DataTypes::ValueType&
214      getVector() const;
215    
216    
217    /**    /**
218       \brief       \brief
219       Return the number of doubles stored for the Data.       Return the number of doubles stored for the Data.
220    */    */
221      ESCRIPT_DLL_API
222    virtual    virtual
223    ValueType::size_type    ValueType::size_type
224    getLength() const;    getLength() const;
# Line 161  class DataExpanded : public DataAbstract Line 227  class DataExpanded : public DataAbstract
227       \brief       \brief
228       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
229       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
230    
231       \param region - Input - Region to copy.       \param region - Input - Region to copy.
232    */    */
233      ESCRIPT_DLL_API
234    virtual    virtual
235    DataAbstract*    DataAbstract*
236    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataTypes::RegionType& region) const;
237    
238    /**    /**
239       \brief       \brief
240       Copy the specified region from the given value.       Copy the specified region from the given value.
241       \param value - Input - Data to copy from  
242         \param value - Input - Data object to copy from.
243       \param region - Input - Region to copy.       \param region - Input - Region to copy.
244    */    */
245      ESCRIPT_DLL_API
246    virtual    virtual
247    void    void
248    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
249             const DataArrayView::RegionType& region);             const DataTypes::RegionType& region);
250    
251    
252    //  /**
253    /*     \brief
254         setTaggedValue
255    
256         Description:
257         uses tag to set a new value
258    
259         \param tagKey - Input - Integer key.
260         \param value - Input - Single DataArrayView value to be assigned to the tag.*/
261    //  */
262    //   ESCRIPT_DLL_API
263    //   virtual
264    //   void
265    //   setTaggedValue(int tagKey,
266    //                  const DataArrayView& value);
267    
268    
269    
270      /**
271         \brief
272         setTaggedValue
273    
274         Description:
275         uses tag to set a new value
276    
277         \param tagKey - Input - Integer key.
278         \param pointshape - Input - The shape of the value parameter
279         \param value - Input - .
280      */
281      void  
282      setTaggedValue(int tagKey,
283                 const DataTypes::ShapeType& pointshape,
284                     const DataTypes::ValueType& value,
285             int dataOffset=0);
286    
287    
288    
289      /**
290         \brief
291         Computes a symmetric matrix (A + AT) / 2
292    
293         \param ev - Output - symmetric matrix
294    
295      */
296      ESCRIPT_DLL_API
297      virtual void
298      symmetric(DataAbstract* ev);
299    
300      /**
301         \brief
302         Computes a nonsymmetric matrix (A - AT) / 2
303    
304         \param ev - Output - nonsymmetric matrix
305    
306      */
307      ESCRIPT_DLL_API
308      virtual void
309      nonsymmetric(DataAbstract* ev);
310    
311      /**
312         \brief
313         Computes the trace of a matrix
314    
315         \param ev - Output - trace of your matrix
316    
317      */
318      ESCRIPT_DLL_API
319      virtual void
320      trace(DataAbstract* ev, int axis_offset);
321    
322      /**
323         \brief
324         Transpose each data point of this Data object around the given axis.
325    
326         \param ev - Output - transpose of your matrix
327    
328      */
329      ESCRIPT_DLL_API
330      virtual void
331      transpose(DataAbstract* ev, int axis_offset);
332    
333      /**
334         \brief
335         swaps components axis0 and axis1
336    
337         \param ev - Output - swapped components
338    
339      */
340      ESCRIPT_DLL_API
341      virtual void
342      swapaxes(DataAbstract* ev, int axis0, int axis1);
343    
344    
345      /**
346         \brief
347         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
348    
349         \param ev - Output - eigenvalues in increasing order at each data point
350    
351      */
352      ESCRIPT_DLL_API
353      virtual void
354      eigenvalues(DataAbstract* ev);
355    
356      /**
357         \brief
358         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
359    
360         \param ev - Output - eigenvalues in increasing order at each data point
361         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
362                             and the first nonzero component is positive.
363         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
364    
365      */
366    
367      ESCRIPT_DLL_API
368      virtual void
369      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
370    
371    /**
372     *      \brief
373     *           reorders data sample ordered by reference_ids to the ordering of the functions space
374     *
375     *                \param reference_ids - Input - reference_ids used for current ordering
376     *                  */
377      ESCRIPT_DLL_API
378      virtual void
379      reorderByReferenceIDs(int *reference_ids);
380    
381    
382    
383   protected:   protected:
384    
# Line 184  class DataExpanded : public DataAbstract Line 386  class DataExpanded : public DataAbstract
386    
387    /**    /**
388       \brief       \brief
389       Common initialisation called from constructors       Common initialisation called from constructors.
390    
391       Description:       Description:
392       Common initialisation called from constructors       Common initialisation called from constructors.
393       \param shape - Input - The shape of the point data.  
394         Resizes the underlying data array to provide sufficient storage for the
395         given shape and number of data points, and creates the corresponding
396         DataArrayView of this data.
397    
398       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
399       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
400    */    */
401    void    void
402    initialise(const DataArrayView::ShapeType& shape,    initialise(int noSamples,
              int noSamples,  
403               int noDataPointsPerSample);               int noDataPointsPerSample);
404    
405    /**    /**
406       \brief       \brief
407       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
408    
409       Description:       Description:
410       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
411       \param value Input - Value for a single data point.  
412         \param value Input - A single data point value.
413    */    */
414    void    void
415    copy(const DataArrayView& value);    copy(const DataConstant& value);
416    
417    
418    
419      /**
420         \brief
421         Copy the given data point value given a numarray object to all data points in this object.
422    
423         Description:
424         Copy the given data point value given a numarray object to all data points in this object.
425    
426         \param value Input - A single data point value.
427      */
428    void    void
429    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
430    
431      /**
432         \brief
433         Copy the numarray object to the data points in this object.
434    
435         Description:
436         Copy the numarray object to the data points in this object.
437    
438         \param value Input - new values for the data points
439      */
440      void
441      copyAll(const boost::python::numeric::array& value);
442    
443      /**
444         \brief
445         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
446    
447         Description:
448         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
449    
450         \param sampleNo Input - sample number
451         \param dataPointNo Input - data point of the sample
452         \param value Input - new values for the data point
453      */
454      ESCRIPT_DLL_API
455      virtual void
456      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
457    
458    
459      /**
460         \brief
461         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
462    
463         Description:
464         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
465    
466         \param sampleNo Input - sample number
467         \param dataPointNo Input - data point of the sample
468         \param value Input - new values for the data point
469      */
470      void
471      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
472    
473    //    //
474    // The main data storage, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
475      // noSamples * noDataPointsPerSample
476    DataBlocks2D m_data;    DataBlocks2D m_data;
477    
478  };  };

Legend:
Removed from v.97  
changed lines
  Added in v.1796

  ViewVC Help
Powered by ViewVC 1.1.26