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

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

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

revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC revision 117 by jgs, Fri Apr 1 05:48:57 2005 UTC
# Line 23  Line 23 
23  #include "escript/Data/FunctionSpace.h"  #include "escript/Data/FunctionSpace.h"
24  #include "escript/Data/BinaryOp.h"  #include "escript/Data/BinaryOp.h"
25  #include "escript/Data/UnaryOp.h"  #include "escript/Data/UnaryOp.h"
26    #include "escript/Data/DataException.h"
27    
28  extern "C" {  extern "C" {
29  #include "escript/Data/DataC.h"  #include "escript/Data/DataC.h"
# Line 68  class Data { Line 69  class Data {
69    
70    public:    public:
71    
72      // These typedefs allow function names to be cast to pointers
73      // to functions of the appropriate type when calling unaryOp etc.
74    typedef double (*UnaryDFunPtr)(double);    typedef double (*UnaryDFunPtr)(double);
75    typedef double (*BinaryDFunPtr)(double,double);    typedef double (*BinaryDFunPtr)(double,double);
76    
# Line 220  class Data { Line 223  class Data {
223    
224    /**    /**
225       \brief       \brief
226         Return the values of all data-points in a single python numarray object.
227      */
228      boost::python::numeric::array
229      convertToNumArray();
230    
231      /**
232         \brief
233       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
234    */    */
235    escriptDataC    escriptDataC
# Line 397  class Data { Line 407  class Data {
407    
408    /**    /**
409       \brief       \brief
410         Assign the given value to the data-points referenced by the given
411         reference number.
412    
413         The value supplied is a python numarray object.  The data from this numarray
414         is unpacked into a DataArray, and this is used to set the corresponding
415         data-points in the underlying Data object.
416    
417         If the underlying Data object cannot be accessed via reference numbers, an
418         exception will be thrown.
419    
420         \param ref - Input - reference number.
421         \param value - Input - value to assign to data-points associated with
422                                the given reference number.
423      */
424      void
425      setRefValue(int ref,
426                  const boost::python::numeric::array& value);
427    
428      /**
429         \brief
430         Return the values associated with the data-points referenced by the given
431         reference number.
432    
433         The value supplied is a python numarray object. The data from the corresponding
434         data-points in this Data object are packed into the given numarray object.
435    
436         If the underlying Data object cannot be accessed via reference numbers, an
437         exception will be thrown.
438    
439         \param ref - Input - reference number.
440         \param value - Output - object to receive values from data-points
441                                 associated with the given reference number.
442      */
443      void
444      getRefValue(int ref,
445                  boost::python::numeric::array& value);
446    
447      /**
448         \brief
449       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
450       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
451       operation.       operation.
# Line 591  class Data { Line 640  class Data {
640    
641    /**    /**
642       \brief       \brief
643         Return the minimum absolute value of this Data object.
644      */
645      double
646      Linf() const;
647    
648      /**
649         \brief
650       Return the maximum value of this Data object.       Return the maximum value of this Data object.
651    */    */
652    double    double
# Line 643  class Data { Line 699  class Data {
699    /**    /**
700      \transpose      \transpose
701      Transpose each data point of this Data object around the given axis.      Transpose each data point of this Data object around the given axis.
702        --* not implemented yet *--
703    */    */
704    Data    Data
705    transpose(int axis) const;    transpose(int axis) const;
# Line 681  class Data { Line 738  class Data {
738    
739    /**    /**
740      \brief      \brief
741        writes the object to a file in the DX file format
742      */
743      void
744      saveDX(std::string fileName) const;
745    
746      /**
747        \brief
748        writes the object to a file in the VTK file format
749      */
750      void
751      saveVTK(std::string fileName) const;
752    
753      /**
754        \brief
755      Return the negation of each data point of this Data object.      Return the negation of each data point of this Data object.
756    */    */
757    Data    Data
# Line 823  class Data { Line 894  class Data {
894    /**    /**
895       \brief       \brief
896       Perform the specified reduction algorithm on every element of every data point in       Perform the specified reduction algorithm on every element of every data point in
897       this Data object and return the single double value result.       this Data object according to the given function and return the single value result.
898    */    */
899    template <class UnaryFunction>    template <class UnaryFunction>
900    inline    inline
# Line 832  class Data { Line 903  class Data {
903    
904    /**    /**
905       \brief       \brief
906         Reduce each data-point in this Data object using the given operation. Return a Data
907         object with the same number of data-points, but with each data-point containing only
908         one value - the result of the reduction operation on the corresponding data-point in
909         this Data object
910      */
911      template <class UnaryFunction>
912      inline
913      Data
914      dp_algorithm(UnaryFunction operation) const;
915    
916      /**
917         \brief
918       Perform the given binary operation on all of the data's elements.       Perform the given binary operation on all of the data's elements.
919       The underlying type of the right hand side (right) determines the final       The underlying type of the right hand side (right) determines the final
920       type of *this after the operation. For example if the right hand side       type of *this after the operation. For example if the right hand side
# Line 1222  Data::algorithm(UnaryFunction operation) Line 1305  Data::algorithm(UnaryFunction operation)
1305  template <class UnaryFunction>  template <class UnaryFunction>
1306  inline  inline
1307  Data  Data
1308  dp_algorithm(const Data& data,  Data::dp_algorithm(UnaryFunction operation) const
              UnaryFunction operation)  
1309  {  {
1310    Data result(0,DataArrayView::ShapeType(),data.getFunctionSpace(),data.isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1311    if (data.isExpanded()) {    if (isExpanded()) {
1312      DataExpanded* dataE=dynamic_cast<DataExpanded*>(data.m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1313      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1314      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1315      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1316      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation);
1317    } else if (data.isTagged()) {    } else if (isTagged()) {
1318      DataTagged* dataT=dynamic_cast<DataTagged*>(data.m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1319      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1320      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1321      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1322      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation);
1323    } else if (data.isConstant()) {    } else if (isConstant()) {
1324      DataConstant* dataC=dynamic_cast<DataConstant*>(data.m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1325      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1326      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1327      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");

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

  ViewVC Help
Powered by ViewVC 1.1.26