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

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

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

trunk/esys2/escript/src/Data/Data.h revision 122 by jgs, Thu Jun 9 05:38:05 2005 UTC trunk/escript/src/Data.h revision 698 by gross, Fri Mar 31 04:52:55 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/DataAlgorithm.h"  #include "FunctionSpace.h"
22  #include "escript/Data/FunctionSpace.h"  #include "BinaryOp.h"
23  #include "escript/Data/BinaryOp.h"  #include "UnaryOp.h"
24  #include "escript/Data/UnaryOp.h"  #include "DataException.h"
 #include "escript/Data/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 150  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 206  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 242  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 290  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 508  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 520  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 541  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 549  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 559  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 566  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 573  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 580  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 587  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 594  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 763  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       writes the object to a file in the DX file format
919    */    */
920    void    void
921    saveDX(std::string fileName) const;    saveDX(std::string fileName) const;
922    
923    /**    /**
924      \brief       \brief
925      writes the object to a file in the VTK file format       writes the object to a file in the VTK file format
926    */    */
927    void    void
928    saveVTK(std::string fileName) const;    saveVTK(std::string fileName) const;
# Line 794  class Data { Line 931  class Data {
931       \brief       \brief
932       Overloaded operator +=       Overloaded operator +=
933       \param right - Input - The right hand side.       \param right - Input - The right hand side.
934         *
935    */    */
936    Data& operator+=(const Data& right);    Data& operator+=(const Data& right);
937    Data& operator+=(const boost::python::object& right);    Data& operator+=(const boost::python::object& right);
# Line 802  class Data { Line 940  class Data {
940       \brief       \brief
941       Overloaded operator -=       Overloaded operator -=
942       \param right - Input - The right hand side.       \param right - Input - The right hand side.
943         *
944    */    */
945    Data& operator-=(const Data& right);    Data& operator-=(const Data& right);
946    Data& operator-=(const boost::python::object& right);    Data& operator-=(const boost::python::object& right);
# Line 810  class Data { Line 949  class Data {
949       \brief       \brief
950       Overloaded operator *=       Overloaded operator *=
951       \param right - Input - The right hand side.       \param right - Input - The right hand side.
952         *
953    */    */
954    Data& operator*=(const Data& right);    Data& operator*=(const Data& right);
955    Data& operator*=(const boost::python::object& right);    Data& operator*=(const boost::python::object& right);
# Line 818  class Data { Line 958  class Data {
958       \brief       \brief
959       Overloaded operator /=       Overloaded operator /=
960       \param right - Input - The right hand side.       \param right - Input - The right hand side.
961         *
962    */    */
963    Data& operator/=(const Data& right);    Data& operator/=(const Data& right);
964    Data& operator/=(const boost::python::object& right);    Data& operator/=(const boost::python::object& right);
# Line 883  class Data { Line 1024  class Data {
1024       Return a Data object containing the specified slice of       Return a Data object containing the specified slice of
1025       this Data object.       this Data object.
1026       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1027         *
1028    */    */
1029    Data    Data
1030    getSlice(const DataArrayView::RegionType& region) const;    getSlice(const DataArrayView::RegionType& region) const;
# Line 893  class Data { Line 1035  class Data {
1035       Data object.       Data object.
1036       \param value - Input - Data to copy from.       \param value - Input - Data to copy from.
1037       \param region - Input - Region to copy.       \param region - Input - Region to copy.
1038         *
1039    */    */
1040    void    void
1041    setSlice(const Data& value,    setSlice(const Data& value,
# Line 940  class Data { Line 1083  class Data {
1083       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
1084       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.
1085    */    */
1086    template <class UnaryFunction>    template <class BinaryFunction>
1087    inline    inline
1088    double    double
1089    algorithm(UnaryFunction operation) const;    algorithm(BinaryFunction operation,
1090                double initial_value) const;
1091    
1092    /**    /**
1093       \brief       \brief
# Line 952  class Data { Line 1096  class Data {
1096       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
1097       this Data object       this Data object
1098    */    */
1099    template <class UnaryFunction>    template <class BinaryFunction>
1100    inline    inline
1101    Data    Data
1102    dp_algorithm(UnaryFunction operation) const;    dp_algorithm(BinaryFunction operation,
1103                   double initial_value) const;
1104    
1105    /**    /**
1106       \brief       \brief
# Line 1022  class Data { Line 1167  class Data {
1167    // pointer to the actual data object    // pointer to the actual data object
1168    boost::shared_ptr<DataAbstract> m_data;    boost::shared_ptr<DataAbstract> m_data;
1169    
1170      //
1171      // pointer to the internal profiling data
1172      struct profDataEntry *profData;
1173    
1174  };  };
1175    
1176  template <class IValueType>  template <class IValueType>
# Line 1317  Data::unaryOp(UnaryFunction operation) Line 1466  Data::unaryOp(UnaryFunction operation)
1466    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.
1467    Calls escript::algorithm.    Calls escript::algorithm.
1468  */  */
1469  template <class UnaryFunction>  template <class BinaryFunction>
1470  inline  inline
1471  double  double
1472  Data::algorithm(UnaryFunction operation) const  Data::algorithm(BinaryFunction operation, double initial_value) const
1473  {  {
1474    if (isExpanded()) {    if (isExpanded()) {
1475      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* leftC=dynamic_cast<DataExpanded*>(m_data.get());
1476      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");      EsysAssert((leftC!=0), "Programming error - casting to DataExpanded.");
1477      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1478    } else if (isTagged()) {    } else if (isTagged()) {
1479      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* leftC=dynamic_cast<DataTagged*>(m_data.get());
1480      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");      EsysAssert((leftC!=0), "Programming error - casting to DataTagged.");
1481      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1482    } else if (isConstant()) {    } else if (isConstant()) {
1483      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* leftC=dynamic_cast<DataConstant*>(m_data.get());
1484      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");      EsysAssert((leftC!=0), "Programming error - casting to DataConstant.");
1485      return escript::algorithm(*leftC,operation);      return escript::algorithm(*leftC,operation,initial_value);
1486    }    }
1487    return 0;    return 0;
1488  }  }
# Line 1346  Data::algorithm(UnaryFunction operation) Line 1495  Data::algorithm(UnaryFunction operation)
1495    rank 0 Data object.    rank 0 Data object.
1496    Calls escript::dp_algorithm.    Calls escript::dp_algorithm.
1497  */  */
1498  template <class UnaryFunction>  template <class BinaryFunction>
1499  inline  inline
1500  Data  Data
1501  Data::dp_algorithm(UnaryFunction operation) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1502  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1503    if (isExpanded()) {    if (isExpanded()) {
1504        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1505      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1506      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1507      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1508      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1509      escript::dp_algorithm(*dataE,*resultE,operation);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1510        return result;
1511    } else if (isTagged()) {    } else if (isTagged()) {
1512      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1513        DataArrayView::ShapeType viewShape;
1514        DataArrayView::ValueType viewData(1);
1515        viewData[0]=0;
1516        DataArrayView defaultValue(viewData,viewShape);
1517        DataTagged::TagListType keys;
1518        DataTagged::ValueListType values;
1519        DataTagged::DataMapType::const_iterator i;
1520        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1521          keys.push_back(i->first);
1522          values.push_back(defaultValue);
1523        }
1524        Data result(keys,values,defaultValue,getFunctionSpace());
1525      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1526      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1527      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1528      escript::dp_algorithm(*dataT,*resultT,operation);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1529        return result;
1530    } else if (isConstant()) {    } else if (isConstant()) {
1531        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1532      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1533      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1534      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1535      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1536      escript::dp_algorithm(*dataC,*resultC,operation);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1537        return result;
1538    }    }
1539    return result;    Data falseRetVal; // to keep compiler quiet
1540      return falseRetVal;
1541  }  }
1542    
1543  }  }

Legend:
Removed from v.122  
changed lines
  Added in v.698

  ViewVC Help
Powered by ViewVC 1.1.26