SundanceSymbolicFuncElement.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_SYMBOLICFUNCELEMENT_H
00032 #define SUNDANCE_SYMBOLICFUNCELEMENT_H
00033 
00034 
00035 #include "SundanceDefs.hpp"
00036 #include "SundanceFuncElementBase.hpp"
00037 #include "SundanceEvaluatableExpr.hpp"
00038 #include "SundanceDiscreteFuncElement.hpp"
00039 #include "SundanceDiscreteFunctionStub.hpp"
00040 #include "SundanceSymbolicFuncEvaluator.hpp"
00041 #include "SundanceSymbolicFuncDescriptor.hpp"
00042 #include "SundanceCommonFuncDataStub.hpp"
00043 
00044 namespace Sundance
00045 {
00046   using namespace Sundance;
00047     class DiscreteFuncElement;
00048     using namespace Teuchos;
00049 
00050     
00051     
00052 
00053     /** 
00054      * SymbolicFuncElement represents a scalar-valued element of a (possibly)
00055      * list-valued SymbolicFunction. 
00056      */
00057     class SymbolicFuncElement : public FuncElementBase,
00058                                 public SymbolicFuncDescriptor,
00059                                 virtual public EvaluatableExpr,
00060                                 public GenericEvaluatorFactory<SymbolicFuncElement, SymbolicFuncElementEvaluator>
00061     {
00062     public:
00063       /** */
00064       SymbolicFuncElement(const std::string& name, 
00065         const std::string& suffix,
00066         const FunctionIdentifier& fid,
00067         const RCP<const CommonFuncDataStub>& data);
00068       
00069       /** virtual destructor */
00070       virtual ~SymbolicFuncElement() {;}
00071 
00072       /** Append to the set of func IDs present in this expression. */
00073       void accumulateFuncSet(Set<int>& funcDofIDs, 
00074         const Set<int>& activeSet) const ;
00075 
00076       /** */
00077       virtual bool hasTestFunctions() const {return false;}
00078 
00079 
00080       /** Specify that expressions involving this function are to be evaluated
00081        * with this function set to zero. Test functions should always be
00082        * evaluated at zero. For unknown functions, 
00083        * substituting zero is appropriate for computing
00084        * the functional derivatives that arise in a linear problem.
00085        * */
00086       void substituteZero() const ;
00087 
00088       /** Specify that expressions involving this function are to be evaluated
00089        * with this function set to the discrete function (or constant parameter) \f$u_0\f$. 
00090        * This is appropriate for computing
00091        * the functional derivatives that arise in a nonlinear expression
00092        * being linearized about \f$u_0\f$. 
00093        */
00094       void substituteFunction(const RCP<DiscreteFuncElement>& u0) const ;
00095 
00096       /** Return the point in function space at which this symbolic 
00097        * function is to be evaluated. */
00098       const EvaluatableExpr* evalPt() const {return evalPt_.get();}
00099 
00100       /** Return the point in function space at which this symbolic 
00101        * function is to be evaluated. */
00102       EvaluatableExpr* evalPt() {return evalPt_.get();}
00103 
00104 
00105       /** */
00106       bool evalPtIsZero() const ;
00107 
00108       /** */
00109       const RCP<const CommonFuncDataStub>& commonData() const {return commonData_;}
00110 
00111 
00112       /** \name Preprocessing */
00113       //@{
00114       /** */
00115       virtual Set<MultipleDeriv> 
00116       internalFindW(int order, const EvalContext& context) const ;
00117           
00118       /** */
00119       virtual Set<MultipleDeriv> 
00120       internalFindV(int order, const EvalContext& context) const ;
00121           
00122       /** */
00123       virtual Set<MultipleDeriv> 
00124       internalFindC(int order, const EvalContext& context) const ;
00125 
00126       /** */
00127       virtual RCP<Array<Set<MultipleDeriv> > > 
00128       internalDetermineR(const EvalContext& context,
00129                          const Array<Set<MultipleDeriv> >& RInput) const ;
00130       /** */
00131       virtual void registerSpatialDerivs(const EvalContext& context, 
00132                                          const Set<MultiIndex>& miSet) const ;
00133       //@}
00134       
00135 
00136       /** Indicate whether the expression is independent of the given 
00137        * functions */
00138       virtual bool isIndependentOf(const Expr& u) const ;
00139 
00140       
00141       /** Indicate whether the expression is linear in the given 
00142        * functions */
00143       virtual bool isLinearForm(const Expr& u) const ;
00144       
00145       /** */
00146       virtual RCP<ExprBase> getRcp() {return rcp(this);}
00147       
00148     private:
00149       RCP<const CommonFuncDataStub> commonData_;
00150 
00151       mutable RCP<EvaluatableExpr> evalPt_;
00152 
00153       mutable Array<int> evalPtDerivSetIndices_;
00154     };
00155 }
00156 
00157 #endif

Site Contact