/[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 110 by jgs, Mon Feb 14 04:14:42 2005 UTC trunk/escript/src/DataExpanded.h revision 580 by gross, Wed Mar 8 05:45:51 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 180  class DataExpanded : public DataAbstract Line 211  class DataExpanded : public DataAbstract
211    
212    /**    /**
213       \brief       \brief
214       Assign the given value to the data-point associated with the given       Assign the given value to all data-points associated with the given
215       reference number.       reference number.
216    
217       A reference number corresponds to a sample, and thus to all data-points       A reference number corresponds to a sample, and thus to all data-points
218       in that sample. If there is more than one data-point per sample number       in that sample.
219       in this Data object, an exception will be thrown. If the given reference  
220       number does not correspond to any sample in this Data object, an exception       If the given reference number does not correspond to any sample in this
221       will be thrown.       Data object, an exception will be thrown.
222    
223       If the given value is a different shape to this Data object, an exception       If the given value is a different shape to this Data object, an exception
224       will be thrown.       will be thrown.
225    
226       \param ref - Input - reference number which determines data-point to assign to.       \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       \param value - Input - Value to assign to data-point associated with
229                              the given reference number.                              the given reference number.
230    */    */
# Line 203  class DataExpanded : public DataAbstract Line 235  class DataExpanded : public DataAbstract
235    
236    /**    /**
237       \brief       \brief
238       Return the value of the data-point associated with the given       Return the value of the first data-point in the sample associated with
239       reference number.       the given reference number.
240    
241       A reference number corresponds to a sample, and thus to all data-points       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       in that sample. If there is more than one data-point per sample number
243       in this Data object, an exception will be thrown. If the given reference       in this Data object, the value of the first data-point will be returned.
244       number does not correspond to any sample in this Data object, an exception  
245       will be thrown.       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       If the given value is a different shape to this Data object, an exception
249       will be thrown.       will be thrown.
250    
251       \param ref - Input - reference number which determines data-point to read from.       \param ref - Input - reference number which determines sample number to
252                              read from.
253       \param value - Output - Object to receive data-points associated with       \param value - Output - Object to receive data-points associated with
254                              the given reference number.                              the given reference number.
255    */    */
# Line 224  class DataExpanded : public DataAbstract Line 258  class DataExpanded : public DataAbstract
258    getRefValue(int ref,    getRefValue(int ref,
259                DataArray& value);                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      /**
285         \brief
286         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
287    
288         \param ev - Output - eigenvalues in increasing order at each data point
289    
290      */
291      virtual void
292      eigenvalues(DataAbstract* ev);
293    
294      /**
295         \brief
296         solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
297    
298         \param ev - Output - eigenvalues in increasing order at each data point
299         \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
300                             and the first nonzero component is positive.
301         \param tol - Input - eigenvalue with relative distance tol are treated as equal.
302    
303      */
304    
305      virtual void
306      eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
307    
308    
309   protected:   protected:
310    
311   private:   private:
312    
313    /**    /**
314       \brief       \brief
315       Common initialisation called from constructors       Common initialisation called from constructors.
316    
317       Description:       Description:
318       Common initialisation called from constructors       Common initialisation called from constructors.
319    
320         Resizes the underlying data array to provide sufficient storage for the
321         given shape and number of data points, and creates the corresponding
322         DataArrayView of this data.
323    
324       \param shape - Input - The shape of the point data.       \param shape - Input - The shape of the point data.
325       \param noSamples - Input - number of samples.       \param noSamples - Input - number of samples.
326       \param noDataPointsPerSample - Input -       \param noDataPointsPerSample - Input - number of data points per sample.
327    */    */
328    void    void
329    initialise(const DataArrayView::ShapeType& shape,    initialise(const DataArrayView::ShapeType& shape,
# Line 245  class DataExpanded : public DataAbstract Line 332  class DataExpanded : public DataAbstract
332    
333    /**    /**
334       \brief       \brief
335       Copy the given data point to all data points.       Copy the given data point value to all data points in this object.
336    
337       Description:       Description:
338       Copy the given data point to all data points.       Copy the given data point to all data points in this object.
339       \param value Input - Value for a single data point.  
340         \param value Input - A single data point value.
341    */    */
342    void    void
343    copy(const DataArrayView& value);    copy(const DataArrayView& value);
344    
345      /**
346         \brief
347         Copy the given data point value given a numarray object to all data points in this object.
348    
349         Description:
350         Copy the given data point value given a numarray object to all data points in this object.
351    
352         \param value Input - A single data point value.
353      */
354    void    void
355    copy(const boost::python::numeric::array& value);    copy(const boost::python::numeric::array& value);
356    
357      /**
358         \brief
359         Copy the numarray object to the data points in this object.
360    
361         Description:
362         Copy the numarray object to the data points in this object.
363    
364         \param value Input - new values for the data points
365      */
366      void
367      copyAll(const boost::python::numeric::array& value);
368    
369    //    //
370    // The main data storage, a 2D array of data blocks.    // The main data storage array, a 2D array of data blocks.
371      // noSamples * noDataPointsPerSample
372    DataBlocks2D m_data;    DataBlocks2D m_data;
373    
374  };  };

Legend:
Removed from v.110  
changed lines
  Added in v.580

  ViewVC Help
Powered by ViewVC 1.1.26