Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

StdFunctionExpr.h

Go to the documentation of this file.
00001 #ifndef STDFUNCTIONEXPR_H
00002 #define STDFUNCTIONEXPR_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "UnaryExpr.h"
00007 #include "Expr.h"
00008 #include "DenseSerialVector.h"
00009 #include "XMLObject.h"
00010 
00011 
00012 namespace Sundance
00013 {
00014 
00015   using namespace TSF;
00016   using std::string;
00017 
00018   using std::ostream;
00019 
00020   enum StdFunctionCode {StdSin, StdCos, StdExp, StdLog,
00021                         StdCosh, StdSinh, StdSqrt, StdFabs, StdSign,
00022                         StdATan, StdACos, StdASin};
00023 
00024   typedef double (*StdFunctionPtr)(double);
00025 
00026   typedef Expr (*StdFuncOfExpr)(const Expr&);
00027 
00028   /** \ingroup LowLevelSymbolics
00029    * A standard elementary math function operating on a symbolic expression.
00030    */
00031 
00032   class StdFunctionExpr : public UnaryExpr
00033     {
00034     public:
00035       /** \name Developer-only methods */
00036       //@{
00037       /** no detailed doc */
00038       StdFunctionExpr(StdFunctionCode funcCode, const Expr& arg);
00039       virtual ~StdFunctionExpr(){;}
00040 
00041       // factory method for building exprs from XML
00042       /** */
00043       static bool createFunction(const XMLObject& xml, Expr& result);
00044       /** */
00045       static bool oneArgumentFunction(const string& tag, StdFuncOfExpr f,
00046                                       const XMLObject& xml, Expr& result);
00047 
00048 
00049 
00050       // evaluation
00051 
00052       /** */
00053       virtual double value() const ;
00054 
00055       /** */
00056       virtual void evaluate(const WorkSet& workSet,
00057                             const QuadratureFamily& quadFamily,
00058                             DenseSerialVector& result) const ;
00059 
00060       /** */
00061       virtual void evaluate(const AbstractFunctionSpace& targetSpace, const TSFArray<Cell>& cells,
00062                             const TSFArray<int>& cellIndices,
00063                             const TSFArray<int>& dofIndices,
00064                             const TSFArray<Point>& x,
00065                             DenseSerialVector& values) const ;
00066 
00067 
00068       /** */
00069       virtual ExprValue average(const Cell& cell) const ;
00070 
00071       // differentiation
00072       /** */
00073       virtual void derivative(const MultiIndex& d, Expr& result) const ;
00074 
00075       // ordering support
00076       /** */
00077       virtual bool operator==(const Expr& other) const ;
00078       /** */
00079       virtual bool operator<(const Expr& other) const ;
00080       /** */
00081       virtual int sortPriority() const {return STDFUNCTIONEXPR;}
00082 
00083       /** */
00084       virtual ExprBase* clone() const ;
00085 
00086       /** */
00087       virtual bool isSpatiallyConstant() const
00088         {return expr_.isSpatiallyConstant();}
00089 
00090       /** */
00091       virtual void print(ostream& os, bool paren=false) const ;
00092       /** */
00093       virtual string toString(bool paren=false) const ;
00094       /** */
00095       virtual XMLObject toXML() const ;
00096 
00097       /** */
00098       const string& name() const {return name_;}
00099 
00100       /** extract the mesh */
00101       virtual bool getMesh(Mesh& mesh) const ;
00102 
00103       /** */
00104       virtual void differential(const Expr& u, const Expr& du,
00105                                 Expr& result) const ;
00106 
00107       /** */
00108       virtual void substitute(const Expr& u, const Expr& u0,
00109                               Expr& result) const ;
00110       //@}
00111     protected:
00112       /** derivative of the function */
00113       Expr dFunc() const ;
00114 
00115       string name_;
00116       StdFunctionCode funcCode_;
00117       StdFunctionPtr funcPtr_;
00118     };
00119 
00120 
00121   /** \relates Expr
00122       Trigonometric sine function.
00123   */
00124   Expr sin(const Expr& arg);
00125 
00126   /** \relates Expr
00127       Trigonometric cosine function.
00128   */
00129   Expr cos(const Expr& arg);
00130 
00131   /** \relates Expr
00132       Trigonometric tangent function
00133   */
00134   Expr tan(const Expr& arg);
00135 
00136   /** \relates Expr
00137       Trigonometric inverse sine function
00138   */
00139   Expr asin(const Expr& arg);
00140 
00141   /** \relates Expr
00142       Trigonometric inverse cosine function
00143   */
00144   Expr acos(const Expr& arg);
00145 
00146   /** \relates Expr
00147       Trigonometric inverse tangent function
00148   */
00149   Expr atan(const Expr& arg);
00150 
00151   /** \relates Expr
00152       Exponential function
00153   */
00154   Expr exp(const Expr& arg);
00155 
00156   /** \relates Expr
00157       Logarithm function
00158   */
00159   Expr log(const Expr& arg);
00160 
00161   /** \relates Expr
00162       Hyperbolic cosine function
00163   */
00164   Expr cosh(const Expr& arg);
00165 
00166   /** \relates Expr
00167       Hyperbolic sine function
00168   */
00169   Expr sinh(const Expr& arg);
00170 
00171   /** \relates Expr
00172       Hyperbolic tangent function
00173   */
00174   Expr tanh(const Expr& arg);
00175 
00176   /** \relates Expr
00177       Square root function
00178   */
00179   Expr sqrt(const Expr& arg);
00180 
00181 
00182   /** \relates Expr
00183       Absolute value function
00184   */
00185   Expr fabs(const Expr& arg);
00186 
00187   /** \relates Expr
00188       Sign function
00189   */
00190   Expr sign(const Expr& arg);
00191 
00192 }
00193 #endif
00194 
00195 
00196 
00197 

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by