/[escript]/branches/trilinos_from_5897/escriptcore/src/DataConstant.h
ViewVC logotype

Diff of /branches/trilinos_from_5897/escriptcore/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/escript/src/Data/DataConstant.h revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC trunk/escript/src/DataConstant.h revision 2548 by jfenwick, Mon Jul 20 06:20:06 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_DataConstant_20040323_H  #if !defined escript_DataConstant_20040323_H
16  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
17    #include "system_dep.h"
18    
19  #include "escript/Data/DataAbstract.h"  #include "DataReady.h"
20  #include "escript/Data/DataArray.h"  #include "WrappedArray.h"
 #include "escript/Data/DataArrayView.h"  
21    
22  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
23    
24  namespace escript {  namespace escript {
25    
26  /**  /**
27     \brief     \brief
28     DataConstant stores single data point which represents the entire     DataConstant stores a single data point which represents the entire
29     function space.     function space.
30    
31     Description:     Description:
32     DataConstant stores single data point which represents the entire     DataConstant stores a single data point which represents the entire
33     function space.     function space.
34  */  */
35  class DataConstant:public DataAbstract  {  class DataConstant : public DataReady  {
36    typedef DataReady parent;
37   public:   public:
38    
39    /**    /**
40       \brief       \brief
41       Default constructor for DataConstant       Constructor for DataConstant objects.
42    
43       Description:       Description:
44       Default constructor for DataConstant       Constructor for DataConstant objects.
   
      \param value Input - Data value for a single point.  
      \param noSamples Input - number of samples.  
      \param noDataPointsPerSample Input - Input.  
      \param what Input - A description of what this data represents.  
45    
46         \param value - Input - Data value for a single point.
47         \param what - Input - A description of what this data object represents.
48    */    */
49    DataConstant(const boost::python::numeric::array& value, const FunctionSpace& what);    ESCRIPT_DLL_API
50      DataConstant(const WrappedArray& value,
51                   const FunctionSpace& what);
52    
53    
54    /**    /**
55       \brief       \brief
56       Copy constructor. Performs a deep copy.       Copy constructor. Performs a deep copy.
57    */    */
58      ESCRIPT_DLL_API
59    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
60    
61    
62    /**    /**
63       \brief       \brief
64       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
65    
66       Description:       Description:
67       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
68       \param value Input - Data value for a single point.       \param other - Input - Data object to copy from.
69       \param noSamples Input - number of samples.       \param region - Input - region to copy.
      \param noDataPointsPerSample Input - Input.  
      \param what Input - A description of what this data represents.  
70    */    */
71    DataConstant(const DataArrayView& value, const FunctionSpace& what);    ESCRIPT_DLL_API
72      DataConstant(const DataConstant& other,
73                   const DataTypes::RegionType& region);
74    
75    /**    /**
76       \brief       \brief
77       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
78    
79       Description:       Description:
80       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
81       \param other Input - Other DataConstant       \param what - Input - A description of what this data object represents.
82       \param region Input - region to copy       \param shape - Input - the shape of each data-point.
83         \param data - the data values for each data-point.
84    */    */
85    DataConstant(const DataConstant& other, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
86      DataConstant(const FunctionSpace& what,
87                   const DataTypes::ShapeType &shape,
88                   const DataTypes::ValueType &data);
89    
90    
91      ESCRIPT_DLL_API
92      bool
93      isConstant() const
94      {
95        return true;
96      };
97    
98    
99    /**    /**
100       \brief       \brief
101       Write the data as a string.       Write the data as a string.
102    */    */
103    std::string toString() const;    ESCRIPT_DLL_API
104      std::string
105      toString() const;
106    
107    /**    /**
108         \brief Return a deep copy of the current object.
109      */
110      ESCRIPT_DLL_API
111      virtual
112      DataAbstract*
113      deepCopy();
114    
115    
116     /**
117       \brief       \brief
118       Return the offset for the given sample. This is somewhat artificial notion       dumps the object into a netCDF file
119      */
120      ESCRIPT_DLL_API
121      virtual
122      void
123      dump(const std::string fileName) const;
124    
125     /**
126         \brief
127        sets all values to zero
128      */
129      ESCRIPT_DLL_API
130      virtual
131      void
132      setToZero();
133    
134      /**
135         \brief
136         Return the offset for the given sample. This is a somewhat artificial notion
137       but returns the offset in bytes for the given point into the container       but returns the offset in bytes for the given point into the container
138       holding the point data. Only really necessary to avoid many DataArrayView       holding the point data. Only really necessary to avoid many DataArrayView
139       objects.       objects.
140       \param sampleNo - Input, sample number.       \param sampleNo - Input - sample number.
141       \param dataPointNo - Input, data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
142     */     */
143    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    ESCRIPT_DLL_API
144      virtual
145      DataTypes::ValueType::size_type
146      getPointOffset(int sampleNo,
147                     int dataPointNo) const;
148    
149      ESCRIPT_DLL_API
150      virtual
151      DataTypes::ValueType::size_type
152      getPointOffset(int sampleNo,
153                     int dataPointNo);
154    
155    /**    /**
156       \brief       \brief
157       Return a view into the data for the data point specified.       Return the number of doubles stored for the Data object.
      NOTE: Construction of the DataArrayView is a relatively expensive  
      operation  
      \param sampleNo Input  
      \param dataPointNo Input  
158    */    */
159    virtual DataArrayView getDataPoint(int sampleNo, int dataPointNo);    ESCRIPT_DLL_API
160      virtual
161      DataTypes::ValueType::size_type
162      getLength() const;
163    
164    /**    /**
165       \brief       \brief
166       Return the number of doubles stored for the Data       Factory method that returns a newly created DataConstant object
167         sliced from the specified region of this object.
168         The caller is reponsible for managing the object created.
169         \param region - Input - region to slice from this object.
170    */    */
171    virtual ValueType::size_type getLength() const;    ESCRIPT_DLL_API
172      virtual
173      DataAbstract*
174      getSlice(const DataTypes::RegionType& region) const;
175    
176    /**    /**
177       \brief       \brief
178       Factory method that returns a newly created DataConstant.       Copy the specified region from the given value.
179       The caller is reponsible for managing the object created.       \param value - Input - Data object to copy from.
180         \param region - Input - Region to copy.
181    */    */
182    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;  /**    ESCRIPT_DLL_API
183      virtual
184      void
185      setSlice(const DataAbstract* value,
186               const DataTypes::RegionType& region);
187    
188    
189      /**
190       \brief       \brief
191       Copy the specified region from the given value.       Computes a symmetric matrix (A + AT) / 2
192       \param value Input - Data to copy from  
193       \param region Input - Region to copy.       \param ev - Output - symmetric matrix
194    
195      */
196      ESCRIPT_DLL_API
197      virtual void
198      symmetric(DataAbstract* ev);
199    
200      /**
201         \brief
202         Computes a nonsymmetric matrix (A - AT) / 2
203    
204         \param ev - Output - nonsymmetric matrix
205    
206    */    */
207    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
208      virtual void
209      nonsymmetric(DataAbstract* ev);
210    
211    /**    /**
212       \brief       \brief
213       Reshape the data point if the data point is currently rank 0.       Computes the trace of a matrix
214       The original data point value is used for all values of the new  
215       data point.       \param ev - Output - trace of matrix
216         \param axis_offset
217    
218    */    */
219    void reshapeDataPoint(const DataArrayView::ShapeType& shape);    ESCRIPT_DLL_API
220      virtual void
221      trace(DataAbstract* ev, int axis_offset);
222    
223      /**
224         \brief
225         Transpose each data point of this Data object around the given axis.
226    
227         \param ev - Output - transpose of matrix
228         \param axis_offset
229      */
230      ESCRIPT_DLL_API
231      virtual void
232      transpose(DataAbstract* ev, int axis_offset);
233    
234      /**
235         \brief
236         swaps components axis0 and axis1
237    
238         \param ev - Output - swapped components
239         \param axis0
240         \param axis1
241      */
242      ESCRIPT_DLL_API
243      virtual void
244      swapaxes(DataAbstract* ev, int axis0, int axis1);
245    
246    
247      /**
248         \brief
249         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
250    
251         \param ev - Output - eigenvalues in increasing order at each data point
252    
253      */
254      ESCRIPT_DLL_API
255      virtual void
256      eigenvalues(DataAbstract* ev);
257    
258      /**
259         \brief
260         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
261    
262         \param ev - Output - eigenvalues in increasing order at each data point
263         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
264                             and the first nonzero component is positive.
265         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
266    
267      */
268    
269      ESCRIPT_DLL_API
270      virtual void
271      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
272    
273    
274      /**
275         \brief
276         Return a reference to the underlying DataVector.
277      */
278      ESCRIPT_DLL_API
279      DataTypes::ValueType&
280      getVectorRW();
281    
282    
283      ESCRIPT_DLL_API
284      const DataTypes::ValueType&
285      getVectorRO() const;
286    
287   protected:   protected:
288    
289   private:   private:
290    //    //
291    // data    // the actual data
292    DataArrayView::ValueType m_data;    DataTypes::ValueType m_data;
293    
294  };  };
295    
296  } // end of namespace  } // end of namespace
297  #endif  #endif
   

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

  ViewVC Help
Powered by ViewVC 1.1.26