43 #ifndef PANZER_EXPLICIT_MODEL_EVALUATOR_IMPL_HPP
44 #define PANZER_EXPLICIT_MODEL_EVALUATOR_IMPL_HPP
46 #include "Thyra_EpetraModelEvaluator.hpp"
47 #include "Thyra_DefaultDiagonalLinearOp.hpp"
48 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
50 #include "Thyra_get_Epetra_Operator.hpp"
55 template<
typename Scalar>
58 bool constantMassMatrix,
60 bool applyMassInverse)
61 : Thyra::ModelEvaluatorDelegatorBase<Scalar>(model)
62 , constantMassMatrix_(constantMassMatrix)
63 , massLumping_(useLumpedMass)
66 using Teuchos::rcp_dynamic_cast;
75 if(epME!=Teuchos::null)
83 template<
typename Scalar>
87 typedef Thyra::ModelEvaluatorBase MEB;
89 MEB::InArgs<Scalar> nomVals = createInArgs();
90 nomVals.setArgs(this->getUnderlyingModel()->getNominalValues(),
true);
95 template<
typename Scalar>
99 return prototypeInArgs_;
102 template<
typename Scalar>
106 return prototypeOutArgs_;
109 template<
typename Scalar>
116 template<
typename Scalar>
119 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
121 typedef Thyra::ModelEvaluatorBase MEB;
125 MEB::InArgs<Scalar> under_inArgs = under_me->createInArgs();
126 under_inArgs.setArgs(inArgs);
129 under_inArgs.set_x_dot(inArgs.get_x_dot());
130 under_inArgs.set_alpha(0.0);
134 MEB::OutArgs<Scalar> under_outArgs = under_me->createOutArgs();
135 under_outArgs.setArgs(outArgs);
136 if(f!=Teuchos::null) {
138 if(scrap_f_==Teuchos::null)
139 scrap_f_ = Thyra::createMember(*under_me->get_f_space());
141 Thyra::assign(scrap_f_.ptr(),0.0);
142 under_outArgs.set_f(scrap_f_);
145 under_me->evalModel(under_inArgs,under_outArgs);
148 if(invMassMatrix_==Teuchos::null || constantMassMatrix_==
false)
149 buildInverseMassMatrix(inArgs);
152 Thyra::Vt_S(scrap_f_.ptr(),-1.0);
155 if(f!=Teuchos::null && this->applyMassInverse_) {
156 Thyra::apply(*invMassMatrix_,Thyra::NOTRANS,*scrap_f_,f.
ptr());
158 else if(f!=Teuchos::null){
159 Thyra::V_V(f.
ptr(),*scrap_f_);
163 template<
typename Scalar>
167 typedef Thyra::ModelEvaluatorBase MEB;
169 using Thyra::createMember;
174 mass_ = me->create_W_op();
177 if(zero_==Teuchos::null) {
178 zero_ = Thyra::createMember(*me->get_x_space());
179 Thyra::assign(zero_.ptr(),0.0);
184 MEB::InArgs<Scalar> inArgs_new = me->createInArgs();
185 inArgs_new.setArgs(inArgs);
186 inArgs_new.set_x_dot(inArgs.get_x_dot());
187 inArgs_new.set_alpha(1.0);
188 inArgs_new.set_beta(0.0);
193 if(panzerModel_!=Teuchos::null)
194 panzerModel_->setOneTimeDirichletBeta(1.0);
195 else if(panzerEpetraModel_!=Teuchos::null)
196 panzerEpetraModel_->setOneTimeDirichletBeta(1.0);
201 setOneTimeDirichletBeta(1.0,*this->getUnderlyingModel());
205 MEB::OutArgs<Scalar> outArgs = me->createOutArgs();
206 outArgs.set_W_op(mass_);
209 me->evalModel(inArgs_new,outArgs);
215 invMassMatrix_ = Thyra::inverse<Scalar>(*me->get_W_factory(),mass_);
220 Thyra::assign(ones.
ptr(),1.0);
223 Thyra::apply(*mass_,Thyra::NOTRANS,*ones,invLumpMass.
ptr());
224 Thyra::reciprocal(*invLumpMass,invLumpMass.
ptr());
226 invMassMatrix_ = Thyra::diagonal(invLumpMass);
230 template<
typename Scalar>
234 typedef Thyra::ModelEvaluatorBase MEB;
236 MEB::InArgsSetup<Scalar> inArgs(this->getUnderlyingModel()->createInArgs());
237 inArgs.setModelEvalDescription(this->description());
238 inArgs.setSupports(MEB::IN_ARG_alpha,
true);
239 inArgs.setSupports(MEB::IN_ARG_beta,
true);
240 inArgs.setSupports(MEB::IN_ARG_x_dot,
true);
241 prototypeInArgs_ = inArgs;
243 MEB::OutArgsSetup<Scalar> outArgs(this->getUnderlyingModel()->createOutArgs());
244 outArgs.setModelEvalDescription(this->description());
245 outArgs.setSupports(MEB::OUT_ARG_W,
false);
246 outArgs.setSupports(MEB::OUT_ARG_W_op,
false);
247 prototypeOutArgs_ = outArgs;
250 template<
typename Scalar>
255 using Teuchos::ptrFromRef;
256 using Teuchos::ptr_dynamic_cast;
260 if(panzerModel!=Teuchos::null) {
265 Ptr<const Thyra::EpetraModelEvaluator> epModel = ptr_dynamic_cast<
const Thyra::EpetraModelEvaluator>(ptrFromRef(me));
266 if(epModel!=Teuchos::null) {
267 Ptr<const panzer::ModelEvaluator_Epetra> panzerEpetraModel
270 if(panzerEpetraModel!=Teuchos::null) {
280 Ptr<const Thyra::ModelEvaluatorDelegatorBase<Scalar> > delegator
281 = ptr_dynamic_cast<
const Thyra::ModelEvaluatorDelegatorBase<Scalar> >(ptrFromRef(me));
282 if(delegator!=Teuchos::null) {
283 setOneTimeDirichletBeta(beta,*delegator->getUnderlyingModel());
288 "panzer::ExplicitModelEvaluator::setOneTimeDirichletBeta can't find a panzer::ME or a panzer::EpetraME. "
289 "The deepest model is also not a delegator. Thus the recursion failed and an exception was generated.");
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Build the in args, modifies the underlying models in args slightly.
void buildArgsPrototypes()
Build prototype in/out args.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void setOneTimeDirichletBeta(const Scalar &beta) const
Teuchos::RCP< panzer::ModelEvaluator< Scalar > > getPanzerUnderlyingModel()
Get the underlying panzer::ModelEvaluator.
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Evaluation of model, applies the mass matrix to the RHS.
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Build the nominal values, modifies the underlying models in args slightly.
Teuchos::RCP< const panzer::ModelEvaluator_Epetra > panzerEpetraModel_
Access to the epetra panzer model evaluator pointer.
void setOneTimeDirichletBeta(double beta, const Thyra::ModelEvaluator< Scalar > &me) const
bool applyMassInverse_
Apply mass matrix inverse within the evaluator.
Teuchos::RCP< const panzer::ModelEvaluator< Scalar > > panzerModel_
Access to the panzer model evaluator pointer (thyra version)
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgs() const
Build the out args, modifies the underlying models in args slightly.
void buildInverseMassMatrix(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs) const
void setOneTimeDirichletBeta(const double &beta) const