00001 #ifndef INTEGRALEXPR_H 00002 #define INTEGRALEXPR_H 00003 00004 #include "SundanceDefs.h" 00005 #include "ExprBase.h" 00006 #include "Expr.h" 00007 #include "CellSet.h" 00008 #include "QuadratureFamily.h" 00009 #include "UnaryExpr.h" 00010 00011 namespace Sundance 00012 { 00013 using namespace TSF; 00014 using std::string; 00015 00016 using std::ostream; 00017 00018 /** 00019 * \ingroup LowLevelSymbolics 00020 * IntegralExpr is a symbolic specification of an integration that is to be 00021 * carried out over a cell set with a given quadrature rule. 00022 */ 00023 00024 class IntegralExpr : public UnaryExpr 00025 { 00026 public: 00027 00028 /** Construct with an expression for the integrand, cell set for the domain, 00029 * and quadrature family */ 00030 IntegralExpr(const CellSet& domain, const Expr& integrand, 00031 const QuadratureFamily& quad); 00032 00033 /** Virtual dtor */ 00034 virtual ~IntegralExpr(){;} 00035 00036 // ordering support 00037 /** */ 00038 virtual bool operator==(const Expr& other) const ; 00039 /** */ 00040 virtual bool operator<(const Expr& other) const ; 00041 /** */ 00042 virtual int sortPriority() const {return INTEGRALEXPR;} 00043 00044 // RTTI 00045 /** identify self as a IntegralExpr */ 00046 virtual bool isIntegralExpr() const {return true;} 00047 00048 /** virtual copy ctor */ 00049 virtual ExprBase* clone() const ; 00050 00051 /** print */ 00052 virtual void print(ostream& os, bool paren=false) const ; 00053 /** write to string */ 00054 virtual string toString(bool paren=false) const ; 00055 /** write to XML form */ 00056 virtual XMLObject toXML() const ; 00057 00058 /** */ 00059 Expr takeConstantUnderIntegral(const Expr& e) const ; 00060 00061 /** */ 00062 const QuadratureFamily& quad() const {return quad_;} 00063 00064 /** */ 00065 const Expr& integrand() const {return expr_;} 00066 00067 /** */ 00068 const CellSet& domain() const {return domain_;} 00069 00070 /** */ 00071 virtual void differential(const Expr& u, const Expr& du, 00072 Expr& result) const ; 00073 00074 /** */ 00075 virtual void substitute(const Expr& u, const Expr& du, 00076 Expr& result) const ; 00077 private: 00078 CellSet domain_; 00079 QuadratureFamily quad_; 00080 00081 }; 00082 00083 00084 } 00085 #endif 00086 00087 00088 00089 00090