SundanceSymbolicFuncElement.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #ifndef SUNDANCE_SYMBOLICFUNCELEMENT_H
00043 #define SUNDANCE_SYMBOLICFUNCELEMENT_H
00044 
00045 
00046 #include "SundanceDefs.hpp"
00047 #include "SundanceFuncElementBase.hpp"
00048 #include "SundanceEvaluatableExpr.hpp"
00049 #include "SundanceDiscreteFuncElement.hpp"
00050 #include "SundanceDiscreteFunctionStub.hpp"
00051 #include "SundanceSymbolicFuncEvaluator.hpp"
00052 #include "SundanceSymbolicFuncDescriptor.hpp"
00053 #include "SundanceCommonFuncDataStub.hpp"
00054 
00055 namespace Sundance
00056 {
00057   using namespace Sundance;
00058     class DiscreteFuncElement;
00059     using namespace Teuchos;
00060 
00061     
00062     
00063 
00064     /** 
00065      * SymbolicFuncElement represents a scalar-valued element of a (possibly)
00066      * list-valued SymbolicFunction. 
00067      */
00068     class SymbolicFuncElement : public FuncElementBase,
00069                                 public SymbolicFuncDescriptor,
00070                                 virtual public EvaluatableExpr,
00071                                 public GenericEvaluatorFactory<SymbolicFuncElement, SymbolicFuncElementEvaluator>
00072     {
00073     public:
00074       /** */
00075       SymbolicFuncElement(const std::string& name, 
00076         const std::string& suffix,
00077         const FunctionIdentifier& fid,
00078         const RCP<const CommonFuncDataStub>& data);
00079       
00080       /** virtual destructor */
00081       virtual ~SymbolicFuncElement() {;}
00082 
00083       /** Append to the set of func IDs present in this expression. */
00084       void accumulateFuncSet(Set<int>& funcDofIDs, 
00085         const Set<int>& activeSet) const ;
00086 
00087       /** */
00088       virtual bool hasTestFunctions() const {return false;}
00089 
00090 
00091       /** Specify that expressions involving this function are to be evaluated
00092        * with this function set to zero. Test functions should always be
00093        * evaluated at zero. For unknown functions, 
00094        * substituting zero is appropriate for computing
00095        * the functional derivatives that arise in a linear problem.
00096        * */
00097       void substituteZero() const ;
00098 
00099       /** Specify that expressions involving this function are to be evaluated
00100        * with this function set to the discrete function (or constant parameter) \f$u_0\f$. 
00101        * This is appropriate for computing
00102        * the functional derivatives that arise in a nonlinear expression
00103        * being linearized about \f$u_0\f$. 
00104        */
00105       void substituteFunction(const RCP<DiscreteFuncElement>& u0) const ;
00106 
00107       /** Return the point in function space at which this symbolic 
00108        * function is to be evaluated. */
00109       const EvaluatableExpr* evalPt() const {return evalPt_.get();}
00110 
00111       /** Return the point in function space at which this symbolic 
00112        * function is to be evaluated. */
00113       EvaluatableExpr* evalPt() {return evalPt_.get();}
00114 
00115 
00116       /** */
00117       bool evalPtIsZero() const ;
00118 
00119       /** */
00120       const RCP<const CommonFuncDataStub>& commonData() const {return commonData_;}
00121 
00122 
00123       /** \name Preprocessing */
00124       //@{
00125       /** */
00126       virtual Set<MultipleDeriv> 
00127       internalFindW(int order, const EvalContext& context) const ;
00128           
00129       /** */
00130       virtual Set<MultipleDeriv> 
00131       internalFindV(int order, const EvalContext& context) const ;
00132           
00133       /** */
00134       virtual Set<MultipleDeriv> 
00135       internalFindC(int order, const EvalContext& context) const ;
00136 
00137       /** */
00138       virtual RCP<Array<Set<MultipleDeriv> > > 
00139       internalDetermineR(const EvalContext& context,
00140                          const Array<Set<MultipleDeriv> >& RInput) const ;
00141       /** */
00142       virtual void registerSpatialDerivs(const EvalContext& context, 
00143                                          const Set<MultiIndex>& miSet) const ;
00144       //@}
00145       
00146 
00147       /** Indicate whether the expression is independent of the given 
00148        * functions */
00149       virtual bool isIndependentOf(const Expr& u) const ;
00150 
00151       
00152       /** Indicate whether the expression is linear in the given 
00153        * functions */
00154       virtual bool isLinearForm(const Expr& u) const ;
00155       
00156       /** */
00157       virtual RCP<ExprBase> getRcp() {return rcp(this);}
00158       
00159     private:
00160       RCP<const CommonFuncDataStub> commonData_;
00161 
00162       mutable RCP<EvaluatableExpr> evalPt_;
00163 
00164       mutable Array<int> evalPtDerivSetIndices_;
00165     };
00166 }
00167 
00168 #endif

Site Contact