Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceSubtypeEvaluator.hpp"
00043 #include "SundanceEvalManager.hpp"
00044 #include "SundanceSpatiallyConstantExpr.hpp"
00045 #include "SundanceSet.hpp"
00046 #include "PlayaTabs.hpp"
00047 #include "SundanceOut.hpp"
00048
00049 using namespace Sundance;
00050 using namespace Sundance;
00051
00052 using namespace Sundance;
00053 using namespace Teuchos;
00054
00055
00056
00057
00058 ConstantEvaluator::ConstantEvaluator(const SpatiallyConstantExpr* expr,
00059 const EvalContext& context)
00060 : SubtypeEvaluator<SpatiallyConstantExpr>(expr, context)
00061 {
00062 Tabs tab;
00063 SUNDANCE_MSG1(context.setupVerbosity(), tab << "in ConstantEvaluator ctor");
00064
00065
00066
00067
00068
00069
00070
00071 TEUCHOS_TEST_FOR_EXCEPTION(this->sparsity()->numDerivs() > 1, std::logic_error,
00072 "ConstantEvaluator ctor found a sparsity table "
00073 "without more than one entry. The bad sparsity table is "
00074 << *(this->sparsity)());
00075
00076 if (this->sparsity()->numDerivs() > 0)
00077 {
00078 const MultipleDeriv& d = this->sparsity()->deriv(0);
00079
00080 TEUCHOS_TEST_FOR_EXCEPTION(d.order() != 0, std::logic_error,
00081 "ConstantEvaluator ctor found a nonzero derivative "
00082 "of order greater than zero. The bad sparsity "
00083 "table is " << *(this->sparsity)());
00084 addConstantIndex(0,0);
00085 }
00086 }
00087
00088
00089
00090
00091
00092 void ConstantEvaluator::internalEval(const EvalManager& mgr,
00093 Array<double>& constantResults,
00094 Array<RCP<EvalVector> >& vectorResults) const
00095 {
00096 Tabs tabs;
00097 SUNDANCE_MSG1(mgr.verb(), tabs << "ConstantEvaluator::eval() expr="
00098 << expr()->toString());
00099
00100 if (this->sparsity()->numDerivs() > 0)
00101 {
00102 constantResults.resize(1);
00103 constantResults[0] = expr()->value();
00104
00105 SUNDANCE_MSG2(mgr.verb(), tabs << "result=" << constantResults[0]);
00106 }
00107 else
00108 {
00109 SUNDANCE_MSG2(mgr.verb(), tabs << "no results requested");
00110 }
00111 }