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

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

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

trunk/esys2/escript/src/Data/DataExpanded.h revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC trunk/escript/src/DataExpanded.h revision 480 by jgs, Wed Feb 1 05:15:12 2006 UTC
# Line 12  Line 12 
12   *                                                                            *   *                                                                            *
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    
# Line 20  Line 20 
20  #include "DataBlocks2D.h"  #include "DataBlocks2D.h"
21  #include "DataArrayView.h"  #include "DataArrayView.h"
22    
 #include <boost/scoped_ptr.hpp>  
23  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
24    
25  namespace escript {  namespace escript {
26    
27  class DataEmpty;  //
28    // Forward declarations of other Data types.
29  class DataConstant;  class DataConstant;
30  class DataTagged;  class DataTagged;
31    
# Line 34  class DataTagged; Line 34  class DataTagged;
34     Give a short description of what DataExpanded does.     Give a short description of what DataExpanded does.
35    
36     Description:     Description:
37     Give a detailed description of DataExpanded     Give a detailed description of DataExpanded.
38    
39     Template Parameters:     Template Parameters:
40     For templates describe any conditions that the parameters used in the     For templates describe any conditions that the parameters used in the
41     template must satisfy     template must satisfy.
42  */  */
43    
44  class DataExpanded : public DataAbstract{  class DataExpanded : public DataAbstract {
45    
46   public:   public:
47    
48    /**    /**
49       \brief       \brief
50       Copy constructor for DataExpanded. Performs a deep copy.       Constructor for DataExpanded.
   */  
   DataExpanded(const DataExpanded& other);  
   
   /**  
      \brief  
      Construct a DataExpanded from a DataConstant.  
   */  
   DataExpanded(const DataConstant& other);  
51    
52    /**       Description:
53       \brief       Constructor for DataExpanded.
      Construct a DataExpanded from a DataTagged.  
   */  
   DataExpanded(const DataTagged& other);  
54    
55    /**       The given single data value is copied to all the data points in
56       \brief       this data object, where the number of data points is defined by
57       Constructor for DataExpanded       the given function space.
58    
59       Description:       \param value - Input - A single data value.
      Constructor for DataExpanded  
      \param value - Input - Data value for a single point.  
60       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
61    */    */
62    DataExpanded(const boost::python::numeric::array& value,    DataExpanded(const boost::python::numeric::array& value,
# Line 77  class DataExpanded : public DataAbstract Line 64  class DataExpanded : public DataAbstract
64    
65    /**    /**
66       \brief       \brief
67       Alternative constructor for DataExpanded       Alternative constructor for DataExpanded.
68    
69       Description:       Description:
70       Alternative Constructor for DataExpanded.       Alternative Constructor for DataExpanded.
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data represents.  
71    
72         The given single data value is copied to all the data points in
73         this data object, where the number of data points is defined by
74         the given function space.
75    
76         \param value - Input - A single data value.
77         \param what - Input - A description of what this data represents.
78    */    */
79    DataExpanded(const DataArrayView& value,    DataExpanded(const DataArrayView& value,
80                 const FunctionSpace& what);                 const FunctionSpace& what);
# Line 101  class DataExpanded : public DataAbstract Line 92  class DataExpanded : public DataAbstract
92    
93    /**    /**
94       \brief       \brief
95       Destructor       Alternative constructor for DataExpanded objects.
96    
97         Description:
98         Alternative Constructor for DataExpanded objects.
99         \param what - Input - A description of what this data object represents.
100         \param shape - Input - the shape of each data-point.
101         \param data - the array of data values for the data-points.
102      */
103      DataExpanded(const FunctionSpace& what,
104                   const DataArrayView::ShapeType &shape,
105                   const DataArrayView::ValueType &data);
106    
107      /**
108         \brief
109         Copy constructor for DataExpanded.
110         Performs a deep copy from another DataExpanded.
111      */
112      DataExpanded(const DataExpanded& other);
113    
114      /**
115         \brief
116         Copy constructor for DataExpanded.
117         Construct a DataExpanded from a DataConstant.
118      */
119      DataExpanded(const DataConstant& other);
120    
121      /**
122         \brief
123         Copy constructor for DataExpanded.
124         Construct a DataExpanded from a DataTagged.
125      */
126      DataExpanded(const DataTagged& other);
127    
128      /**
129         \brief
130         Default destructor for DataExpanded.
131    */    */
132    virtual    virtual
133    ~DataExpanded();    ~DataExpanded();
134    
135    /**    /**
136       \brief       \brief
137       Return a textual representation of the data       Return a textual representation of the data.
138    */    */
139    virtual    virtual
140    std::string    std::string
# Line 125  class DataExpanded : public DataAbstract Line 151  class DataExpanded : public DataAbstract
151    
152    /**    /**
153       \brief       \brief
154       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
155       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
156       holding the point data.       holding the point data.
157       \param sampleNo - Input - number of samples.  
158       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
159         \param dataPointNo - Input - data point number.
160    */    */
161    virtual    virtual
162    DataArrayView::ValueType::size_type    DataArrayView::ValueType::size_type
# Line 138  class DataExpanded : public DataAbstract Line 165  class DataExpanded : public DataAbstract
165    
166    /**    /**
167       \brief       \brief
168       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
169    
170       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
171       operation.       operation.
172       \param sampleNo - Input  
173       \param dataPointNo - Input       \param sampleNo - Input - sample number.
174       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
175         \return DataArrayView for the data point.
176    */    */
177    DataArrayView    DataArrayView
178    getDataPoint(int sampleNo,    getDataPoint(int sampleNo,
# Line 161  class DataExpanded : public DataAbstract Line 190  class DataExpanded : public DataAbstract
190       \brief       \brief
191       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
192       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
193    
194       \param region - Input - Region to copy.       \param region - Input - Region to copy.
195    */    */
196    virtual    virtual
# Line 170  class DataExpanded : public DataAbstract Line 200  class DataExpanded : public DataAbstract
200    /**    /**
201       \brief       \brief
202       Copy the specified region from the given value.       Copy the specified region from the given value.
203       \param value - Input - Data to copy from  
204         \param value - Input - Data object to copy from.
205       \param region - Input - Region to copy.       \param region - Input - Region to copy.
206    */    */
207    virtual    virtual
# Line 178  class DataExpanded : public DataAbstract Line 209  class DataExpanded : public DataAbstract
209    setSlice(const DataAbstract* value,    setSlice(const DataAbstract* value,
210             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
211    
212      /**
213         \brief
214         Assign the given value to all data-points associated with the given
215         reference number.
216    
217         A reference number corresponds to a sample, and thus to all data-points
218         in that sample.
219    
220         If the given reference number does not correspond to any sample in this
221         Data object, an exception will be thrown.
222    
223         If the given value is a different shape to this Data object, an exception
224         will be thrown.
225    
226         \param ref - Input - reference number which determines sample numebr to
227                              assign given values to.
228         \param value - Input - Value to assign to data-point associated with
229                                the given reference number.
230      */
231      virtual
232      void
233      setRefValue(int ref,
234                  const DataArray& value);
235    
236      /**
237         \brief
238         Return the value of the first data-point in the sample associated with
239         the given reference number.
240    
241         A reference number corresponds to a sample, and thus to all data-points
242         in that sample. If there is more than one data-point per sample number
243         in this Data object, the value of the first data-point will be returned.
244    
245         If the given reference number does not correspond to any sample in this
246         Data object, an exception will be thrown.
247    
248         If the given value is a different shape to this Data object, an exception
249         will be thrown.
250    
251         \param ref - Input - reference number which determines sample number to
252                              read from.
253         \param value - Output - Object to receive data-points associated with
254                                the given reference number.
255      */
256      virtual
257      void
258      getRefValue(int ref,
259                  DataArray& value);
260    
261      /**
262        \brief
263        Archive the underlying data values to the file referenced
264        by ofstream. A count of the number of values expected to be written
265        is provided as a cross-check.
266    
267        The return value indicates success (0) or otherwise (1).
268      */
269      int
270      archiveData(std::ofstream& archiveFile,
271                  const DataArrayView::ValueType::size_type noValues) const;
272    
273      /**
274        \brief
275        Extract the number of values specified by noValues from the file
276        referenced by ifstream to the underlying data structure.
277    
278        The return value indicates success (0) or otherwise (1).
279      */
280      int
281      extractData(std::ifstream& archiveFile,
282                  const DataArrayView::ValueType::size_type noValues);
283    
284   protected:   protected:
285    
286   private:   private:
287    
288    /**    /**
289       \brief       \brief
290       Common initialisation called from constructors       Common initialisation called from constructors.
291    
292       Description:       Description:
293       Common initialisation called from constructors       Common initialisation called from constructors.
294    
295         Resizes the underlying data array to provide sufficient storage for the
296         given shape and number of data points, and creates the corresponding
297         DataArrayView of this data.
298    
299       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
300       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
301       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
302    */    */
303    void    void
304    initialise(const DataArrayView::ShapeType& shape,    initialise(const DataArrayView::ShapeType& shape,
# Line 199  class DataExpanded : public DataAbstract Line 307  class DataExpanded : public DataAbstract
307    
308    /**    /**
309       \brief       \brief
310       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
311    
312       Description:       Description:
313       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
314       \param value Input - Value for a single data point.  
315         \param value Input - A single data point value.
316    */    */
317    void    void
318    copy(const DataArrayView& value);    copy(const DataArrayView& value);
319    
320      /**
321         \brief
322         Copy the given data point value given a numarray object to all data points in this object.
323    
324         Description:
325         Copy the given data point value given a numarray object to all data points in this object.
326    
327         \param value Input - A single data point value.
328      */
329    void    void
330    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
331    
332      /**
333         \brief
334         Copy the numarray object to the data points in this object.
335    
336         Description:
337         Copy the numarray object to the data points in this object.
338    
339         \param value Input - new values for the data points
340      */
341      void
342      copyAll(const boost::python::numeric::array& value);
343    
344    //    //
345    // The main data storage, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
346      // noSamples * noDataPointsPerSample
347    DataBlocks2D m_data;    DataBlocks2D m_data;
348    
349  };  };

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

  ViewVC Help
Powered by ViewVC 1.1.26