/[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 104 by jgs, Fri Dec 17 07:43:12 2004 UTC revision 110 by jgs, Mon Feb 14 04:14:42 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 688  class Data { Line 731  class Data {
731    
732    /**    /**
733      \brief      \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 837  class Data { Line 887  class Data {
887    double    double
888    algorithm(UnaryFunction operation) const;    algorithm(UnaryFunction operation) const;
889    
890      template <class UnaryFunction>
891      inline
892      Data
893      dp_algorithm(UnaryFunction operation) const;
894    
895    /**    /**
896       \brief       \brief
897       Perform the given binary operation on all of the data's elements.       Perform the given binary operation on all of the data's elements.
# Line 1229  Data::algorithm(UnaryFunction operation) Line 1284  Data::algorithm(UnaryFunction operation)
1284  template <class UnaryFunction>  template <class UnaryFunction>
1285  inline  inline
1286  Data  Data
1287  dp_algorithm(const Data& data,  Data::dp_algorithm(UnaryFunction operation) const
              UnaryFunction operation)  
1288  {  {
1289    Data result(0,DataArrayView::ShapeType(),data.getFunctionSpace(),data.isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1290    if (data.isExpanded()) {    if (isExpanded()) {
1291      DataExpanded* dataE=dynamic_cast<DataExpanded*>(data.m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1292      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1293      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1294      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1295      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation);
1296    } else if (data.isTagged()) {    } else if (isTagged()) {
1297      DataTagged* dataT=dynamic_cast<DataTagged*>(data.m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1298      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1299      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1300      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1301      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation);
1302    } else if (data.isConstant()) {    } else if (isConstant()) {
1303      DataConstant* dataC=dynamic_cast<DataConstant*>(data.m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1304      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1305      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1306      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");

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

  ViewVC Help
Powered by ViewVC 1.1.26