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

Diff of /trunk/escript/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 474 by jgs, Mon Jan 30 04:23:44 2006 UTC
# Line 1  Line 1 
1    //$Id$
2  /*  /*
3   ******************************************************************************   ******************************************************************************
4   *                                                                            *   *                                                                            *
# Line 12  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15                                                                                                                                                        
16  #if !defined  escript_DataConstant_20040323_H  #if !defined escript_DataConstant_20040323_H
17  #define escript_DataConstant_20040323_H  #define escript_DataConstant_20040323_H
18    
19  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
20  #include "escript/Data/DataArray.h"  #include "DataArray.h"
21  #include "escript/Data/DataArrayView.h"  #include "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);    DataConstant(const boost::python::numeric::array& value,
51                   const FunctionSpace& what);
52    
53    /**    /**
54       \brief       \brief
55       Copy constructor. Performs a deep copy.       Copy constructor. Performs a deep copy.
56    */    */
57    DataConstant(const DataConstant& other);    DataConstant(const DataConstant& other);
58    
59    /**    /**
60       \brief       \brief
61       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
62    
63       Description:       Description:
64       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
65       \param value Input - Data value for a single point.       \param value - Input - Data value for a single point.
66       \param noSamples Input - number of samples.       \param what - Input - A description of what this data object represents.
      \param noDataPointsPerSample Input - Input.  
      \param what Input - A description of what this data represents.  
67    */    */
68    DataConstant(const DataArrayView& value, const FunctionSpace& what);    DataConstant(const DataArrayView& value,
69                   const FunctionSpace& what);
70    
71    /**    /**
72       \brief       \brief
73       Alternative constructor for DataConstant       Alternative constructor for DataConstant objects.
74    
75       Description:       Description:
76       Alternative Constructor for DataConstant       Alternative Constructor for DataConstant objects.
77       \param other Input - Other DataConstant       \param other - Input - Data object to copy from.
78       \param region Input - region to copy       \param region - Input - region to copy.
79    */    */
80    DataConstant(const DataConstant& other, const DataArrayView::RegionType& region);    DataConstant(const DataConstant& other,
81                   const DataArrayView::RegionType& region);
82    
83      /**
84         \brief
85         Alternative constructor for DataConstant objects.
86    
87         Description:
88         Alternative Constructor for DataConstant objects.
89         \param what - Input - A description of what this data object represents.
90         \param shape - Input - the shape of each data-point.
91         \param data - the data values for each data-point.
92      */
93      DataConstant(const FunctionSpace& what,
94                   const DataArrayView::ShapeType &shape,
95                   const DataArrayView::ValueType &data);
96    
97    /**    /**
98       \brief       \brief
99       Write the data as a string.       Write the data as a string.
100    */    */
101    std::string toString() const;    std::string
102      toString() const;
103    
104    /**    /**
105       \brief       \brief
106       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
107       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
108       holding the point data. Only really necessary to avoid many DataArrayView       holding the point data. Only really necessary to avoid many DataArrayView
109       objects.       objects.
110       \param sampleNo - Input, sample number.       \param sampleNo - Input - sample number.
111       \param dataPointNo - Input, data point number for the sample.       \param dataPointNo - Input - data point number for the sample.
112     */     */
113    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    virtual
114      DataArrayView::ValueType::size_type
115      getPointOffset(int sampleNo,
116                     int dataPointNo) const;
117    
118    /**    /**
119       \brief       \brief
120       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
121       NOTE: Construction of the DataArrayView is a relatively expensive       \param sampleNo - Input - sample number.
122       operation       \param dataPointNo - Input - data point number for the sample.
      \param sampleNo Input  
      \param dataPointNo Input  
123    */    */
124    virtual DataArrayView getDataPoint(int sampleNo, int dataPointNo);    virtual
125      DataArrayView
126      getDataPoint(int sampleNo,
127                   int dataPointNo);
128    
129    /**    /**
130       \brief       \brief
131       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data object.
132    */    */
133    virtual ValueType::size_type getLength() const;    virtual
134      DataArrayView::ValueType::size_type
135      getLength() const;
136    
137    /**    /**
138       \brief       \brief
139       Factory method that returns a newly created DataConstant.       Factory method that returns a newly created DataConstant object
140         sliced from the specified region of this object.
141       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
142         \param region - Input - region to slice from this object.
143    */    */
144    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;  /**    virtual
145      DataAbstract*
146      getSlice(const DataArrayView::RegionType& region) const;
147    
148      /**
149       \brief       \brief
150       Copy the specified region from the given value.       Copy the specified region from the given value.
151       \param value Input - Data to copy from       \param value - Input - Data object to copy from.
152       \param region Input - Region to copy.       \param region - Input - Region to copy.
153    */    */
154    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    virtual
155      void
156      setSlice(const DataAbstract* value,
157               const DataArrayView::RegionType& region);
158    
159    /**    /**
160       \brief       \brief
161       Reshape the data point if the data point is currently rank 0.       Reshape the data point if the data point is currently rank 0.
162       The original data point value is used for all values of the new       The original data point value is used for all values of the new
163       data point.       data point.
164    */    */
165    void reshapeDataPoint(const DataArrayView::ShapeType& shape);    void
166      reshapeDataPoint(const DataArrayView::ShapeType& shape);
167    
168      /**
169        \brief
170        Archive the underlying data values to the file referenced
171        by ofstream. A count of the number of values expected to be written
172        is provided as a cross-check.
173    
174        The return value indicates success (0) or otherwise (1).
175      */
176      int
177      archiveData(std::ofstream& archiveFile,
178                  const DataArrayView::ValueType::size_type noValues) const;
179    
180      /**
181        \brief
182        Extract the number of values specified by noValues from the file
183        referenced by ifstream to the underlying data structure.
184    
185        The return value indicates success (0) or otherwise (1).
186      */
187      int
188      extractData(std::ifstream& archiveFile,
189                  const DataArrayView::ValueType::size_type noValues);
190    
191   protected:   protected:
192    
193   private:   private:
194    //    //
195    // data    // the actual data
196    DataArrayView::ValueType m_data;    DataArrayView::ValueType m_data;
197    
198  };  };
199    
200  } // end of namespace  } // end of namespace
201  #endif  #endif
   

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

  ViewVC Help
Powered by ViewVC 1.1.26