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 #include "SundanceSubtypeEvaluator.hpp"
00032 #include "SundanceEvalManager.hpp"
00033 #include "SundanceCellVectorExpr.hpp"
00034 #include "PlayaExceptions.hpp"
00035 #include "SundanceSet.hpp"
00036 #include "PlayaTabs.hpp"
00037 #include "SundanceOut.hpp"
00038
00039 using namespace Sundance;
00040 using namespace Sundance;
00041
00042 using namespace Sundance;
00043 using namespace Teuchos;
00044
00045
00046 CellVectorEvaluator::CellVectorEvaluator(const CellVectorExpr* expr,
00047 const EvalContext& context)
00048 : SubtypeEvaluator<CellVectorExpr>(expr, context),
00049 dim_(expr->dimension()),
00050 isTangentVector_(expr->isTangent()),
00051 basisVectorIndex_(expr->basisMemberIndex()),
00052 componentIndex_(expr->componentIndex()),
00053 stringRep_(expr->toString())
00054 {
00055
00056 Tabs tabs;
00057 int verb = context.setupVerbosity();
00058 SUNDANCE_MSG1(verb, tabs << "initializing cell vector evaluator for "
00059 << expr->toString());
00060 SUNDANCE_MSG2(verb, tabs << "return sparsity "
00061 << std::endl << *(this->sparsity)());
00062
00063 TEUCHOS_TEST_FOR_EXCEPTION(this->sparsity()->numDerivs() >1 , std::logic_error,
00064 "CellVectorEvaluator ctor found a sparsity table "
00065 "with more than one entry. The bad sparsity table is "
00066 << *(this->sparsity)());
00067
00068
00069
00070
00071
00072
00073 for (int i=0; i<this->sparsity()->numDerivs(); i++)
00074 {
00075 const MultipleDeriv& d = this->sparsity()->deriv(i);
00076
00077
00078 TEUCHOS_TEST_FOR_EXCEPTION(d.order() != 0, std::runtime_error,
00079 "Derivative " << d << " is not valid for "
00080 "CellVectorEvaluator");
00081 addVectorIndex(i, 0);
00082 }
00083
00084 }
00085
00086
00087
00088 void CellVectorEvaluator::internalEval(const EvalManager& mgr,
00089 Array<double>& constantResults,
00090 Array<RCP<EvalVector> >& vectorResults) const
00091 {
00092 Tabs tabs(0);
00093
00094 SUNDANCE_MSG1(mgr.verb(), tabs << "CellVectorEvaluator::eval() expr="
00095 << expr()->toString());
00096
00097 SUNDANCE_MSG3(mgr.verb(),
00098 tabs << "sparsity = " << std::endl << tabs << *(this->sparsity)());
00099
00100 vectorResults.resize(1);
00101 vectorResults[0] = mgr.popVector();
00102 SUNDANCE_MSG4(mgr.verb(), tabs << "forwarding to evaluation manager");
00103 mgr.evalCellVectorExpr(expr(), vectorResults[0]);
00104 mgr.stack().setVecSize(vectorResults[0]->length());
00105 vectorResults[0]->setString(stringRep_);
00106
00107 if (mgr.verb() > 1)
00108 {
00109 Tabs tab1;
00110 Out::os() << tab1 << "results " << std::endl;
00111 mgr.showResults(Out::os(), this->sparsity(), vectorResults,
00112 constantResults);
00113 }
00114
00115 }
00116