/[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 102 by jgs, Wed Dec 15 07:08:39 2004 UTC revision 113 by jgs, Mon Feb 28 07:06:33 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 397  class Data { Line 400  class Data {
400    
401    /**    /**
402       \brief       \brief
403         Assign the given value to the data-points referenced by the given
404         reference number.
405    
406         The value supplied is a python numarray object.  The data from this numarray
407         is unpacked into a DataArray, and this is used to set the corresponding
408         data-points in the underlying Data object.
409    
410         If the underlying Data object cannot be accessed via reference numbers, an
411         exception will be thrown.
412    
413         \param ref - Input - reference number.
414         \param value - Input - value to assign to data-points associated with
415                                the given reference number.
416      */
417      void
418      setRefValue(int ref,
419                  const boost::python::numeric::array& value);
420    
421      /**
422         \brief
423         Return the values associated with the data-points referenced by the given
424         reference number.
425    
426         The value supplied is a python numarray object. The data from the corresponding
427         data-points in this Data object are packed into the given numarray object.
428    
429         If the underlying Data object cannot be accessed via reference numbers, an
430         exception will be thrown.
431    
432         \param ref - Input - reference number.
433         \param value - Output - object to receive values from data-points
434                                 associated with the given reference number.
435      */
436      void
437      getRefValue(int ref,
438                  boost::python::numeric::array& value);
439    
440      /**
441         \brief
442       Return a view into the data for the data point specified.       Return a view into the data for the data point specified.
443       NOTE: Construction of the DataArrayView is a relatively expensive       NOTE: Construction of the DataArrayView is a relatively expensive
444       operation.       operation.
# Line 643  class Data { Line 685  class Data {
685    /**    /**
686      \transpose      \transpose
687      Transpose each data point of this Data object around the given axis.      Transpose each data point of this Data object around the given axis.
688        --* not implemented yet *--
689    */    */
690    Data    Data
691    transpose(int axis) const;    transpose(int axis) const;
# Line 681  class Data { Line 724  class Data {
724    
725    /**    /**
726      \brief      \brief
727        writes the object to a file in the DX file format
728      */
729      void
730      saveDX(std::string fileName) const;
731    
732      /**
733        \brief
734        writes the object to a file in the VTK file format
735      */
736      void
737      saveVTK(std::string fileName) const;
738    
739      /**
740        \brief
741      Return the negation of each data point of this Data object.      Return the negation of each data point of this Data object.
742    */    */
743    Data    Data
# Line 823  class Data { Line 880  class Data {
880    /**    /**
881       \brief       \brief
882       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
883       this Data object and return the single double value result.       this Data object according to the given function and return the single value result.
884    */    */
885    template <class UnaryFunction>    template <class UnaryFunction>
886    inline    inline
# Line 832  class Data { Line 889  class Data {
889    
890    /**    /**
891       \brief       \brief
892         Reduce each data-point in this Data object using the given operation. Return a Data
893         object with the same number of data-points, but with each data-point containing only
894         one value - the result of the reduction operation on the corresponding data-point in
895         this Data object
896      */
897      template <class UnaryFunction>
898      inline
899      Data
900      dp_algorithm(UnaryFunction operation) const;
901    
902      /**
903         \brief
904       Perform the given binary operation on all of the data's elements.       Perform the given binary operation on all of the data's elements.
905       The underlying type of the right hand side (right) determines the final       The underlying type of the right hand side (right) determines the final
906       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 1291  Data::algorithm(UnaryFunction operation)
1291  template <class UnaryFunction>  template <class UnaryFunction>
1292  inline  inline
1293  Data  Data
1294  dp_algorithm(const Data& data,  Data::dp_algorithm(UnaryFunction operation) const
              UnaryFunction operation)  
1295  {  {
1296    Data result(0,DataArrayView::ShapeType(),data.getFunctionSpace(),data.isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1297    if (data.isExpanded()) {    if (isExpanded()) {
1298      DataExpanded* dataE=dynamic_cast<DataExpanded*>(data.m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1299      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1300      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1301      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1302      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation);
1303    } else if (data.isTagged()) {    } else if (isTagged()) {
1304      DataTagged* dataT=dynamic_cast<DataTagged*>(data.m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1305      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1306      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1307      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1308      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation);
1309    } else if (data.isConstant()) {    } else if (isConstant()) {
1310      DataConstant* dataC=dynamic_cast<DataConstant*>(data.m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1311      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1312      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1313      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");

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

  ViewVC Help
Powered by ViewVC 1.1.26