/[escript]/trunk/escript/src/Data/DataExpanded.h
ViewVC logotype

Diff of /trunk/escript/src/Data/DataExpanded.h

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

revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC
# Line 1  Line 1 
1    // $Id$
2  /*  /*
3   ******************************************************************************   ******************************************************************************
4   *                                                                            *   *                                                                            *
# Line 12  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15                                                                                                                                                        
16  #if !defined  escript_DataExpanded_20040323_H  #if !defined escript_DataExpanded_20040323_H
17  #define escript_DataExpanded_20040323_H  #define escript_DataExpanded_20040323_H
18    
19  #include "DataAbstract.h"  #include "DataAbstract.h"
# Line 24  Line 25 
25    
26  namespace escript {  namespace escript {
27    
28    class DataConstant;  //
29    class DataTagged;  // Forward declarations of other Data types.
30    class DataEmpty;
31    class DataConstant;
32    class DataTagged;
33    
34  /**  /**
35     \brief     \brief
36     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
37    
38     Description:     Description:
39     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
40    
41     Template Parameters:     Template Parameters:
42     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
43     template must satisfy     template must satisfy.
44  */  */
45    
46  class DataExpanded : public DataAbstract{  class DataExpanded : public DataAbstract {
47    
48   public:   public:
49    
50    /**    /**
51       \brief       \brief
52       Copy constructor for DataExpanded. Performs a deep copy.       Constructor for DataExpanded.
   */  
   DataExpanded(const DataExpanded& other);  
53    
54    /**       Description:
55       \brief       Constructor for DataExpanded.
      Construct a DataExpanded from a DataConstant  
   */  
   DataExpanded(const DataConstant& other);  
56    
57    /**       The given single data value is copied to all the data points in
58       \brief       this data object, where the number of data points is defined by
59       Construct a DataExpanded from a DataTagged       the given function space.
60    
61         \param value - Input - A single data value.
62         \param what - Input - A description of what this data represents.
63    */    */
64    DataExpanded(const DataTagged& other);    DataExpanded(const boost::python::numeric::array& value,
65                   const FunctionSpace& what);
66    
67    /**    /**
68       \brief       \brief
69       Constructor for DataExpanded       Alternative constructor for DataExpanded.
70    
71       Description:       Description:
72       Constructor for DataExpanded       Alternative Constructor for DataExpanded.
73       \param value - Input - Data value for a single point.  
74         The given single data value is copied to all the data points in
75         this data object, where the number of data points is defined by
76         the given function space.
77    
78         \param value - Input - A single data value.
79       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
80    */    */
81    DataExpanded(const boost::python::numeric::array& value, const FunctionSpace& what);    DataExpanded(const DataArrayView& value,
82                   const FunctionSpace& what);
83    
84    /**    /**
85       \brief       \brief
86       Alternative constructor for DataExpanded       Alternative constructor for DataExpanded that copies a slice from
87         another DataExpanded.
88    
89       Description:       \param other - Input - DataExpanded object to slice from.
90       Alternative Constructor for DataExpanded       \param region - Input - region to copy.
91       \param value - Input - Data value for a single point.    */
92       \param what - Input - A description of what this data represents.    DataExpanded(const DataExpanded& other,
93                   const DataArrayView::RegionType& region);
94    
95      /**
96         \brief
97         Copy constructor for DataExpanded.
98         Performs a deep copy from another DataExpanded.
99    */    */
100    DataExpanded(const DataArrayView& value, const FunctionSpace& what);    DataExpanded(const DataExpanded& other);
101    
102    /**    /**
103       \brief       \brief
104       Alternative constructor for DataExpanded that copies a slice from       Copy constructor for DataExpanded.
105       another DataExpanded.       Construct a DataExpanded from a DataConstant.
106      */
107      DataExpanded(const DataConstant& other);
108    
109       \param other - Input - DataExpanded object to slice from    /**
110       \param region - Input - region to copy       \brief
111         Copy constructor for DataExpanded.
112         Construct a DataExpanded from a DataTagged.
113    */    */
114    DataExpanded(const DataExpanded& other, const DataArrayView::RegionType& region);    DataExpanded(const DataTagged& other);
115    
116    /**    /**
117       \brief       \brief
118       Destructor       Default destructor for DataExpanded.
119    */    */
120    virtual ~DataExpanded();    virtual
121      ~DataExpanded();
122    
123    /**    /**
124       \brief       \brief
125       Return a textual representation of the data       Return a textual representation of the data.
126    */    */
127    virtual std::string toString() const;    virtual
128      std::string
129      toString() const;
130    
131    /**    /**
132       \brief       \brief
# Line 112  class DataExpanded : public DataAbstract Line 134  class DataExpanded : public DataAbstract
134       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
135       data point.       data point.
136    */    */
137    void reshapeDataPoint(const DataArrayView::ShapeType& shape);    void
138      reshapeDataPoint(const DataArrayView::ShapeType& shape);
139    
140    /**    /**
141       \brief       \brief
142       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
143       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
144       holding the point data.       holding the point data.
145       \param sampleNo - Input - number of samples.  
146       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
147         \param dataPointNo - Input - data point number.
148    */    */
149    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    virtual
150      DataArrayView::ValueType::size_type
151      getPointOffset(int sampleNo,
152                     int dataPointNo) const;
153    
154    /**    /**
155       \brief       \brief
156       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
157    
158       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
159       operation       operation.
160       \param sampleNo - Input  
161       \param dataPointNo - Input       \param sampleNo - Input - sample number.
162       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
163         \return DataArrayView for the data point.
164    */    */
165    DataArrayView getDataPoint(int sampleNo, int dataPointNo);    DataArrayView
166      getDataPoint(int sampleNo,
167                   int dataPointNo);
168    
169    /**    /**
170       \brief       \brief
171       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data.
172    */    */
173    virtual ValueType::size_type getLength() const;    virtual
174      ValueType::size_type
175      getLength() const;
176    
177    /**    /**
178       \brief       \brief
179       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
180       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
181    
182       \param region - Input - Region to copy.       \param region - Input - Region to copy.
183    */    */
184    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;    virtual
185      DataAbstract*
186      getSlice(const DataArrayView::RegionType& region) const;
187    
188    /**    /**
189       \brief       \brief
190       Copy the specified region from the given value.       Copy the specified region from the given value.
191       \param value - Input - Data to copy from  
192         \param value - Input - Data object to copy from.
193       \param region - Input - Region to copy.       \param region - Input - Region to copy.
194    */    */
195    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    virtual
196      void
197      setSlice(const DataAbstract* value,
198               const DataArrayView::RegionType& region);
199    
200      /**
201         \brief
202         Assign the given value to all data-points associated with the given
203         reference number.
204    
205         A reference number corresponds to a sample, and thus to all data-points
206         in that sample.
207    
208         If the given reference number does not correspond to any sample in this
209         Data object, an exception will be thrown.
210    
211         If the given value is a different shape to this Data object, an exception
212         will be thrown.
213    
214         \param ref - Input - reference number which determines sample numebr to
215                              assign given values to.
216         \param value - Input - Value to assign to data-point associated with
217                                the given reference number.
218      */
219      virtual
220      void
221      setRefValue(int ref,
222                  const DataArray& value);
223    
224      /**
225         \brief
226         Return the value of the first data-point in the sample associated with
227         the given reference number.
228    
229         A reference number corresponds to a sample, and thus to all data-points
230         in that sample. If there is more than one data-point per sample number
231         in this Data object, the value of the first data-point will be returned.
232    
233         If the given reference number does not correspond to any sample in this
234         Data object, an exception will be thrown.
235    
236         If the given value is a different shape to this Data object, an exception
237         will be thrown.
238    
239         \param ref - Input - reference number which determines sample number to
240                              read from.
241         \param value - Output - Object to receive data-points associated with
242                                the given reference number.
243      */
244      virtual
245      void
246      getRefValue(int ref,
247                  DataArray& value);
248    
249   protected:   protected:
250    
# Line 163  class DataExpanded : public DataAbstract Line 252  class DataExpanded : public DataAbstract
252    
253    /**    /**
254       \brief       \brief
255       Common initialisation called from constructors       Common initialisation called from constructors.
256    
257       Description:       Description:
258       Common initialisation called from constructors       Common initialisation called from constructors.
259    
260         Resizes the underlying data array to provide sufficient storage for the
261         given shape and number of data points, and creates the corresponding
262         DataArrayView of this data.
263    
264       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
265       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
266       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
267    */    */
268    void initialise(const DataArrayView::ShapeType& shape, int noSamples, int noDataPointsPerSample);    void
269      initialise(const DataArrayView::ShapeType& shape,
270                 int noSamples,
271                 int noDataPointsPerSample);
272    
273    /**    /**
274       \brief       \brief
275       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
276    
277       Description:       Description:
278       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
279       \param value Input - Value for a single data point  
280         \param value Input - A single data point value.
281    */    */
282    void copy(const DataArrayView& value);    void
283    void copy(const boost::python::numeric::array& value);    copy(const DataArrayView& value);
284    
285      void
286      copy(const boost::python::numeric::array& value);
287    
288    //    //
289    // The main data storage, a 2D array of data blocks    // The main data storage array, a 2D array of data blocks.
290      // noSamples * noDataPointsPerSample
291    DataBlocks2D m_data;    DataBlocks2D m_data;
292    
293  };  };
294    
295  } // end of namespace  } // end of namespace
 #endif  
   
   
   
296    
297    #endif

Legend:
Removed from v.82  
changed lines
  Added in v.117

  ViewVC Help
Powered by ViewVC 1.1.26