/[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 119 by jgs, Tue Apr 12 04:45:05 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 803  class Data { Line 874  class Data {
874    setSlice(const Data& value,    setSlice(const Data& value,
875             const DataArrayView::RegionType& region);             const DataArrayView::RegionType& region);
876    
877      /**
878         \brief
879         Archive the current Data object to the given file.
880         \param fileName - Input - file to archive to.
881      */
882      void
883      archiveData(const std::string fileName);
884    
885      /**
886         \brief
887         Extract the Data object archived in the given file, overwriting
888         the current Data object.
889         Note - the current object must be of type DataEmpty.
890         \param fileName - Input - file to extract from.
891         \param what - Input - a suitable FunctionSpace descibing the data.
892      */
893      void
894      extractData(const std::string fileName,
895                  const FunctionSpace& fspace);
896    
897   protected:   protected:
898    
899   private:   private:
# Line 823  class Data { Line 914  class Data {
914    /**    /**
915       \brief       \brief
916       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
917       this Data object and return the single double value result.       this Data object according to the given function and return the single value result.
918    */    */
919    template <class UnaryFunction>    template <class UnaryFunction>
920    inline    inline
# Line 832  class Data { Line 923  class Data {
923    
924    /**    /**
925       \brief       \brief
926         Reduce each data-point in this Data object using the given operation. Return a Data
927         object with the same number of data-points, but with each data-point containing only
928         one value - the result of the reduction operation on the corresponding data-point in
929         this Data object
930      */
931      template <class UnaryFunction>
932      inline
933      Data
934      dp_algorithm(UnaryFunction operation) const;
935    
936      /**
937         \brief
938       Perform the given binary operation on all of the data's elements.       Perform the given binary operation on all of the data's elements.
939       The underlying type of the right hand side (right) determines the final       The underlying type of the right hand side (right) determines the final
940       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 1325  Data::algorithm(UnaryFunction operation)
1325  template <class UnaryFunction>  template <class UnaryFunction>
1326  inline  inline
1327  Data  Data
1328  dp_algorithm(const Data& data,  Data::dp_algorithm(UnaryFunction operation) const
              UnaryFunction operation)  
1329  {  {
1330    Data result(0,DataArrayView::ShapeType(),data.getFunctionSpace(),data.isExpanded());    Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1331    if (data.isExpanded()) {    if (isExpanded()) {
1332      DataExpanded* dataE=dynamic_cast<DataExpanded*>(data.m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1333      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1334      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1335      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1336      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation);
1337    } else if (data.isTagged()) {    } else if (isTagged()) {
1338      DataTagged* dataT=dynamic_cast<DataTagged*>(data.m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1339      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1340      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1341      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1342      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation);
1343    } else if (data.isConstant()) {    } else if (isConstant()) {
1344      DataConstant* dataC=dynamic_cast<DataConstant*>(data.m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1345      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1346      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1347      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.119

  ViewVC Help
Powered by ViewVC 1.1.26