/[escript]/branches/more_shared_ptrs_from_1812/escript/src/Data.h
ViewVC logotype

Diff of /branches/more_shared_ptrs_from_1812/escript/src/Data.h

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

trunk/esys2/escript/src/Data/Data.h revision 121 by jgs, Fri May 6 04:26:16 2005 UTC trunk/escript/src/Data.h revision 699 by gross, Fri Mar 31 06:27:56 2006 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT ACcESS 2004 -  All Rights Reserved                         *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS.  No part of this code             *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that                          *   *                                                          *
11   * person has a software license agreement with ACcESS.                       *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13    
14  /** \file Data.h */  /** \file Data.h */
# Line 18  Line 16 
16  #ifndef DATA_H  #ifndef DATA_H
17  #define DATA_H  #define DATA_H
18    
19  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
20  #include "escript/Data/DataTagged.h"  #include "DataAlgorithm.h"
21  #include "escript/Data/FunctionSpace.h"  #include "FunctionSpace.h"
22  #include "escript/Data/BinaryOp.h"  #include "BinaryOp.h"
23  #include "escript/Data/UnaryOp.h"  #include "UnaryOp.h"
24  #include "escript/Data/DataException.h"  #include "DataException.h"
25    
26  extern "C" {  extern "C" {
27  #include "escript/Data/DataC.h"  #include "DataC.h"
28  }  }
29    
 #include <iostream>  
30  #include <string>  #include <string>
 #include <memory>  
31  #include <algorithm>  #include <algorithm>
32    
33  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
34  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
 #include <boost/python/list.hpp>  
