11 #ifndef PANZER_EXPLICIT_MODEL_EVALUATOR_IMPL_HPP
12 #define PANZER_EXPLICIT_MODEL_EVALUATOR_IMPL_HPP
14 #include "Thyra_DefaultDiagonalLinearOp.hpp"
15 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
17 #include "PanzerDiscFE_config.hpp"
18 #ifdef PANZER_HAVE_EPETRA_STACK
19 #include "Thyra_EpetraModelEvaluator.hpp"
20 #include "Thyra_get_Epetra_Operator.hpp"
26 template<
typename Scalar>
29 bool constantMassMatrix,
31 bool applyMassInverse)
32 : Thyra::ModelEvaluatorDelegatorBase<Scalar>(model)
33 , constantMassMatrix_(constantMassMatrix)
34 , massLumping_(useLumpedMass)
37 using Teuchos::rcp_dynamic_cast;
44 #ifdef PANZER_HAVE_EPETRA_STACK
47 if(epME!=Teuchos::null)
55 template<
typename Scalar>
59 typedef Thyra::ModelEvaluatorBase MEB;
61 MEB::InArgs<Scalar> nomVals = createInArgs();
62 nomVals.setArgs(this->getUnderlyingModel()->getNominalValues(),
true);
67 template<
typename Scalar>
71 return prototypeInArgs_;
74 template<
typename Scalar>
78 return prototypeOutArgs_;
81 template<
typename Scalar>
88 template<
typename Scalar>
91 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
93 typedef Thyra::ModelEvaluatorBase MEB;
97 MEB::InArgs<Scalar> under_inArgs = under_me->createInArgs();
98 under_inArgs.setArgs(inArgs);
101 under_inArgs.set_x_dot(inArgs.get_x_dot());
102 under_inArgs.set_alpha(0.0);
106 MEB::OutArgs<Scalar> under_outArgs = under_me->createOutArgs();
107 under_outArgs.setArgs(outArgs);
108 if(f!=Teuchos::null) {
110 if(scrap_f_==Teuchos::null)
111 scrap_f_ = Thyra::createMember(*under_me->get_f_space());
113 Thyra::assign(scrap_f_.ptr(),0.0);
114 under_outArgs.set_f(scrap_f_);
117 under_me->evalModel(under_inArgs,under_outArgs);
120 if(invMassMatrix_==Teuchos::null || constantMassMatrix_==
false)
121 buildInverseMassMatrix(inArgs);
124 Thyra::Vt_S(scrap_f_.ptr(),-1.0);
127 if(f!=Teuchos::null && this->applyMassInverse_) {
128 Thyra::apply(*invMassMatrix_,Thyra::NOTRANS,*scrap_f_,f.
ptr());
130 else if(f!=Teuchos::null){
131 Thyra::V_V(f.
ptr(),*scrap_f_);
135 template<
typename Scalar>
139 typedef Thyra::ModelEvaluatorBase MEB;
141 using Thyra::createMember;
146 mass_ = me->create_W_op();
149 if(zero_==Teuchos::null) {
150 zero_ = Thyra::createMember(*me->get_x_space());
151 Thyra::assign(zero_.ptr(),0.0);
156 MEB::InArgs<Scalar> inArgs_new = me->createInArgs();
157 inArgs_new.setArgs(inArgs);
158 inArgs_new.set_x_dot(inArgs.get_x_dot());
159 inArgs_new.set_alpha(1.0);
160 inArgs_new.set_beta(0.0);
165 if(panzerModel_!=Teuchos::null)
166 panzerModel_->setOneTimeDirichletBeta(1.0);
167 #ifdef PANZER_HAVE_EPETRA_STACK
168 else if(panzerEpetraModel_!=Teuchos::null)
169 panzerEpetraModel_->setOneTimeDirichletBeta(1.0);
175 setOneTimeDirichletBeta(1.0,*this->getUnderlyingModel());
179 MEB::OutArgs<Scalar> outArgs = me->createOutArgs();
180 outArgs.set_W_op(mass_);
183 me->evalModel(inArgs_new,outArgs);
189 invMassMatrix_ = Thyra::inverse<Scalar>(*me->get_W_factory(),mass_);
194 Thyra::assign(ones.
ptr(),1.0);
197 Thyra::apply(*mass_,Thyra::NOTRANS,*ones,invLumpMass.
ptr());
198 Thyra::reciprocal(*invLumpMass,invLumpMass.
ptr());
200 invMassMatrix_ = Thyra::diagonal(invLumpMass);
204 template<
typename Scalar>
208 typedef Thyra::ModelEvaluatorBase MEB;
210 MEB::InArgsSetup<Scalar> inArgs(this->getUnderlyingModel()->createInArgs());
211 inArgs.setModelEvalDescription(this->description());
212 inArgs.setSupports(MEB::IN_ARG_alpha,
true);
213 inArgs.setSupports(MEB::IN_ARG_beta,
true);
214 inArgs.setSupports(MEB::IN_ARG_x_dot,
true);
215 prototypeInArgs_ = inArgs;
217 MEB::OutArgsSetup<Scalar> outArgs(this->getUnderlyingModel()->createOutArgs());
218 outArgs.setModelEvalDescription(this->description());
219 outArgs.setSupports(MEB::OUT_ARG_W,
false);
220 outArgs.setSupports(MEB::OUT_ARG_W_op,
false);
221 prototypeOutArgs_ = outArgs;
224 template<
typename Scalar>
229 using Teuchos::ptrFromRef;
230 using Teuchos::ptr_dynamic_cast;
234 if(panzerModel!=Teuchos::null) {
239 #ifdef PANZER_HAVE_EPETRA_STACK
240 Ptr<const Thyra::EpetraModelEvaluator> epModel = ptr_dynamic_cast<
const Thyra::EpetraModelEvaluator>(ptrFromRef(me));
241 if(epModel!=Teuchos::null) {
242 Ptr<const panzer::ModelEvaluator_Epetra> panzerEpetraModel
245 if(panzerEpetraModel!=Teuchos::null) {
256 Ptr<const Thyra::ModelEvaluatorDelegatorBase<Scalar> > delegator
257 = ptr_dynamic_cast<
const Thyra::ModelEvaluatorDelegatorBase<Scalar> >(ptrFromRef(me));
258 if(delegator!=Teuchos::null) {
259 setOneTimeDirichletBeta(beta,*delegator->getUnderlyingModel());
264 "panzer::ExplicitModelEvaluator::setOneTimeDirichletBeta can't find a panzer::ME or a panzer::EpetraME. "
265 "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.
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