/[escript]/temp/escript/src/Data.h
ViewVC logotype

Diff of /temp/escript/src/Data.h

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

trunk/esys2/escript/src/Data/Data.h revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC trunk/escript/src/Data.h revision 576 by gross, Fri Mar 3 08:28:42 2006 UTC
# Line 18  Line 18 
18  #ifndef DATA_H  #ifndef DATA_H
19  #define DATA_H  #define DATA_H
20    
21  #include "escript/Data/DataAbstract.h"  #include "DataAbstract.h"
22  #include "escript/Data/DataTagged.h"  #include "DataAlgorithm.h"
23  #include "escript/Data/DataAlgorithm.h"  #include "FunctionSpace.h"
24  #include "escript/Data/FunctionSpace.h"  #include "BinaryOp.h"
25  #include "escript/Data/BinaryOp.h"  #include "UnaryOp.h"
26  #include "escript/Data/UnaryOp.h"  #include "DataException.h"
 #include "escript/Data/DataException.h"  
27    
28  extern "C" {  extern "C" {
29  #include "escript/Data/DataC.h"  #include "DataC.h"
30  }  }
31    
 #include <iostream>  
32  #include <string>  #include <string>
 #include <memory>  
33  #include <algorithm>  #include <algorithm>
34    
35  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
36  #include <boost/python/object.hpp>  #include <boost/python/object.hpp>
 #include <boost/python/list.hpp>  
37  #include <boost/python/tuple.hpp>  #include <boost/python/tuple.hpp>
38  #include <boost/python/numeric.hpp>  #include <boost/python/numeric.hpp>
39    
# Line 45  namespace escript { Line 41  namespace escript {
41    
42  //  //
43  // Forward declaration for various implementations of Data.  // Forward declaration for various implementations of Data.
 class DataEmpty;  
