/[escript]/trunk/escript/src/DataAbstract.h
ViewVC logotype

Diff of /trunk/escript/src/DataAbstract.h

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

trunk/esys2/escript/src/Data/DataAbstract.h revision 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/src/DataAbstract.h revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 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_DataAbstract_20040315_H  #if !defined escript_DataAbstract_20040315_H
17  #define escript_DataAbstract_20040315_H  #define escript_DataAbstract_20040315_H
18    #include "system_dep.h"
19    
20  #include "escript/Data/DataException.h"  #include "DataArrayView.h"
21  #include "escript/Data/DataArrayView.h"  #include "DataArray.h"
22  #include "escript/Data/DataArray.h"  #include "FunctionSpace.h"
 #include "escript/Data/FunctionSpace.h"  
23    
 #include <iostream>  
24  #include <boost/scoped_ptr.hpp>  #include <boost/scoped_ptr.hpp>
25  #include <functional>  #include <boost/python/numeric.hpp>
26    
27  #include <string>  #include <string>
28    #include <fstream>
29    
30  namespace escript {  namespace escript {
31    
# Line 58  class DataAbstract { Line 59  class DataAbstract {
59    
60       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
61    */    */
62      ESCRIPT_DLL_API
63    DataAbstract(const FunctionSpace& what);    DataAbstract(const FunctionSpace& what);
64    
65    /**    /**
66      \brief      \brief
67      Destructor for DataAbstract.      Destructor for DataAbstract.
68    */    */
69      ESCRIPT_DLL_API
70    virtual    virtual
71    ~DataAbstract();    ~DataAbstract();
72    
# Line 71  class DataAbstract { Line 74  class DataAbstract {
74       \brief       \brief
75       Write the data as a string.       Write the data as a string.
76    */    */
77      ESCRIPT_DLL_API
78    virtual    virtual
79    std::string    std::string
80    toString() const = 0;    toString() const = 0;
81    
82     /**
83         \brief
84         dumps the object into a netCDF file
85      */
86      ESCRIPT_DLL_API
87      virtual
88      void
89      dump(const std::string fileName) const;
90    
91    /**    /**
92       \brief       \brief
93       Return the number of data points per sample.       Return the number of data points per sample.
94    */    */
95      ESCRIPT_DLL_API
96    int    int
97    getNumDPPSample() const;    getNumDPPSample() const;
98    
# Line 86  class DataAbstract { Line 100  class DataAbstract {
100       \brief       \brief
101       Return the number of samples.       Return the number of samples.
102    */    */
103      ESCRIPT_DLL_API
104    int    int
105    getNumSamples() const;    getNumSamples() const;
106    
# Line 95  class DataAbstract { Line 110  class DataAbstract {
110       the shape information for each data point although it also may be used       the shape information for each data point although it also may be used
111       to manipulate the point data.       to manipulate the point data.
112    */    */
113      ESCRIPT_DLL_API
114    DataArrayView&    DataArrayView&
115    getPointDataView();    getPointDataView();
116    
117      ESCRIPT_DLL_API
118    const DataArrayView&    const DataArrayView&
119    getPointDataView() const;    getPointDataView() const;
120    
# Line 110  class DataAbstract { Line 127  class DataAbstract {
127       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
128       \param dataPointNo - Input - data point number.       \param dataPointNo - Input - data point number.
129     */     */
130      ESCRIPT_DLL_API
131    virtual    virtual
132    ValueType::size_type    ValueType::size_type
133    getPointOffset(int sampleNo,    getPointOffset(int sampleNo,
# Line 119  class DataAbstract { Line 137  class DataAbstract {
137       \brief       \brief
138       Return the sample data for the given sample number.       Return the sample data for the given sample number.
139    */    */
140      ESCRIPT_DLL_API
141    double*    double*
142    getSampleData(ValueType::size_type sampleNo);    getSampleData(ValueType::size_type sampleNo);
143    
# Line 126  class DataAbstract { Line 145  class DataAbstract {
145       \brief       \brief
146       Return the number of doubles stored for this Data object.       Return the number of doubles stored for this Data object.
147    */    */
148      ESCRIPT_DLL_API
149    virtual    virtual
150    ValueType::size_type    ValueType::size_type
151    getLength() const = 0;    getLength() const = 0;
# Line 135  class DataAbstract { Line 155  class DataAbstract {
155       Return the sample data for the given tag key.       Return the sample data for the given tag key.
156       NB: If the data isn't tagged an exception will be thrown.       NB: If the data isn't tagged an exception will be thrown.
157    */    */
158      ESCRIPT_DLL_API
159    virtual    virtual
160    double*    double*
161    getSampleDataByTag(int tag);    getSampleDataByTag(int tag);
162    
   /**  
      \brief  
      Assign the given value to the data-points(s) referenced by the given  
      reference number.  
   
      If this Data object cannot be accessed by reference numbers an  
      exception will be thrown.  
   
      \param ref - Input - reference number.  
      \param value - Input - value to assign to data-points associated with  
                             the given reference number.  
   */  
   virtual  
   void  
   setRefValue(int ref,  
               const DataArray& value);  
   
   /**  
      \brief  
      Return the values associated with the data-point(s) referenced by the given  
      reference number.  
   
      If this Data object cannot be accessed by reference numbers an  
      exception will be thrown.  
   
      \param ref - Input - reference number.  
      \param value - Output - object to receive data-points associated with  
                              the given reference number.  
   */  
   virtual  
   void  
   getRefValue(int ref,  
               DataArray& value);  
163    
164    /**    /**
165       \brief       \brief
# Line 180  class DataAbstract { Line 168  class DataAbstract {
168    
169       \param right - Input - The right hand side.       \param right - Input - The right hand side.
170    */    */
171      ESCRIPT_DLL_API
172    void    void
173    operandCheck(const DataAbstract& right) const;    operandCheck(const DataAbstract& right) const;
174    
# Line 187  class DataAbstract { Line 176  class DataAbstract {
176       \brief       \brief
177       Return true if a valid sample point number.       Return true if a valid sample point number.
178    */    */
179      ESCRIPT_DLL_API
180    bool    bool
181    validSamplePointNo(int samplePointNo) const;    validSamplePointNo(int samplePointNo) const;
182    
# Line 194  class DataAbstract { Line 184  class DataAbstract {
184       \brief       \brief
185       Return true if a valid sample number.       Return true if a valid sample number.
186    */    */
187      ESCRIPT_DLL_API
188    bool    bool
189    validSampleNo(int sampleNo) const;    validSampleNo(int sampleNo) const;
190    
# Line 206  class DataAbstract { Line 197  class DataAbstract {
197       \param sampleNo - Input - the sample number.       \param sampleNo - Input - the sample number.
198       \param dataPointNo - Input - the data point number.       \param dataPointNo - Input - the data point number.
199    */    */
200      ESCRIPT_DLL_API
201    virtual    virtual
202    DataArrayView    DataArrayView
203    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
# Line 215  class DataAbstract { Line 207  class DataAbstract {
207       \brief       \brief
208       Return the function space associated with this Data object.       Return the function space associated with this Data object.
209    */    */
210      ESCRIPT_DLL_API
211    const    const
212    FunctionSpace&    FunctionSpace&
213    getFunctionSpace() const;    getFunctionSpace() const;
# Line 225  class DataAbstract { Line 218  class DataAbstract {
218    
219       NB: The caller is responsible for managing the object created.       NB: The caller is responsible for managing the object created.
220    */    */
221      ESCRIPT_DLL_API
222    virtual    virtual
223    DataAbstract*    DataAbstract*
224    getSlice(const DataArrayView::RegionType& region) const = 0;    getSlice(const DataArrayView::RegionType& region) const = 0;
# Line 236  class DataAbstract { Line 230  class DataAbstract {
230       \param value - Input - Data to copy from       \param value - Input - Data to copy from
231       \param region - Input - Region to copy.       \param region - Input - Region to copy.
232    */    */
233      ESCRIPT_DLL_API
234    virtual    virtual
235    void    void
236    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
237             const DataArrayView::RegionType& region) = 0;             const DataArrayView::RegionType& region) = 0;
238    
   /**  
      \brief  
      Reshape the data points if they are currently rank 0.  
      Will throw an exception if the data points are not rank 0.  
      The original data point value is used for all values of the new  
      data point.  
   */  
   virtual  
   void  
   reshapeDataPoint(const ShapeType& shape) = 0;  
239    
240    /**    /**
241       \brief       \brief
# Line 264  class DataAbstract { Line 249  class DataAbstract {
249       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
250       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
251    */    */
252      ESCRIPT_DLL_API
253    virtual    virtual
254    void    void
255    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
256                   const DataArrayView& value);                   const DataArrayView& value);
257    
258      /**
259        \brief
260        Archive the underlying data values to the file referenced
261        by ofstream. A count of the number of values expected to be written
262        is provided as a cross-check.
263    
264        The return value indicates success (0) or otherwise (1).
265      */
266      ESCRIPT_DLL_API
267      virtual
268      int
269      archiveData(std::ofstream& archiveFile,
270                  const ValueType::size_type noValues) const;
271    
272      /**
273        \brief
274        Extract the number of values specified by noValues from the file
275        referenced by ifstream to the underlying data structure.
276    
277        The return value indicates success (0) or otherwise (1).
278      */
279      ESCRIPT_DLL_API
280      virtual
281      int
282      extractData(std::ifstream& archiveFile,
283                  const ValueType::size_type noValues);
284    
285      /**
286         \brief
287         Copy the numarray object to the data points in this object.
288    
289         Description:
290         Copy the numarray object to the data points in this object.
291    
292         \param value Input - new values for the data points
293      */
294      ESCRIPT_DLL_API
295      virtual void
296      copyAll(const boost::python::numeric::array& value);
297    
298      /**
299         \brief
300         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
301    
302         Description:
303         Copy a double value to the data point dataPointNo of sample sampleNo in this object.
304    
305         \param sampleNo Input - sample number
306         \param dataPointNo Input - data point of the sample
307         \param value Input - new values for the data point
308      */
309      ESCRIPT_DLL_API
310      virtual void
311      copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
312    
313      /**
314         \brief
315         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
316    
317         Description:
318         Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
319    
320         \param sampleNo Input - sample number
321         \param dataPointNo Input - data point of the sample
322         \param value Input - new values for the data point
323      */
324      ESCRIPT_DLL_API
325      virtual void
326      copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
327    
328    
329      /**
330         \brief
331         Return the tag number associated with the given data-point number.
332    
333         If the object cannot be referenced by tag numbers, an exception
334         will be thrown.
335      */
336      ESCRIPT_DLL_API
337      virtual
338      int
339      getTagNumber(int dpno);
340    
341      /**
342         \brief
343         Computes a symmetric matrix (A + AT) / 2
344    
345         \param ev - Output - a symmetric matrix
346    
347      */
348      ESCRIPT_DLL_API
349      virtual void
350      symmetric(DataAbstract* ev);
351    
352      /**
353         \brief
354         Computes a nonsymmetric matrix (A - AT) / 2
355    
356         \param ev - Output - a nonsymmetric matrix
357    
358      */
359      ESCRIPT_DLL_API
360      virtual void
361      nonsymmetric(DataAbstract* ev);
362    
363      /**
364         \brief
365         Computes the trace of a matrix
366    
367         \param ev - Output - the trace of a matrix
368    
369      */
370      ESCRIPT_DLL_API
371      virtual void
372      trace(DataAbstract* ev, int axis_offset);
373    
374      /**
375         \brief
376         Transpose each data point of this Data object around the given axis.
377    
378         \param ev - Output - the transpose of a matrix
379    
380      */
381      ESCRIPT_DLL_API
382      virtual void
383      transpose(DataAbstract* ev, int axis_offset);
384    
385      /**
386         \brief
387         swaps components axis0 and axis1
388    
389         \param ev - Output - swapped components
390    
391      */
392      ESCRIPT_DLL_API
393      virtual void
394      swapaxes(DataAbstract* ev, int axis0, int axis1);
395      /**
396         \brief
397         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
398    
399         \param ev - Output - eigenvalues in increasing order at each data point
400    
401      */
402      ESCRIPT_DLL_API
403      virtual void
404      eigenvalues(DataAbstract* ev);
405    
406      /**
407         \brief
408         sets values to zero
409    
410      */
411      ESCRIPT_DLL_API
412      virtual void
413      setToZero();
414    
415      /**
416         \brief
417         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
418    
419         \param ev - Output - eigenvalues in increasing order at each data point
420         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
421                             and the first nonzero component is positive.
422         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
423    
424      */
425    
426      ESCRIPT_DLL_API
427      virtual void
428      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
429    
430   protected:   protected:
431    
432    /**    /**
# Line 278  class DataAbstract { Line 436  class DataAbstract {
436       \param input - Input - The point data view. DataAbstract takes ownership       \param input - Input - The point data view. DataAbstract takes ownership
437       of the DataArrayView provided. It will delete it when it is destructed.       of the DataArrayView provided. It will delete it when it is destructed.
438    */    */
439      ESCRIPT_DLL_API
440    void    void
441    setPointDataView(const DataArrayView& input);    setPointDataView(const DataArrayView& input);
442    
443      ESCRIPT_DLL_API
444    void    void
445    resetPointDataView();    resetPointDataView();
446    
# Line 366  DataAbstract::getPointDataView() Line 526  DataAbstract::getPointDataView()
526  {  {
527    return *(m_pointDataView.get());    return *(m_pointDataView.get());
528  }  }
   
529  } // end of namespace  } // end of namespace
530    
531  #endif  #endif

Legend:
Removed from v.121  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26