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

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

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

trunk/esys2/escript/src/Data/DataAbstract.h revision 106 by jgs, Thu Dec 23 07:20:12 2004 UTC trunk/escript/src/Data/DataAbstract.h revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC
# Line 18  Line 18 
18    
19  #include "escript/Data/DataException.h"  #include "escript/Data/DataException.h"
20  #include "escript/Data/DataArrayView.h"  #include "escript/Data/DataArrayView.h"
21    #include "escript/Data/DataArray.h"
22  #include "escript/Data/FunctionSpace.h"  #include "escript/Data/FunctionSpace.h"
23    
24  #include <iostream>  #include <iostream>
25    #include <fstream>
26  #include <boost/scoped_ptr.hpp>  #include <boost/scoped_ptr.hpp>
27  #include <functional>  #include <functional>
28  #include <string>  #include <string>
# Line 29  namespace escript { Line 31  namespace escript {
31    
32  /**  /**
33     \brief     \brief
34     DataAbstract provides an interface for the class of containers     DataAbstract provides an abstract interface for the class of containers
35     which hold ESyS data.     which hold ESyS data.
36    
37     Description:     Description:
38     DataAbstract provides an interface for the class of containers     DataAbstract provides an abstract interface for the class of containers
39     which hold ESyS data. The container may be thought of as a 2 dimensional     which hold ESyS data. The container may be thought of as a 2 dimensional
40     array of data points. The data points themselves are arrays of rank 0-4.     array of data points where one dimension corresponds to the number of samples
41       and the other to the number of data points per sample as defined by the function
42       space associated with each Data object. The data points themselves are arrays of
43       doubles of rank 0-4.
44  */  */
45    
46  class DataAbstract {  class DataAbstract {
# Line 51  class DataAbstract { Line 56  class DataAbstract {
56    
57       Description:       Description:
58       Constructor for DataAbstract.       Constructor for DataAbstract.
59    
60       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
61    */    */
62    DataAbstract(const FunctionSpace& what);    DataAbstract(const FunctionSpace& what);
# Line 90  class DataAbstract { Line 96  class DataAbstract {
96       the shape information for each data point although it also may be used       the shape information for each data point although it also may be used
97       to manipulate the point data.       to manipulate the point data.
98    */    */
   const DataArrayView&  
   getPointDataView() const;  
   
99    DataArrayView&    DataArrayView&
100    getPointDataView();    getPointDataView();
101    
102      const DataArrayView&
103      getPointDataView() const;
104    
105    /**    /**
106       \brief       \brief
107       Return the offset for the given sample. This is somewhat artificial notion       Return the offset for the given sample. This returns the offset for the given
108       but returns the offset for the given point into the container       point into the container holding the point data. Only really necessary to
109       holding the point data. Only really necessary to avoid many DataArrayView       avoid creating many DataArrayView objects.
110       objects.  
111       \param sampleNo - Input - sample number.       \param sampleNo - Input - sample number.
112       \param dataPointNo - Input - Input.       \param dataPointNo - Input - data point number.
113     */     */
114    virtual    virtual
115    ValueType::size_type    ValueType::size_type
# Line 112  class DataAbstract { Line 118  class DataAbstract {
118    
119    /**    /**
120       \brief       \brief
121       Return the sample data for the given sample no.       Return the sample data for the given sample number.
122    */    */
123    double*    double*
124    getSampleData(ValueType::size_type sampleNo);    getSampleData(ValueType::size_type sampleNo);
125    
126    /**    /**
127       \brief       \brief
128       Return the number of doubles stored for the Data.       Return the number of doubles stored for this Data object.
129    */    */
130    virtual    virtual
131    ValueType::size_type    ValueType::size_type
# Line 136  class DataAbstract { Line 142  class DataAbstract {
142    
143    /**    /**
144       \brief       \brief
145       Check this and the right operands are compatible. Throws       Assign the given value to the data-points(s) referenced by the given
146         reference number.
147    
148         If this Data object cannot be accessed by reference numbers an
149         exception will be thrown.
150    
151         \param ref - Input - reference number.
152         \param value - Input - value to assign to data-points associated with
153                                the given reference number.
154      */
155      virtual
156      void
157      setRefValue(int ref,
158                  const DataArray& value);
159    
160      /**
161         \brief
162         Return the values associated with the data-point(s) referenced by the given
163         reference number.
164    
165         If this Data object cannot be accessed by reference numbers an
166         exception will be thrown.
167    
168         \param ref - Input - reference number.
169         \param value - Output - object to receive data-points associated with
170                                 the given reference number.
171      */
172      virtual
173      void
174      getRefValue(int ref,
175                  DataArray& value);
176    
177      /**
178         \brief
179         Check this and the given RHS operands are compatible. Throws
180       an exception if they aren't.       an exception if they aren't.
181    
182       \param right - Input - The right hand side.       \param right - Input - The right hand side.
183    */    */
184    void    void
# Line 152  class DataAbstract { Line 193  class DataAbstract {
193    
194    /**    /**
195       \brief       \brief
196       Return true if a valid number.       Return true if a valid sample number.
197    */    */
198    bool    bool
199    validSampleNo(int sampleNo) const;    validSampleNo(int sampleNo) const;
# Line 162  class DataAbstract { Line 203  class DataAbstract {
203       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
204       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
205       operation.       operation.
206       \param samplesNo Input  
207       \param dataPointNo Input       \param sampleNo - Input - the sample number.
208         \param dataPointNo - Input - the data point number.
209    */    */
210    virtual    virtual
211    DataArrayView    DataArrayView
212    getDataPoint(int samplesNo,    getDataPoint(int sampleNo,
213                 int dataPointNo) = 0;                 int dataPointNo) = 0;
214    
215    /**    /**
216       \brief       \brief
217       Return the function space.       Return the function space associated with this Data object.
218    */    */
219    const FunctionSpace&    const
220      FunctionSpace&
221    getFunctionSpace() const;    getFunctionSpace() const;
222    
223    /**    /**
224       \brief       \brief
225       Return a newly constructed DataAbstract. The caller is responsible for       Return the given slice from this object.
226       managing the object created.  
227         NB: The caller is responsible for managing the object created.
228    */    */
229    virtual    virtual
230    DataAbstract*    DataAbstract*
# Line 188  class DataAbstract { Line 232  class DataAbstract {
232    
233    /**    /**
234       \brief       \brief
235       Copy the specified region from the given value.       Copy the specified region from the given object.
236    
237       \param value - Input - Data to copy from       \param value - Input - Data to copy from
238       \param region - Input - Region to copy.       \param region - Input - Region to copy.
239    */    */
# Line 199  class DataAbstract { Line 244  class DataAbstract {
244    
245    /**    /**
246       \brief       \brief
247       Reshape the data point if the data point is currently rank 0.       Reshape the data points if they are currently rank 0.
248       Will throw an exception if the data points are not rank 0.       Will throw an exception if the data points are not rank 0.
249       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
250       data point.       data point.
251    */    */
252    virtual    virtual
253    void    void
254    reshapeDataPoint(const DataArrayView::ShapeType& shape) = 0;    reshapeDataPoint(const ShapeType& shape) = 0;
255    
256    /**    /**
257       \brief       \brief
# Line 214  class DataAbstract { Line 259  class DataAbstract {
259                                                                                                                                                                                                                                                                        
260       Description:       Description:
261       Assign the given value to the given tag.       Assign the given value to the given tag.
262    
263         NB: If the data isn't tagged an exception will be thrown.
264    
265       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
266       \param value - Input - Single DataArrayView value to be assigned to the tag.       \param value - Input - Single DataArrayView value to be assigned to the tag.
      NB: If the data isn't tagged an exception will be thrown.  
267    */    */
268    virtual    virtual
269    void    void
270    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
271                   const DataArrayView& value);                   const DataArrayView& value);
272    
273      /**
274        \brief
275        Archive the underlying data values to the file referenced
276        by ofstream. A count of the number of values expected to be written
277        is provided as a cross-check.
278    
279        The return value indicates success (0) or otherwise (1).
280      */
281      virtual
282      int
283      archiveData(std::ofstream& archiveFile,
284                  const ValueType::size_type noValues) const;
285    
286      /**
287        \brief
288        Extract the number of values specified by noValues from the file
289        referenced by ifstream to the underlying data structure.
290    
291        The return value indicates success (0) or otherwise (1).
292      */
293      virtual
294      int
295      extractData(std::ifstream& archiveFile,
296                  const ValueType::size_type noValues);
297    
298      /**
299         \brief
300         Copy the numarray object to the data points in this object.
301    
302         Description:
303         Copy the numarray object to the data points in this object.
304    
305         \param value Input - new values for the data points
306      */
307      virtual void
308      copyAll(const boost::python::numeric::array& value);
309    
310      /**
311         \brief
312         Return the tag number associated with the given data-point number.
313    
314         If the object cannot be referenced by tag numbers, an exception
315         will be thrown.
316      */
317      virtual
318      int
319      getTagNumber(int dpno);
320    
321   protected:   protected:
322    
323    /**    /**
324       \brief       \brief
325       Set the pointDataView       Set the pointDataView DataArrayView associated with this object.
326       \param right - Input - The point data view. DataAbstract takes ownership  
327         \param input - Input - The point data view. DataAbstract takes ownership
328       of the DataArrayView provided. It will delete it when it is destructed.       of the DataArrayView provided. It will delete it when it is destructed.
329    */    */
330    void    void
331    setPointDataView(const DataArrayView& input);    setPointDataView(const DataArrayView& input);
332    
333   private:    void
334      resetPointDataView();
335    
336    int m_noDataPointsPerSample;   private:
337    
338      //
339      // The number of samples in this Data object.
340      // This is derived directly from the FunctionSpace.
341    int m_noSamples;    int m_noSamples;
342    
343    //    //
344    // Provides a view of the data as point data    // The number of data points per sample in this Data object.
345      // This is derived directly from the FunctionSpace.
346      int m_noDataPointsPerSample;
347    
348      //
349      // The DataArrayView of the data array associated with this object.
350      // The data array is defined only in child classes of this class, it
351      // is not defined in this abstract parent class.
352    boost::scoped_ptr<DataArrayView> m_pointDataView;    boost::scoped_ptr<DataArrayView> m_pointDataView;
353    
354    //    //
355    // function space    // A FunctionSpace which provides a description of the data associated
356      // with this Data object.
357    FunctionSpace m_functionSpace;    FunctionSpace m_functionSpace;
358    
359  };  };
# Line 309  DataAbstract::getPointDataView() Line 417  DataAbstract::getPointDataView()
417  }  }
418    
419  } // end of namespace  } // end of namespace
420    
421  #endif  #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26