/[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 1388 by trankine, Fri Jan 11 07:45:58 2008 UTC
# Line 1  Line 1 
1  /*  
2   ******************************************************************************  /* $Id$ */
3   *                                                                            *  
4   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  /*******************************************************
5   *                                                                            *   *
6   * This software is the property of ACcESS. No part of this code              *   *           Copyright 2003-2007 by ACceSS MNRF
7   * may be copied in any form or by any means without the expressed written    *   *       Copyright 2007 by University of Queensland
8   * consent of ACcESS.  Copying, use or modification of this software          *   *
9   * by any unauthorised person is illegal unless that person has a software    *   *                http://esscc.uq.edu.au
10   * license agreement with ACcESS.                                             *   *        Primary Business: Queensland, Australia
11   *                                                                            *   *  Licensed under the Open Software License version 3.0
12   ******************************************************************************   *     http://www.opensource.org/licenses/osl-3.0.php
13  */   *
14                                                                               *******************************************************/
15  #if !defined  escript_DataConstant_20040323_H  
16    #if !defined escript_DataConstant_20040323_H
17  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
18    #include "system_dep.h"
19    
20  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
21  #include "escript/Data/DataArray.h"  #include "DataArrayView.h"
 #include "escript/Data/DataArrayView.h"  
22    
23  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
24    
25  namespace escript {  namespace escript {
26    
27  /**  /**
28     \brief     \brief
29     DataConstant stores single data point which represents the entire     DataConstant stores a single data point which represents the entire
30     function space.     function space.
31    
32     Description:     Description:
33     DataConstant stores single data point which represents the entire     DataConstant stores a single data point which represents the entire
34     function space.     function space.
35  */  */
36  class DataConstant:public DataAbstract  {  class DataConstant : public DataAbstract  {
37    
38   public:   public:
39    
40    /**    /**
41       \brief       \brief
42       Default constructor for DataConstant       Constructor for DataConstant objects.
43    
44       Description:       Description:
45       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.  
46    
47         \param value - Input - Data value for a single point.
48         \param what - Input - A description of what this data object represents.
49    */    */
50    DataConstant(const boost::python::numeric::array& value, const FunctionSpace& what);    ESCRIPT_DLL_API
51      DataConstant(const boost::python::numeric::array& value,
52                   const FunctionSpace& what);
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         \brief
63         Alternative constructor for DataConstant objects.
64    
65         Description:
66         Alternative Constructor for DataConstant objects.
67         \param value - Input - Data value for a single point.
68         \param what - Input - A description of what this data object represents.
69      */
70      ESCRIPT_DLL_API
71      DataConstant(const DataArrayView& value,
72                   const FunctionSpace& what);
73    
74    /**    /**
75       \brief       \brief
76       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
77    
78       Description:       Description:
79       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
80       \param value Input - Data value for a single point.       \param other - Input - Data object to copy from.
81       \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.  
82    */    */
83    DataConstant(const DataArrayView& value, const FunctionSpace& what);    ESCRIPT_DLL_API
84      DataConstant(const DataConstant& other,
85                   const DataArrayView::RegionType& region);
86    
87    /**    /**
88       \brief       \brief
89       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
90    
91       Description:       Description:
92       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
93       \param other Input - Other DataConstant       \param what - Input - A description of what this data object represents.
94       \param region Input - region to copy       \param shape - Input - the shape of each data-point.
95         \param data - the data values for each data-point.
96    */    */
97    DataConstant(const DataConstant& other, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
98      DataConstant(const FunctionSpace& what,
99                   const DataArrayView::ShapeType &shape,
100                   const DataArrayView::ValueType &data);
101    
102    /**    /**
103       \brief       \brief
104       Write the data as a string.       Write the data as a string.
105    */    */
106    std::string toString() const;    ESCRIPT_DLL_API
107      std::string
108      toString() const;
109     /**
110         \brief
111         dumps the object into a netCDF file
112      */
113      ESCRIPT_DLL_API
114      virtual
115      void
116      dump(const std::string fileName) const;
117    
118     /**
119         \brief
120        sets all values to zero
121      */
122      ESCRIPT_DLL_API
123      virtual
124      void
125      setToZero();
126    
127    /**    /**
128       \brief       \brief
129       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given sample. This is a somewhat artificial notion
130       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
131       holding the point data. Only really necessary to avoid many DataArrayView       holding the point data. Only really necessary to avoid many DataArrayView
132       objects.       objects.
133       \param sampleNo - Input, sample number.       \param sampleNo - Input - sample number.
134       \param dataPointNo - Input, data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
135     */     */
136    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    ESCRIPT_DLL_API
137      virtual
138      DataArrayView::ValueType::size_type
139      getPointOffset(int sampleNo,
140                     int dataPointNo) const;
141    
142    /**    /**
143       \brief       \brief
144       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
145       NOTE: Construction of the DataArrayView is a relatively expensive       \param sampleNo - Input - sample number.
146       operation       \param dataPointNo - Input - data point number for the sample.
      \param sampleNo Input  
      \param dataPointNo Input  
147    */    */
148    virtual DataArrayView getDataPoint(int sampleNo, int dataPointNo);    ESCRIPT_DLL_API
149      virtual
150      DataArrayView
151      getDataPoint(int sampleNo,
152                   int dataPointNo);
153    
154    /**    /**
155       \brief       \brief
156       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data object.
157    */    */
158    virtual ValueType::size_type getLength() const;    ESCRIPT_DLL_API
159      virtual
160      DataArrayView::ValueType::size_type
161      getLength() const;
162    
163    /**    /**
164       \brief       \brief
165       Factory method that returns a newly created DataConstant.       Factory method that returns a newly created DataConstant object
166         sliced from the specified region of this object.
167       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
168         \param region - Input - region to slice from this object.
169    */    */
170    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;  /**    ESCRIPT_DLL_API
171      virtual
172      DataAbstract*
173      getSlice(const DataArrayView::RegionType& region) const;
174    
175      /**
176       \brief       \brief
177       Copy the specified region from the given value.       Copy the specified region from the given value.
178       \param value Input - Data to copy from       \param value - Input - Data object to copy from.
179       \param region Input - Region to copy.       \param region - Input - Region to copy.
180      */
181      ESCRIPT_DLL_API
182      virtual
183      void
184      setSlice(const DataAbstract* value,
185               const DataArrayView::RegionType& region);
186    
187      /**
188        \brief
189        Archive the underlying data values to the file referenced
190        by ofstream. A count of the number of values expected to be written
191        is provided as a cross-check.
192    
193        The return value indicates success (0) or otherwise (1).
194      */
195      ESCRIPT_DLL_API
196      int
197      archiveData(std::ofstream& archiveFile,
198                  const DataArrayView::ValueType::size_type noValues) const;
199    
200      /**
201        \brief
202        Extract the number of values specified by noValues from the file
203        referenced by ifstream to the underlying data structure.
204    
205        The return value indicates success (0) or otherwise (1).
206      */
207      ESCRIPT_DLL_API
208      int
209      extractData(std::ifstream& archiveFile,
210                  const DataArrayView::ValueType::size_type noValues);
211    
212      /**
213         \brief
214         Computes a symmetric matrix (A + AT) / 2
215    
216         \param ev - Output - symmetric matrix
217    
218      */
219      ESCRIPT_DLL_API
220      virtual void
221      symmetric(DataAbstract* ev);
222    
223      /**
224         \brief
225         Computes a nonsymmetric matrix (A - AT) / 2
226    
227         \param ev - Output - nonsymmetric matrix
228    
229      */
230      ESCRIPT_DLL_API
231      virtual void
232      nonsymmetric(DataAbstract* ev);
233    
234      /**
235         \brief
236         Computes the trace of a matrix
237    
238         \param ev - Output - trace of matrix
239    
240      */
241      ESCRIPT_DLL_API
242      virtual void
243      trace(DataAbstract* ev, int axis_offset);
244    
245      /**
246         \brief
247         Transpose each data point of this Data object around the given axis.
248    
249         \param ev - Output - transpose of matrix
250    
251      */
252      ESCRIPT_DLL_API
253      virtual void
254      transpose(DataAbstract* ev, int axis_offset);
255    
256      /**
257         \brief
258         swaps components axis0 and axis1
259    
260         \param ev - Output - swapped components
261    
262      */
263      ESCRIPT_DLL_API
264      virtual void
265      swapaxes(DataAbstract* ev, int axis0, int axis1);
266    
267    
268      /**
269         \brief
270         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
271    
272         \param ev - Output - eigenvalues in increasing order at each data point
273    
274    */    */
275    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    ESCRIPT_DLL_API
276      virtual void
277      eigenvalues(DataAbstract* ev);
278    
279    /**    /**
280       \brief       \brief
281       Reshape the data point if the data point is currently rank 0.       solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
282       The original data point value is used for all values of the new  
283       data point.       \param ev - Output - eigenvalues in increasing order at each data point
284         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
285                             and the first nonzero component is positive.
286         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
287    
288    */    */
289    void reshapeDataPoint(const DataArrayView::ShapeType& shape);  
290      ESCRIPT_DLL_API
291      virtual void
292      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
293    
294    
295   protected:   protected:
296    
297   private:   private:
298    //    //
299    // data    // the actual data
300    DataArrayView::ValueType m_data;    DataArrayView::ValueType m_data;
301    
302  };  };
303    
304  } // end of namespace  } // end of namespace
305  #endif  #endif
   

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

  ViewVC Help
Powered by ViewVC 1.1.26