44  class DataConstant;  class DataConstant;
45  class DataTagged;  class DataTagged;
46  class DataExpanded;  class DataExpanded;
# Line 150  class Data { Line 145  class Data {
145       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
146       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
147                         the appropriate values.                         the appropriate values.
148        ==>*
149    */    */
150    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
151         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
# Line 206  class Data { Line 202  class Data {
202         const boost::python::tuple& shape=boost::python::make_tuple(),         const boost::python::tuple& shape=boost::python::make_tuple(),
203         const FunctionSpace& what=FunctionSpace(),         const FunctionSpace& what=FunctionSpace(),
204         bool expanded=false);         bool expanded=false);
205      /**
206         \brief
207         Destructor
208      */
209      ~Data();
210    
211    /**    /**
212       \brief       \brief
# Line 307  class Data { Line 308  class Data {
308       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
309       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
310       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
311        ==>*
312    */    */
313    void    void
314    tag();    tag();
# Line 525  class Data { Line 527  class Data {
527       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
528       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
529       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
530        ==>*
531    */    */
532    void    void
533    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 537  class Data { Line 540  class Data {
540       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
541       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
542       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
543        ==>*
544    */    */
545    void    void
546    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
# Line 589  class Data { Line 593  class Data {
593       *       *
594    */    */
595    Data    Data
596    wherePositive() const;    wherePositive(double tol=0.0) const;
597    
598    /**    /**
599       \brief       \brief
# Line 597  class Data { Line 601  class Data {
601       *       *
602    */    */
603    Data    Data
604    whereNegative() const;    whereNegative(double tol=0.0) const;
605    
606    /**    /**
607       \brief       \brief
# Line 605  class Data { Line 609  class Data {
609       *       *
610    */    */
611    Data    Data
612    whereNonNegative() const;    whereNonNegative(double tol=0.0) const;
613    
614    /**    /**
615       \brief       \brief
# Line 613  class Data { Line 617  class Data {
617       *       *
618    */    */
619    Data    Data
620    whereNonPositive() const;    whereNonPositive(double tol=0.0) const;
621    
622    /**    /**
623       \brief       \brief
# Line 621  class Data { Line 625  class Data {
625       *       *
626    */    */
627    Data    Data
628    whereZero() const;    whereZero(double tol=0.0) const;
629    
630    /**    /**
631       \brief       \brief
# Line 629  class Data { Line 633  class Data {
633       *       *
634    */    */
635    Data    Data
636    whereNonZero() const;    whereNonZero(double tol=0.0) const;
637    
638    /**    /**
639       \brief       \brief
# Line 701  class Data { Line 705  class Data {
705    
706    /**    /**
707       \brief       \brief
708       Return the length of each data point of this Data object.       Return the sign of each data point of this Data object.
709       sqrt(sum(A[i,j,k,l]^2))       -1 for negative values, zero for zero values, 1 for positive values.
710       *       *
711    */    */
712    Data    Data
713    length() const;    sign() const;
714    
715    /**    /**
716       \brief       \brief
717       Return the sign 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.
718       -1 for negative values, zero for zero values, 1 for positive values.       Currently this function is restricted to rank 2, square shape, and dimension 3.
719       *       *
720    */    */
721    Data    Data
722    sign() const;    eigenvalues() const;
723    
724      /**
725         \brief
726         Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
727         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
728         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
729         first non-zero entry is positive.
730         Currently this function is restricted to rank 2, square shape, and dimension 3
731         *
732      */
733      const boost::python::tuple
734      eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
735    
736    /**    /**
737       \brief       \brief
# Line 729  class Data { Line 745  class Data {
745    /**    /**
746       \brief       \brief
747       Calculate the trace of each data point of this Data object.       Calculate the trace of each data point of this Data object.
      sum(A[i,i,i,i])  
748       *       *
749    */    */
750    Data    Data
# Line 761  class Data { Line 776  class Data {
776    
777    /**    /**
778       \brief       \brief
779         Return the asin of each data point of this Data object.
780         *
781      */
782      Data
783      asin() const;
784    
785      /**
786         \brief
787         Return the acos of each data point of this Data object.
788         *
789      */
790      Data
791      acos() const;
792    
793      /**
794         \brief
795         Return the atan of each data point of this Data object.
796         *
797      */
798      Data
799      atan() const;
800    
801      /**
802         \brief
803         Return the sinh of each data point of this Data object.
804         *
805      */
806      Data
807      sinh() const;
808    
809      /**
810         \brief
811         Return the cosh of each data point of this Data object.
812         *
813      */
814      Data
815      cosh() const;
816    
817      /**
818         \brief
819         Return the tanh of each data point of this Data object.
820         *
821      */
822      Data
823      tanh() const;
824    
825      /**
826         \brief
827         Return the asinh of each data point of this Data object.
828         *
829      */
830      Data
831      asinh() const;
832    
833      /**
834         \brief
835         Return the acosh of each data point of this Data object.
836         *
837      */
838      Data
839      acosh() const;
840    
841      /**
842         \brief
843         Return the atanh of each data point of this Data object.
844         *
845      */
846      Data
847      atanh() const;
848    
849      /**
850         \brief
851       Return the log to base 10 of each data point of this Data object.       Return the log to base 10 of each data point of this Data object.
852       *       *
853    */    */
854    Data    Data
855    log() const;    log10() const;
856    
857    /**    /**
858       \brief       \brief
# Line 773  class Data { Line 860  class Data {
860       *       *
861    */    */
862    Data    Data
863    ln() const;    log() const;
864    
865    /**    /**
866       \brief       \brief
# Line 1415  inline Line 1502  inline
1502  Data  Data
1503  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1504  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1505    if (isExpanded()) {    if (isExpanded()) {
1506        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1507      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1508      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1509      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1510      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1511      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1512        return result;
1513    } else if (isTagged()) {    } else if (isTagged()) {
1514      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1515        DataArrayView::ShapeType viewShape;
1516        DataArrayView::ValueType viewData(1);
1517        viewData[0]=0;
1518        DataArrayView defaultValue(viewData,viewShape);
1519        DataTagged::TagListType keys;
1520        DataTagged::ValueListType values;
1521        DataTagged::DataMapType::const_iterator i;
1522        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1523          keys.push_back(i->first);
1524          values.push_back(defaultValue);
1525        }
1526        Data result(keys,values,defaultValue,getFunctionSpace());
1527      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1528      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1529      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1530      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1531        return result;
1532    } else if (isConstant()) {    } else if (isConstant()) {
1533        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1534      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1535      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1536      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1537      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1538      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1539        return result;
1540    }    }
1541    return result;    Data falseRetVal; // to keep compiler quiet
1542      return falseRetVal;
1543  }  }
1544    
1545  }  }

Legend:
Removed from v.149  
changed lines
  Added in v.576

  ViewVC Help
Powered by ViewVC 1.1.26