SundanceDiffOp.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_DIFFOP_H
00032 #define SUNDANCE_DIFFOP_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceDerivative.hpp"
00036 #include "SundanceUnaryExpr.hpp"
00037 #include "SundanceDeriv.hpp"
00038 #include "SundanceMap.hpp"
00039 #include "SundanceSet.hpp"
00040 #include "SundanceMultipleDeriv.hpp"
00041 #include "SundanceDiffOpEvaluator.hpp"
00042 
00043 
00044 namespace Sundance
00045 {
00046 class Expr;
00047 
00048 using namespace Sundance;
00049 using namespace Teuchos;
00050 
00051 
00052 
00053 
00054 /**
00055  *
00056  */
00057 class DiffOp : public UnaryExpr
00058 {
00059 public:
00060   /** ctor */
00061   DiffOp(const MultiIndex& op, const RCP<ScalarExpr>& arg);
00062 
00063   /** virtual destructor */
00064   virtual ~DiffOp() {;}
00065 
00066 
00067   /** 
00068    * Indicate whether the expression is linear 
00069    * with respect to test functions 
00070    */
00071   virtual bool isLinearInTests() const 
00072     {return evaluatableArg()->isLinearInTests();}
00073       
00074       
00075   /** Indicate whether the expression is linear in the given 
00076    * functions */
00077   virtual bool isLinearForm(const Expr& u) const 
00078     {
00079       return evaluatableArg()->isLinearForm(u);
00080     }
00081       
00082   /** Indicate whether the expression is at most 
00083    * quadratic in the given functions */
00084   virtual bool isQuadraticForm(const Expr& u) const
00085     {
00086       return evaluatableArg()->isQuadraticForm(u);
00087     }
00088 
00089   /**
00090    * Find the maximum differentiation order acting on discrete
00091    * functions in this expression. 
00092    */
00093   virtual int maxDiffOrderOnDiscreteFunctions() const 
00094     {
00095       int rtn = evaluatableArg()->maxDiffOrderOnDiscreteFunctions();
00096       if (evaluatableArg()->hasDiscreteFunctions()) 
00097       {
00098         rtn += mi_.order();
00099       }
00100       return rtn;
00101     }
00102 
00103 
00104   /** Write a simple text description suitable
00105    * for output to a terminal */
00106   virtual std::ostream& toText(std::ostream& os, bool paren) const ;
00107 
00108   /** Write in XML */
00109   virtual XMLObject toXML() const ;
00110 
00111 
00112   /** */
00113   virtual Set<MultipleDeriv> 
00114   internalFindW(int order, const EvalContext& context) const ;
00115 
00116 
00117   /** */
00118   virtual Set<MultipleDeriv> 
00119   internalFindV(int order, const EvalContext& context) const ;
00120 
00121 
00122   /** */
00123   virtual Set<MultipleDeriv> 
00124   internalFindC(int order, const EvalContext& context) const ;
00125 
00126 
00127   /** */
00128   virtual RCP<Array<Set<MultipleDeriv> > > 
00129   internalDetermineR(const EvalContext& context,
00130     const Array<Set<MultipleDeriv> >& RInput) const ;
00131 
00132   /** */
00133   void requestMultiIndexAtEvalPoint(const MultiIndex& mi,
00134     const MultipleDeriv& u,
00135     const EvalContext& context) const ;
00136       
00137       
00138       
00139   /** */
00140   const Deriv& myCoordDeriv() const {return myCoordDeriv_;}
00141 
00142   /** */
00143   const MultiIndex& mi() const {return mi_;}
00144 
00145   /** Get the functions that are required in the evaluation
00146    * of the multiple deriv d */
00147   const Sundance::Set<Deriv>& requiredFunctions(const MultipleDeriv& d) const 
00148     {return requiredFunctions_[d];}
00149 
00150   /** */
00151   bool requiresFunctionsToEval(const MultipleDeriv& d) const 
00152     {return requiredFunctions_.containsKey(d);}
00153 
00154     
00155       
00156      
00157 
00158   /** */
00159   virtual RCP<ExprBase> getRcp() {return rcp(this);}
00160 
00161 
00162   /** */
00163   virtual Evaluator* createEvaluator(const EvaluatableExpr* expr,
00164     const EvalContext& context) const ;
00165 
00166      
00167 
00168   /** */
00169   virtual void registerSpatialDerivs(const EvalContext& context, 
00170     const Set<MultiIndex>& miSet) const ;
00171 
00172   /** Ordering operator for use in transforming exprs to standard form */
00173   virtual bool lessThan(const ScalarExpr* other) const ;
00174 
00175 private:
00176 
00177       
00178       
00179 
00180   MultiIndex mi_;
00181 
00182 
00183   Deriv myCoordDeriv_;
00184 
00185   mutable Map<MultipleDeriv, Sundance::Set<Deriv>, 
00186               increasingOrder<MultipleDeriv> > requiredFunctions_;
00187 
00188   mutable bool ignoreFuncTerms_;
00189 };
00190 }
00191 
00192 
00193 #endif

Site Contact