/[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 82 by jgs, Tue Oct 26 06:53:54 2004 UTC trunk/escript/src/Data/DataExpanded.h revision 155 by jgs, Wed Nov 9 02:02:19 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.
53    
54         Description:
55         Constructor for DataExpanded.
56    
57         The given single data value is copied to all the data points in
58         this data object, where the number of data points is defined by
59         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 DataExpanded& other);    DataExpanded(const boost::python::numeric::array& value,
65                   const FunctionSpace& what);
66    
67    /**    /**
68       \brief       \brief
69       Construct a DataExpanded from a DataConstant       Alternative constructor for DataExpanded.
70    
71         Description:
72         Alternative Constructor for DataExpanded.
73    
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.
80    */    */
81    DataExpanded(const DataConstant& other);    DataExpanded(const DataArrayView& value,
82                   const FunctionSpace& what);
83    
84    /**    /**
85       \brief       \brief
86       Construct a DataExpanded from a DataTagged       Alternative constructor for DataExpanded that copies a slice from
87         another DataExpanded.
88    
89         \param other - Input - DataExpanded object to slice from.
90         \param region - Input - region to copy.
91    */    */
92    DataExpanded(const DataTagged& other);    DataExpanded(const DataExpanded& other,
93                   const DataArrayView::RegionType& region);
94    
95    /**    /**
96       \brief       \brief
97       Constructor for DataExpanded       Alternative constructor for DataExpanded objects.
98    
99       Description:       Description:
100       Constructor for DataExpanded       Alternative Constructor for DataExpanded objects.
101       \param value - Input - Data value for a single point.       \param what - Input - A description of what this data object represents.
102       \param what - Input - A description of what this data represents.       \param shape - Input - the shape of each data-point.
103         \param data - the array of data values for the data-points.
104    */    */
105    DataExpanded(const boost::python::numeric::array& value, const FunctionSpace& what);    DataExpanded(const FunctionSpace& what,
106                   const DataArrayView::ShapeType &shape,
107                   const DataArrayView::ValueType &data);
108    
109    /**    /**
110       \brief       \brief
111       Alternative constructor for DataExpanded       Copy constructor for DataExpanded.
112         Performs a deep copy from another DataExpanded.
      Description:  
      Alternative Constructor for DataExpanded  
      \param value - Input - Data value for a single point.  
      \param what - Input - A description of what this data represents.  
   
113    */    */
114    DataExpanded(const DataArrayView& value, const FunctionSpace& what);    DataExpanded(const DataExpanded& other);
115    
116    /**    /**
117       \brief       \brief
118       Alternative constructor for DataExpanded that copies a slice from       Copy constructor for DataExpanded.
119       another DataExpanded.       Construct a DataExpanded from a DataConstant.
120      */
121      DataExpanded(const DataConstant& other);
122    
123       \param other - Input - DataExpanded object to slice from    /**
124       \param region - Input - region to copy       \brief
125         Copy constructor for DataExpanded.
126         Construct a DataExpanded from a DataTagged.
127    */    */
128    DataExpanded(const DataExpanded& other, const DataArrayView::RegionType& region);    DataExpanded(const DataTagged& other);
129    
130    /**    /**
131       \brief       \brief
132       Destructor       Default destructor for DataExpanded.
133    */    */
134    virtual ~DataExpanded();    virtual
135      ~DataExpanded();
136    
137    /**    /**
138       \brief       \brief
139       Return a textual representation of the data       Return a textual representation of the data.
140    */    */
141    virtual std::string toString() const;    virtual
142      std::string
143      toString() const;
144    
145    /**    /**
146       \brief       \brief
# Line 112  class DataExpanded : public DataAbstract Line 148  class DataExpanded : public DataAbstract
148       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
149       data point.       data point.
150    */    */
151    void reshapeDataPoint(const DataArrayView::ShapeType& shape);    void
152      reshapeDataPoint(const DataArrayView::ShapeType& shape);
153    
154    /**    /**
155       \brief       \brief
156       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given given data point. This returns
157       but returns the offset in bytes for the given point into the container       the offset in bytes for the given point into the container
158       holding the point data.       holding the point data.
159       \param sampleNo - Input - number of samples.  
160       \param dataPointNo - Input - Input.       \param sampleNo - Input - sample number.
161         \param dataPointNo - Input - data point number.
162    */    */
163    virtual DataArrayView::ValueType::size_type getPointOffset(int sampleNo, int dataPointNo) const;    virtual
164      DataArrayView::ValueType::size_type
165      getPointOffset(int sampleNo,
166                     int dataPointNo) const;
167    
168    /**    /**
169       \brief       \brief
170       Return a view into the data for the data point specified.       Return a view into the data array for the data point specified.
171    
172       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
173       operation       operation.
174       \param sampleNo - Input  
175       \param dataPointNo - Input       \param sampleNo - Input - sample number.
176       \return DataArrayView of the data point.       \param dataPointNo - Input - data point number.
177         \return DataArrayView for the data point.
178    */    */
179    DataArrayView getDataPoint(int sampleNo, int dataPointNo);    DataArrayView
180      getDataPoint(int sampleNo,
181                   int dataPointNo);
182    
183    /**    /**
184       \brief       \brief
185       Return the number of doubles stored for the Data       Return the number of doubles stored for the Data.
186    */    */
187    virtual ValueType::size_type getLength() const;    virtual
188      ValueType::size_type
189      getLength() const;
190    
191    /**    /**
192       \brief       \brief
193       Factory method that returns a newly created DataExpanded.       Factory method that returns a newly created DataExpanded.
194       The caller is reponsible for managing the object created.       The caller is reponsible for managing the object created.
195    
196       \param region - Input - Region to copy.       \param region - Input - Region to copy.
197    */    */
198    virtual DataAbstract* getSlice(const DataArrayView::RegionType& region) const;    virtual
199      DataAbstract*
200      getSlice(const DataArrayView::RegionType& region) const;
201    
202    /**    /**
203       \brief       \brief
204       Copy the specified region from the given value.       Copy the specified region from the given value.
205       \param value - Input - Data to copy from  
206         \param value - Input - Data object to copy from.
207       \param region - Input - Region to copy.       \param region - Input - Region to copy.
208    */    */
209    virtual void setSlice(const DataAbstract* value, const DataArrayView::RegionType& region);    virtual
210      void
211      setSlice(const DataAbstract* value,
212               const DataArrayView::RegionType& region);
213    
214      /**
215         \brief
216         Assign the given value to all data-points associated with the given
217         reference number.
218    
219         A reference number corresponds to a sample, and thus to all data-points
220         in that sample.
221    
222         If the given reference number does not correspond to any sample in this
223         Data object, an exception will be thrown.
224    
225         If the given value is a different shape to this Data object, an exception
226         will be thrown.
227    
228         \param ref - Input - reference number which determines sample numebr to
229                              assign given values to.
230         \param value - Input - Value to assign to data-point associated with
231                                the given reference number.
232      */
233      virtual
234      void
235      setRefValue(int ref,
236                  const DataArray& value);
237    
238      /**
239         \brief
240         Return the value of the first data-point in the sample associated with
241         the given reference number.
242    
243         A reference number corresponds to a sample, and thus to all data-points
244         in that sample. If there is more than one data-point per sample number
245         in this Data object, the value of the first data-point will be returned.
246    
247         If the given reference number does not correspond to any sample in this
248         Data object, an exception will be thrown.
249    
250         If the given value is a different shape to this Data object, an exception
251         will be thrown.
252    
253         \param ref - Input - reference number which determines sample number to
254                              read from.
255         \param value - Output - Object to receive data-points associated with
256                                the given reference number.
257      */
258      virtual
259      void
260      getRefValue(int ref,
261                  DataArray& value);
262    
263      /**
264        \brief
265        Archive the underlying data values to the file referenced
266        by ofstream. A count of the number of values expected to be written
267        is provided as a cross-check.
268    
269        The return value indicates success (0) or otherwise (1).
270      */
271      int
272      archiveData(std::ofstream& archiveFile,
273                  const DataArrayView::ValueType::size_type noValues) const;
274    
275      /**
276        \brief
277        Extract the number of values specified by noValues from the file
278        referenced by ifstream to the underlying data structure.
279    
280        The return value indicates success (0) or otherwise (1).
281      */
282      int
283      extractData(std::ifstream& archiveFile,
284                  const DataArrayView::ValueType::size_type noValues);
285    
286   protected:   protected:
287    
# Line 163  class DataExpanded : public DataAbstract Line 289  class DataExpanded : public DataAbstract
289    
290    /**    /**
291       \brief       \brief
292       Common initialisation called from constructors       Common initialisation called from constructors.
293    
294       Description:       Description:
295       Common initialisation called from constructors       Common initialisation called from constructors.
296    
297         Resizes the underlying data array to provide sufficient storage for the
298         given shape and number of data points, and creates the corresponding
299         DataArrayView of this data.
300    
301       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
302       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
303       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
304    */    */
305    void initialise(const DataArrayView::ShapeType& shape, int noSamples, int noDataPointsPerSample);    void
306      initialise(const DataArrayView::ShapeType& shape,
307                 int noSamples,
308                 int noDataPointsPerSample);
309    
310    /**    /**
311       \brief       \brief
312       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
313    
314       Description:       Description:
315       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
316       \param value Input - Value for a single data point  
317         \param value Input - A single data point value.
318      */
319      void
320      copy(const DataArrayView& value);
321    
322      /**
323         \brief
324         Copy the given data point value given a numarray object to all data points in this object.
325    
326         Description:
327         Copy the given data point value given a numarray object to all data points in this object.
328    
329         \param value Input - A single data point value.
330      */
331      void
332      copy(const boost::python::numeric::array& value);
333    
334      /**
335         \brief
336         Copy the numarray object to the data points in this object.
337    
338         Description:
339         Copy the numarray object to the data points in this object.
340    
341         \param value Input - new values for the data points
342    */    */
343    void copy(const DataArrayView& value);    void
344    void copy(const boost::python::numeric::array& value);    copyAll(const boost::python::numeric::array& value);
345    
346    //    //
347    // The main data storage, a 2D array of data blocks    // The main data storage array, a 2D array of data blocks.
348      // noSamples * noDataPointsPerSample
349    DataBlocks2D m_data;    DataBlocks2D m_data;
350    
351  };  };
352    
353  } // end of namespace  } // end of namespace
 #endif  
   
   
   
354    
355    #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26