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_EVALMANAGER_H 00032 #define SUNDANCE_EVALMANAGER_H 00033 00034 #include "SundanceDefs.hpp" 00035 #include "SundanceEvalContext.hpp" 00036 #include "SundanceAbstractEvalMediator.hpp" 00037 #include "SundanceTempStack.hpp" 00038 #include "SundanceNoncopyable.hpp" 00039 #include "Teuchos_TimeMonitor.hpp" 00040 00041 namespace Sundance 00042 { 00043 using namespace Sundance; 00044 class CoordExpr; 00045 class MultiIndex; 00046 class DiscreteFuncElement; 00047 00048 00049 /** 00050 * EvalManager provides methods for interfacing to the framework 00051 * through an AbstractEvalMediator and managing temporary variables 00052 * through a TempStack. 00053 * 00054 * If no mediator is set, std::string evaluations will be done 00055 */ 00056 class EvalManager : public Noncopyable 00057 { 00058 public: 00059 /** Empty ctor */ 00060 EvalManager(); 00061 00062 /** */ 00063 void evalCoordExpr(const CoordExpr* expr, 00064 RCP<EvalVector>& result) const ; 00065 00066 /** */ 00067 void evalCellDiameterExpr(const CellDiameterExpr* expr, 00068 RCP<EvalVector>& result) const ; 00069 00070 /** */ 00071 void evalCurveNormExpr(const CurveNormExpr* expr, 00072 RCP<EvalVector>& result) const ; 00073 00074 /** */ 00075 void evalCellVectorExpr(const CellVectorExpr* expr, 00076 RCP<EvalVector>& result) const ; 00077 00078 /** */ 00079 void evalDiscreteFuncElement(const DiscreteFuncElement* expr, 00080 const Array<MultiIndex>& mi, 00081 Array<RCP<EvalVector> >& result) const ; 00082 00083 /** */ 00084 void setMediator(const RCP<AbstractEvalMediator>& med) 00085 {mediator_ = med;} 00086 00087 /** */ 00088 void setVerbosity(int verb) ; 00089 00090 00091 /** */ 00092 int verb() const {return verb_;} 00093 00094 /** */ 00095 void setVecSize(int vecSize) {stack().setVecSize(vecSize);} 00096 00097 00098 /** Return a pointer to the mediator. We'll need the 00099 * mediator for computing framework-specific functions. 00100 */ 00101 const AbstractEvalMediator* mediator() const {return mediator_.get();} 00102 00103 /** */ 00104 void setRegion(const EvalContext& region) 00105 {region_ = region;} 00106 00107 /** */ 00108 const EvalContext& getRegion() const {return region_;} 00109 00110 /** */ 00111 static TempStack& stack(); 00112 00113 /** */ 00114 int getMaxDiffOrder() const ; 00115 00116 00117 /** */ 00118 RCP<EvalVector> popVector() const ; 00119 00120 /** */ 00121 TEUCHOS_TIMER(coordEvalTimer, "coord function evaluation"); 00122 00123 /** */ 00124 TEUCHOS_TIMER(discFuncEvalTimer, "discrete function evaluation"); 00125 00126 private: 00127 int verb_; 00128 00129 EvalContext region_; 00130 00131 RCP<AbstractEvalMediator> mediator_; 00132 00133 }; 00134 00135 } 00136 00137 #endif