35  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
36  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
37    
38  namespace escript {  namespace escript {
39    
40  //  //
41  // Forward declaration for various implimentations of Data.  // Forward declaration for various implementations of Data.
 class DataEmpty;  
42  class DataConstant;  class DataConstant;
43  class DataTagged;  class DataTagged;
44  class DataExpanded;  class DataExpanded;
# Line 149  class Data { Line 143  class Data {
143       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
144       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
145                         the appropriate values.                         the appropriate values.
146        ==>*
147    */    */
148    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
149         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
# Line 205  class Data { Line 200  class Data {
200         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
201         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
202         bool expanded=false);         bool expanded=false);
203      /**
204         \brief
205         Destructor
206      */
207      ~Data();
208    
209    /**    /**
210       \brief       \brief
# Line 241  class Data { Line 241  class Data {
241    
242    /**    /**
243       \brief       \brief
244         Fills the expanded Data object from values of a python numarray object.
245      */
246      void
247      fillFromNumArray(const boost::python::numeric::array);
248    
249      /**
250         \brief
251         Return the tag number associated with the given data-point.
252    
253         The data-point number here corresponds to the data-point number in the
254         numarray returned by convertToNumArray.
255      */
256      int
257      getTagNumber(int dpno);
258    
259      /**
260         \brief
261       Return the C wrapper for the Data object.       Return the C wrapper for the Data object.
262    */    */
263    escriptDataC    escriptDataC
# Line 289  class Data { Line 306  class Data {
306       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
307       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
308       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
309        ==>*
310    */    */
311    void    void
312    tag();    tag();
# Line 507  class Data { Line 525  class Data {
525       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
526       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
527       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
528        ==>*
529    */    */
530    void    void
531    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 519  class Data { Line 538  class Data {
538       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
539       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
540       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
541        ==>*
542    */    */
543    void    void
544    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
# Line 540  class Data { Line 560  class Data {
560       \brief       \brief
561       Interpolates this onto the given functionspace and returns       Interpolates this onto the given functionspace and returns
562       the result as a Data object.       the result as a Data object.
563         *
564    */    */
565    Data    Data
566    interpolate(const FunctionSpace& functionspace) const;    interpolate(const FunctionSpace& functionspace) const;
# Line 548  class Data { Line 569  class Data {
569       \brief       \brief
570       Calculates the gradient of the data at the data points of functionspace.       Calculates the gradient of the data at the data points of functionspace.
571       If functionspace is not present the function space of Function(getDomain()) is used.       If functionspace is not present the function space of Function(getDomain()) is used.
572         *
573    */    */
574    Data    Data
575    gradOn(const FunctionSpace& functionspace) const;    gradOn(const FunctionSpace& functionspace) const;
# Line 558  class Data { Line 580  class Data {
580    /**    /**
581       \brief       \brief
582       Calculate the integral over the function space domain.       Calculate the integral over the function space domain.
583         *
584    */    */
585    boost::python::numeric::array    boost::python::numeric::array
586    integrate() const;    integrate() const;
# Line 565  class Data { Line 588  class Data {
588    /**    /**
589       \brief       \brief
590       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.       Return a Data with a 1 for +ive values and a 0 for 0 or -ive values.
591         *
592    */    */
593    Data    Data
594    wherePositive() const;    wherePositive() const;
# Line 572  class Data { Line 596  class Data {
596    /**    /**
597       \brief       \brief
598       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.       Return a Data with a 1 for -ive values and a 0 for +ive or 0 values.
599         *
600    */    */
601    Data    Data
602    whereNegative() const;    whereNegative() const;
# Line 579  class Data { Line 604  class Data {
604    /**    /**
605       \brief       \brief
606       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.       Return a Data with a 1 for +ive or 0 values and a 0 for -ive values.
607         *
608    */    */
609    Data    Data
610    whereNonNegative() const;    whereNonNegative() const;
# Line 586  class Data { Line 612  class Data {
612    /**    /**
613       \brief       \brief
614       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.       Return a Data with a 1 for -ive or 0 values and a 0 for +ive values.
615         *
616    */    */
617    Data    Data
618    whereNonPositive() const;    whereNonPositive() const;
# Line 593  class Data { Line 620  class Data {
620    /**    /**
621       \brief       \brief
622       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.       Return a Data with a 1 for 0 values and a 0 for +ive or -ive values.
623         *
624    */    */
625    Data    Data
626    whereZero() const;    whereZero(double tol=0.0) const;
627    
628    /**    /**
629       \brief       \brief
630       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.       Return a Data with a 0 for 0 values and a 1 for +ive or -ive values.
631         *
632    */    */
633    Data    Data
634    whereNonZero() const;    whereNonZero(double tol=0.0) const;
635    
636    /**    /**
637       \brief       \brief
638       Return the sin of each data point of this Data object.       Return the maximum absolute value of this Data object.
639         *
640      */
641      double
642      Lsup() const;
643    
644      /**
645         \brief
646         Return the minimum absolute value of this Data object.
647         *
648      */
649      double
650      Linf() const;
651    
652      /**
653         \brief
654         Return the maximum value of this Data object.
655         *
656      */
657      double
658      sup() const;
659    
660      /**
661         \brief
662         Return the minimum value of this Data object.
663         *
664      */
665      double
666      inf() const;
667    
668      /**
669         \brief
670         Return the absolute value of each data point of this Data object.
671         *
672    */    */
673    Data    Data
674    sin() const;    abs() const;
675    
676    /**    /**
677       \brief       \brief
678       Return the cos of each data point of this Data object.       Return the maximum value of each data point of this Data object.
679         *
680    */    */
681    Data    Data
682    cos() const;    maxval() const;
683    
684    /**    /**
685       \brief       \brief
686       Return the tan of each data point of this Data object.       Return the minimum value of each data point of this Data object.
687         *
688    */    */
689    Data    Data
690    tan() const;    minval() const;
691    
692    /**    /**
693       \brief       \brief
694       Return the log to base 10 of each data point of this Data object.       Return the (sample number, data-point number) of the data point with
695         the minimum value in this Data object.
696      */
697      const boost::python::tuple
698      mindp() const;
699    
700      void
701      calc_mindp(int& SampleNo,
702                 int& DataPointNo) const;
703    
704      /**
705         \brief
706         Return the sign of each data point of this Data object.
707         -1 for negative values, zero for zero values, 1 for positive values.
708         *
709    */    */
710    Data    Data
711    log() const;    sign() const;
712    
713    /**    /**
714       \brief       \brief
715       Return the natural log of each data point of this Data object.       Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.
716         Currently this function is restricted to rank 2, square shape, and dimension 3.
717         *
718    */    */
719    Data    Data
720    ln() const;    eigenvalues() const;
721    
722    /**    /**
723       \brief       \brief
724       Return the maximum absolute value of this Data object.       Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
725         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
726         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
727         first non-zero entry is positive.
728         Currently this function is restricted to rank 2, square shape, and dimension 3
729         *
730    */    */
731    double    const boost::python::tuple
732    Lsup() const;    eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
733    
734    /**    /**
735       \brief       \brief
736       Return the minimum absolute value of this Data object.       Transpose each data point of this Data object around the given axis.
737         --* not implemented yet *--
738         *
739    */    */
740    double    Data
741    Linf() const;    transpose(int axis) const;
742    
743    /**    /**
744       \brief       \brief
745       Return the maximum value of this Data object.       Calculate the trace of each data point of this Data object.
746         *
747    */    */
748    double    Data
749    sup() const;    trace() const;
750    
751    /**    /**
752       \brief       \brief
753       Return the minimum value of this Data object.       Return the sin of each data point of this Data object.
754         *
755    */    */
756    double    Data
757    inf() const;    sin() const;
758    
759    /**    /**
760       \brief       \brief
761       Return the absolute value of each data point of this Data object.       Return the cos of each data point of this Data object.
762         *
763    */    */
764    Data    Data
765    abs() const;    cos() const;
766    
767    /**    /**
768       \brief       \brief
769       Return the maximum value of each data point of this Data object.       Return the tan of each data point of this Data object.
770         *
771    */    */
772    Data    Data
773    maxval() const;    tan() const;
774    
775    /**    /**
776       \brief       \brief
777       Return the minimum value of each data point of this Data object.       Return the asin of each data point of this Data object.
778         *
779    */    */
780    Data    Data
781    minval() const;    asin() const;
782    
783    /**    /**
784       \brief       \brief
785       Return the (sample number, data-point number) of the data point with       Return the acos of each data point of this Data object.
786       the minimum value in this Data object.       *
787    */    */
788    const boost::python::tuple    Data
789    mindp() const;    acos() const;
790    
791    /**    /**
792       \brief       \brief
793       Return the length of each data point of this Data object.       Return the atan of each data point of this Data object.
794       sqrt(sum(A[i,j,k,l]^2))       *
795    */    */
796    Data    Data
797    length() const;    atan() const;
798    
799    /**    /**
800       \brief       \brief
801       Return the sign of each data point of this Data object.       Return the sinh of each data point of this Data object.
802       -1 for negative values, zero for zero values, 1 for positive values.       *
803    */    */
804    Data    Data
805    sign() const;    sinh() const;
806    
807    /**    /**
808      \brief       \brief
809      Transpose each data point of this Data object around the given axis.       Return the cosh of each data point of this Data object.
810      --* not implemented yet *--       *
811    */    */
812    Data    Data
813    transpose(int axis) const;    cosh() const;
814    
815    /**    /**
816      \brief       \brief
817      Calculate the trace of each data point of this Data object.       Return the tanh of each data point of this Data object.
818      sum(A[i,i,i,i])       *
819    */    */
820    Data    Data
821    trace() const;    tanh() const;
822    
823    /**    /**
824      \brief       \brief
825      Return the exponential function of each data point of this Data object.       Return the asinh of each data point of this Data object.
826         *
827      */
828      Data
829      asinh() const;
830    
831      /**
832         \brief
833         Return the acosh of each data point of this Data object.
834         *
835      */
836      Data
837      acosh() const;
838    
839      /**
840         \brief
841         Return the atanh of each data point of this Data object.
842         *
843      */
844      Data
845      atanh() const;
846    
847      /**
848         \brief
849         Return the log to base 10 of each data point of this Data object.
850         *
851      */
852      Data
853      log10() const;
854    
855      /**
856         \brief
857         Return the natural log of each data point of this Data object.
858         *
859      */
860      Data
861      log() const;
862    
863      /**
864         \brief
865         Return the exponential function of each data point of this Data object.
866         *
867    */    */
868    Data    Data
869    exp() const;    exp() const;
870    
871    /**    /**
872      \brief       \brief
873      Return the square root of each data point of this Data object.       Return the square root of each data point of this Data object.
874         *
875    */    */
876    Data    Data
877    sqrt() const;    sqrt() const;
878    
879    /**    /**
880      \brief       \brief
881      Return the negation of each data point of this Data object.       Return the negation of each data point of this Data object.
882         *
883    */    */
884    Data    Data
885    neg() const;    neg() const;
886    
887    /**    /**
888      \brief       \brief
889      Return the identity of each data point of this Data object.       Return the identity of each data point of this Data object.
890      Simply returns this object unmodified.       Simply returns this object unmodified.
891         *
892    */    */
893    Data    Data
894    pos() const;    pos() const;
# Line 762  class Data { Line 898  class Data {
898       Return the given power of each data point of this Data object.       Return the given power of each data point of this Data object.
899    
900       \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
901         *
902    */    */
903    Data    Data
904    powD(const Data& right) const;    powD(const Data& right) const;
905    
906    /**    /**
907     * \brief       \brief
908     * Return the given power of each data point of this boost python object.       Return the given power of each data point of this boost python object.
909     *      
910     * \param right Input - the power to raise the object to.       \param right Input - the power to raise the object to.
911         *
912     */     */
913    Data    Data
914    powO(const boost::python::object& right) const;    powO(const boost::python::object& right) const;
915    
916    /**    /**
917      \brief       \brief
918      writes the object to a file in the DX file format       Return the given power of each data point of this boost python object.
919        
920         \param left Input - the bases
921         *
922       */
923    
924      Data
925      rpowO(const boost::python::object& left) const;
926    
927      /**
928         \brief
929         writes the object to a file in the DX file format
930    */    */
931    void    void
932    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
933    
934    /**    /**
935      \brief       \brief
936      writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
937    */    */
938    void    void
939    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
# Line 793  class Data { Line 942  class Data {
942       \brief       \brief
943       Overloaded operator +=       Overloaded operator +=
944       \param right - Input - The right hand side.       \param right - Input - The right hand side.
945         *
946    */    */
947    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
948    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
# Line 801  class Data { Line 951  class Data {
951       \brief       \brief
952       Overloaded operator -=       Overloaded operator -=
953       \param right - Input - The right hand side.       \param right - Input - The right hand side.
954         *
955    */    */
956    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
957    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
# Line 809  class Data { Line 960  class Data {
960       \brief       \brief
961       Overloaded operator *=       Overloaded operator *=
962       \param right - Input - The right hand side.       \param right - Input - The right hand side.
963         *
964    */    */
965    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
966    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
# Line 817  class Data { Line 969  class Data {
969       \brief       \brief
970       Overloaded operator /=       Overloaded operator /=
971       \param right - Input - The right hand side.       \param right - Input - The right hand side.
972         *
973    */    */
974    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
975    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
# Line 882  class Data { Line 1035  class Data {
1035       Return a Data object containing the specified slice of       Return a Data object containing the specified slice of
1036       this Data object.       this Data object.
1037       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1038         *
1039    */    */
1040    Data    Data
1041    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 892  class Data { Line 1046  class Data {
1046       Data object.       Data object.
1047       \param value - Input - Data to copy from.       \param value - Input - Data to copy from.
1048       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1049         *
1050    */    */
1051    void    void
1052    setSlice(const Data& value,    setSlice(const Data& value,
# Line 939  class Data { Line 1094  class Data {
1094       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
1095       this Data object according to the given function and return the single value result.       this Data object according to the given function and return the single value result.
1096    */    */
1097    template <class UnaryFunction>    template <class BinaryFunction>
1098    inline    inline
1099    double    double
1100    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1101                double initial_value) const;
1102    
1103    /**    /**
1104       \brief       \brief
# Line 951  class Data { Line 1107  class Data {
1107       one value - the result of the reduction operation on the corresponding data-point in       one value - the result of the reduction operation on the corresponding data-point in
1108       this Data object       this Data object
1109    */    */
1110    template <class UnaryFunction>    template <class BinaryFunction>
1111    inline    inline
1112    Data    Data
1113    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1114                   double initial_value) const;
1115    
1116    /**    /**
1117       \brief       \brief
# Line 1021  class Data { Line 1178  class Data {
1178    // pointer to the actual data object    // pointer to the actual data object
1179    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1180    
1181      //
1182      // pointer to the internal profiling data
1183      struct profDataEntry *profData;
1184    
1185  };  };
1186    
1187  template <class IValueType>  template <class IValueType>
# Line 1316  Data::unaryOp(UnaryFunction operation) Line 1477  Data::unaryOp(UnaryFunction operation)
1477    object (*this) is a rank n Data object, and returned object is a scalar.    object (*this) is a rank n Data object, and returned object is a scalar.
1478    Calls escript::algorithm.    Calls escript::algorithm.
1479  */  */
1480  template <class UnaryFunction>  template <class BinaryFunction>
1481  inline  inline
1482  double  double
1483  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1484  {  {
1485    if (isExpanded()) {    if (isExpanded()) {
1486      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1487      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1488      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1489    } else if (isTagged()) {    } else if (isTagged()) {
1490      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1491      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1492      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1493    } else if (isConstant()) {    } else if (isConstant()) {
1494      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1495      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1496      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1497    }    }
1498    return 0;    return 0;
1499  }  }
# Line 1345  Data::algorithm(UnaryFunction operation) Line 1506  Data::algorithm(UnaryFunction operation)
1506    rank 0 Data object.    rank 0 Data object.
1507    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1508  */  */
1509  template <class UnaryFunction>  template <class BinaryFunction>
1510  inline  inline
1511  Data  Data
1512  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1513  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1514    if (isExpanded()) {    if (isExpanded()) {
1515        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1516      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1517      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1518      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1519      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1520      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1521        return result;
1522    } else if (isTagged()) {    } else if (isTagged()) {
1523      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1524        DataArrayView::ShapeType viewShape;
1525        DataArrayView::ValueType viewData(1);
1526        viewData[0]=0;
1527        DataArrayView defaultValue(viewData,viewShape);
1528        DataTagged::TagListType keys;
1529        DataTagged::ValueListType values;
1530        DataTagged::DataMapType::const_iterator i;
1531        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1532          keys.push_back(i->first);
1533          values.push_back(defaultValue);
1534        }
1535        Data result(keys,values,defaultValue,getFunctionSpace());
1536      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1537      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1538      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1539      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1540        return result;
1541    } else if (isConstant()) {    } else if (isConstant()) {
1542        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1543      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1544      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1545      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1546      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1547      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1548        return result;
1549    }    }
1550    return result;    Data falseRetVal; // to keep compiler quiet
1551      return falseRetVal;
1552  }  }
1553    
1554  }  }

Legend:
Removed from v.121  
changed lines
  Added in v.699

  ViewVC Help
Powered by ViewVC 1.1.26