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

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

  ViewVC Help
Powered by ViewVC 1.1.26