/[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 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataExpanded.h revision 2742 by jfenwick, Thu Nov 12 06:03:37 2009 UTC
# Line 1  Line 1 
1  /*  
2   ******************************************************************************  /*******************************************************
3   *                                                                            *  *
4   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  * Copyright (c) 2003-2009 by University of Queensland
5   *                                                                            *  * Earth Systems Science Computational Center (ESSCC)
6   * This software is the property of ACcESS. No part of this code              *  * http://www.uq.edu.au/esscc
7   * may be copied in any form or by any means without the expressed written    *  *
8   * consent of ACcESS.  Copying, use or modification of this software          *  * Primary Business: Queensland, Australia
9   * by any unauthorised person is illegal unless that person has a software    *  * Licensed under the Open Software License version 3.0
10   * license agreement with ACcESS.                                             *  * http://www.opensource.org/licenses/osl-3.0.php
11   *                                                                            *  *
12   ******************************************************************************  *******************************************************/
13  */  
14                                                                              
15  #if !defined  escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
16  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
17    #include "system_dep.h"
18    
19  #include "DataAbstract.h"  #include "DataReady.h"
20  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
 #include "DataArrayView.h"  
   
 #include <boost/scoped_ptr.hpp>  
 #include <boost/python/numeric.hpp>  
21    
22  namespace escript {  namespace escript {
23    
24    class DataConstant;  //
25    class DataTagged;  // Forward declarations of other Data types.
26    class DataConstant;
27    class DataTagged;
28    
29  /**  /**
30     \brief     \brief
31     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
32    
33     Description:     Description:
34     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
35    
36     Template Parameters:     Template Parameters:
37     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
38     template must satisfy     template must satisfy.
39  */  */
40    
41  class DataExpanded : public DataAbstract{  class DataExpanded : public DataReady {
42    
43    typedef DataReady parent;
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);  
50    
51    /**       Description:
52       \brief       Constructor for DataExpanded.
53       Construct a DataExpanded from a DataConstant  
54         The given single data value is copied to all the data points in
55         this data object, where the number of data points is defined by
56         the given function space.
57    
58         \param value - Input - The value of a single data point.
59         \param what - Input - A description of what this data represents.
60    */    */
61    DataExpanded(const DataConstant& other);    ESCRIPT_DLL_API
62      DataExpanded(const WrappedArray& value,
63                   const FunctionSpace& what);
64    
65    /**    /**
66       \brief       \brief
67       Construct a DataExpanded from a DataTagged       Alternative constructor for DataExpanded that copies a slice from
68         another DataExpanded.
69    
70         \param other - Input - DataExpanded object to slice from.
71         \param region - Input - region to copy.
72    */    */
73    DataExpanded(const DataTagged& other);    ESCRIPT_DLL_API
74      DataExpanded(const DataExpanded& other,
75                   const DataTypes::RegionType& region);
76    
77    /**    /**
78       \brief       \brief
79       Constructor for DataExpanded       Alternative constructor for DataExpanded objects.
80    
81       Description:       Description:
82       Constructor for DataExpanded       Alternative Constructor for DataExpanded objects.
83       \param value - Input - Data value for a single point.       \param what - Input - A description of what this data object represents.
84       \param what - Input - A description of what this data represents.       \param shape - Input - the shape of each data-point.
85         \param data - the array of data values for the data-points.
86    
87    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.
88    */    */
89    DataExpanded(const boost::python::numeric::array& value, const FunctionSpace& what);    ESCRIPT_DLL_API
90      DataExpanded(const FunctionSpace& what,
91                   const DataTypes::ShapeType &shape,
92                   const DataTypes::ValueType &data);
93    
94    /**    /**
95       \brief       \brief
96       Alternative constructor for DataExpanded       Copy constructor for DataExpanded.
97         Performs a deep copy from another DataExpanded.
98       Description:    */
99       Alternative Constructor for DataExpanded    ESCRIPT_DLL_API
100       \param value - Input - Data value for a single point.    DataExpanded(const DataExpanded& other);
      \param what - Input - A description of what this data represents.  
101    
102      /**
103         \brief
104         Copy constructor for DataExpanded.
105         Construct a DataExpanded from a DataConstant.
106    */    */
107    DataExpanded(const DataArrayView& value, const FunctionSpace& what);    ESCRIPT_DLL_API
108      DataExpanded(const DataConstant& other);
109    
110    /**    /**
111       \brief       \brief
112       Alternative constructor for DataExpanded that copies a slice from       Copy constructor for DataExpanded.
113       another DataExpanded.       Construct a DataExpanded from a DataTagged.
114      */
115      ESCRIPT_DLL_API
116      DataExpanded(const DataTagged& other);
117    
118       \param other - Input - DataExpanded object to slice from    /**
119       \param region - Input - region to copy       \brief
120         Default destructor for DataExpanded.
121    */    */
122    DataExpanded(const DataExpanded& other, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
123      virtual
124      ~DataExpanded();
125    
126      ESCRIPT_DLL_API
127      bool
128      isExpanded() const
129      {
130        return true;
131      };
132    
133      ESCRIPT_DLL_API
134      bool
135      actsExpanded() const
136      {
137        return true;
138      }
139    
140    /**    /**
141       \brief       \brief
142       Destructor       Return a textual representation of the data.
143    */    */
144    virtual ~DataExpanded();    ESCRIPT_DLL_API
145      virtual
146      std::string
147      toString() const;
148    
149    /**    /**
150         \brief Return a deep copy of the current object.
151      */
152      ESCRIPT_DLL_API
153      virtual
154      DataAbstract*
155      deepCopy();
156    
157    
158     /**
159       \brief       \brief
160       Return a textual representation of the data       dumps the object into a netCDF file
161    */    */
162    virtual std::string toString() const;    ESCRIPT_DLL_API
163      virtual
164      void
165      dump(const std::string fileName) const;
166    
167    
168    /**    /**
169        \brief invert square matricies
170        \param out - Where to store the results
171      */
172      ESCRIPT_DLL_API
173      virtual void
174      matrixInverse(DataAbstract* out) const;
175    
176     /**
177       \brief       \brief
178       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.  
179    */    */
180    void reshapeDataPoint(const DataArrayView::ShapeType& shape);    ESCRIPT_DLL_API
181      virtual
182      void
183      setToZero();
184    
185    /**    /**
186       \brief       \brief
187       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
188       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
189       holding the point data.       holding the point data.
190       \param sampleNo - Input - number of samples.  
191       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
192         \param dataPointNo - Input - data point number.
193    */    */
194    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    ESCRIPT_DLL_API
195      virtual
196      DataTypes::ValueType::size_type
197      getPointOffset(int sampleNo,
198                     int dataPointNo) const;
199    
200      ESCRIPT_DLL_API
201      virtual
202      DataTypes::ValueType::size_type
203      getPointOffset(int sampleNo,
204                     int dataPointNo);
205    
206    /**    /**
207       \brief       \brief
208       Return a view into the data for the data point specified.       Return a a reference to the underlying DataVector.
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation  
      \param sampleNo - Input  
      \param dataPointNo - Input  
      \return DataArrayView of the data point.  
209    */    */
210    DataArrayView getDataPoint(int sampleNo, int dataPointNo);  
211      ESCRIPT_DLL_API
212      DataTypes::ValueType&
213      getVectorRW();
214    
215      ESCRIPT_DLL_API
216      const DataTypes::ValueType&
217      getVectorRO() const;
218    
219    
220    
221    /**    /**
222       \brief       \brief
223       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data.
224    */    */
225    virtual ValueType::size_type getLength() const;    ESCRIPT_DLL_API
226      virtual
227      ValueType::size_type
228      getLength() const;
229    
230    /**    /**
231       \brief       \brief
232       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
233       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
234    
235       \param region - Input - Region to copy.       \param region - Input - Region to copy.
236    */    */
237    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;    ESCRIPT_DLL_API
238      virtual
239      DataAbstract*
240      getSlice(const DataTypes::RegionType& region) const;
241    
242    /**    /**
243       \brief       \brief
244       Copy the specified region from the given value.       Copy the specified region from the given value.
245       \param value - Input - Data to copy from  
246         \param value - Input - Data object to copy from.
247       \param region - Input - Region to copy.       \param region - Input - Region to copy.
248    */    */
249    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
250      virtual
251      void
252      setSlice(const DataAbstract* value,
253               const DataTypes::RegionType& region);
254    
255      /**
256         \brief
257         setTaggedValue
258    
259         Description:
260         uses tag to set a new value
261    
262         \param tagKey - Input - Integer key.
263         \param pointshape - Input - The shape of the value parameter
264         \param value - Input -
265         \param dataOffset - Input - where in the value parameter to start reading the data point value.
266      */
267      void  
268      setTaggedValue(int tagKey,
269                 const DataTypes::ShapeType& pointshape,
270                     const DataTypes::ValueType& value,
271             int dataOffset=0);
272    
273    
274    
275      /**
276         \brief
277         Computes a symmetric matrix (A + AT) / 2
278    
279         \param ev - Output - symmetric matrix
280    
281      */
282      ESCRIPT_DLL_API
283      virtual void
284      symmetric(DataAbstract* ev);
285    
286      /**
287         \brief
288         Computes a nonsymmetric matrix (A - AT) / 2
289    
290         \param ev - Output - nonsymmetric matrix
291    
292      */
293      ESCRIPT_DLL_API
294      virtual void
295      nonsymmetric(DataAbstract* ev);
296    
297      /**
298         \brief
299         Computes the trace of a matrix
300    
301         \param ev - Output - trace of your matrix
302         \param axis_offset -
303    
304      */
305      ESCRIPT_DLL_API
306      virtual void
307      trace(DataAbstract* ev, int axis_offset);
308    
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         \param axis_offset -
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         \param axis0
326         \param axis1
327      */
328      ESCRIPT_DLL_API
329      virtual void
330      swapaxes(DataAbstract* ev, int axis0, int axis1);
331    
332    
333      /**
334         \brief
335         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
336    
337         \param ev - Output - eigenvalues in increasing order at each data point
338    
339      */
340      ESCRIPT_DLL_API
341      virtual void
342      eigenvalues(DataAbstract* ev);
343    
344      /**
345         \brief
346         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
347    
348         \param ev - Output - eigenvalues in increasing order at each data point
349         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
350                             and the first nonzero component is positive.
351         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
352    
353      */
354    
355      ESCRIPT_DLL_API
356      virtual void
357      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
358    
359    /**
360     *      \brief
361     *           reorders data sample ordered by reference_ids to the ordering of the functions space
362     *
363     *                \param reference_ids - Input - reference_ids used for current ordering
364     *                  */
365      ESCRIPT_DLL_API
366      virtual void
367      reorderByReferenceIDs(int *reference_ids);
368    
369    
370    
371   protected:   protected:
372    
# Line 163  class DataExpanded : public DataAbstract Line 374  class DataExpanded : public DataAbstract
374    
375    /**    /**
376       \brief       \brief
377       Common initialisation called from constructors       Common initialisation called from constructors.
378    
379       Description:       Description:
380       Common initialisation called from constructors       Common initialisation called from constructors.
381       \param shape - Input - The shape of the point data.  
382         Resizes the underlying data array to provide sufficient storage for the
383         given shape and number of data points, and creates the corresponding
384         DataArrayView of this data.
385    
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
390      initialise(int noSamples,
391                 int noDataPointsPerSample);
392    
393      /**
394         \brief
395         Copy the given data point value to all data points in this object.
396    
397         Description:
398         Copy the given data point to all data points in this object.
399    
400         \param value Input - A single data point value.
401      */
402      void
403      copy(const DataConstant& value);
404    
405    
406    
407      /**
408         \brief
409         Copy the given data point value to all data points in this object.
410    
411         \param value Input - A single data point value.
412    */    */
413    void initialise(const DataArrayView::ShapeType& shape, int noSamples, int noDataPointsPerSample);  
414      void
415      copy(const WrappedArray& value);
416    
417    
418    /**    /**
419       \brief       \brief
420       Copy the given data point to all data points.       Copy a double value to the data point dataPointNo of sample sampleNo in this object.
421    
422       Description:       Description:
423       Copy the given data point to all data points.       Copy a double value to the data point dataPointNo of sample sampleNo in this object.
424       \param value Input - Value for a single data point  
425         \param sampleNo Input - sample number
426         \param dataPointNo Input - data point of the sample
427         \param value Input - new values for the data point
428    */    */
429    void copy(const DataArrayView& value);    ESCRIPT_DLL_API
430    void copy(const boost::python::numeric::array& value);    virtual void
431      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
432    
433    
434      /**
435         \brief
436         Copy the value to the data point dataPointNo of sample sampleNo in this object.
437    
438         \param sampleNo Input - sample number
439         \param dataPointNo Input - data point of the sample
440         \param value Input - new values for the data point
441      */
442      ESCRIPT_DLL_API
443      virtual void
444      copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
445    
446    //    //
447    // The main data storage, a 2D array of data blocks    // The main data storage array, a 2D array of data blocks.
448      // noSamples * noDataPointsPerSample
449    DataBlocks2D m_data;    DataBlocks2D m_data;
450    
451  };  };
452    
453  } // end of namespace  } // end of namespace
 #endif  
   
   
   
454    
455    #endif

Legend:
Removed from v.100  
changed lines
  Added in v.2742

  ViewVC Help
Powered by ViewVC 1.1.26