9 #ifndef Tempus_AuxiliaryIntegralModelEvaluator_impl_hpp
10 #define Tempus_AuxiliaryIntegralModelEvaluator_impl_hpp
14 #include "Thyra_VectorStdOps.hpp"
18 template <
typename Scalar>
21 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> > & model,
25 t_interp_(Teuchos::ScalarTraits<Scalar>::rmax())
27 typedef Thyra::ModelEvaluatorBase MEB;
31 MEB::InArgs<Scalar> me_inArgs =
model_->createInArgs();
32 MEB::InArgsSetup<Scalar> inArgs;
33 inArgs.setModelEvalDescription(this->description());
34 inArgs.setSupports(MEB::IN_ARG_x);
35 inArgs.setSupports(MEB::IN_ARG_t);
36 if (me_inArgs.supports(MEB::IN_ARG_x_dot))
37 inArgs.setSupports(MEB::IN_ARG_x_dot);
38 inArgs.setSupports(MEB::IN_ARG_alpha);
39 inArgs.setSupports(MEB::IN_ARG_beta);
40 inArgs.set_Np(me_inArgs.Np());
43 MEB::OutArgs<Scalar> me_outArgs =
model_->createOutArgs();
44 MEB::OutArgsSetup<Scalar> outArgs;
45 outArgs.setModelEvalDescription(this->description());
46 outArgs.set_Np_Ng(me_inArgs.Np(),0);
47 outArgs.setSupports(MEB::OUT_ARG_f);
48 outArgs.setSupports(MEB::OUT_ARG_W_op);
52 template <
typename Scalar>
59 t_interp_ = Teuchos::ScalarTraits<Scalar>::rmax();
60 forward_state_ = Teuchos::null;
63 template <
typename Scalar>
64 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
68 TEUCHOS_ASSERT(p < model_->Np());
69 return model_->get_p_space(p);
72 template <
typename Scalar>
73 Teuchos::RCP<const Teuchos::Array<std::string> >
77 TEUCHOS_ASSERT(p < model_->Np());
78 return model_->get_p_names(p);
81 template <
typename Scalar>
82 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
89 template <
typename Scalar>
90 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
97 template <
typename Scalar>
98 Teuchos::RCP<Thyra::LinearOpBase<Scalar> >
102 return Thyra::scaledIdentity(space_, Scalar(1.0));
105 template <
typename Scalar>
106 Teuchos::RCP<const Thyra::LinearOpWithSolveFactoryBase<Scalar> >
110 return Thyra::scaledIdentitySolveFactory(space_, Scalar(1.0));
113 template <
typename Scalar>
114 Thyra::ModelEvaluatorBase::InArgs<Scalar>
118 return prototypeInArgs_;
121 template <
typename Scalar>
122 Thyra::ModelEvaluatorBase::InArgs<Scalar>
126 typedef Thyra::ModelEvaluatorBase MEB;
128 using Teuchos::rcp_dynamic_cast;
130 MEB::InArgs<Scalar> me_nominal = model_->getNominalValues();
131 MEB::InArgs<Scalar> nominal = this->createInArgs();
133 const Scalar zero = Teuchos::ScalarTraits<Scalar>::zero();
136 RCP< Thyra::VectorBase<Scalar> > x = Thyra::createMember(*space_);
137 Thyra::assign(x.ptr(), zero);
140 if (me_nominal.supports(MEB::IN_ARG_x_dot)) {
141 RCP< Thyra::VectorBase<Scalar> > x_dot = Thyra::createMember(*space_);
142 Thyra::assign(x_dot.ptr(), zero);
143 nominal.set_x_dot(x_dot);
146 const int np = model_->Np();
147 for (
int i=0; i<np; ++i)
148 nominal.set_p(i, me_nominal.get_p(i));
153 template <
typename Scalar>
154 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
158 return prototypeOutArgs_;
161 template <
typename Scalar>
165 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
167 typedef Thyra::ModelEvaluatorBase MEB;
169 using Teuchos::rcp_dynamic_cast;
173 TEUCHOS_ASSERT(sh_ != Teuchos::null);
174 const Scalar t = inArgs.get_t();
175 if (forward_state_ == Teuchos::null || t_interp_ != t) {
176 if (forward_state_ == Teuchos::null)
177 forward_state_ = sh_->interpolateState(t);
179 sh_->interpolateState(t, forward_state_.get());
184 RCP<Thyra::VectorBase<Scalar> > f = outArgs.get_f();
185 if (f != Teuchos::null) {
186 MEB::InArgs<Scalar> me_inArgs = model_->getNominalValues();
187 me_inArgs.set_x(forward_state_->getX());
188 if (me_inArgs.supports(MEB::IN_ARG_x_dot))
189 me_inArgs.set_x_dot(forward_state_->getXDot());
190 if (me_inArgs.supports(MEB::IN_ARG_t))
192 const int np = me_inArgs.Np();
193 for (
int i=0; i<np; ++i)
194 me_inArgs.set_p(i, inArgs.get_p(i));
196 MEB::OutArgs<Scalar> me_outArgs = model_->createOutArgs();
197 me_outArgs.set_g(g_index_, f);
199 model_->evalModel(me_inArgs, me_outArgs);
203 if (inArgs.supports(MEB::IN_ARG_x_dot)) {
204 RCP<const Thyra::VectorBase<Scalar> > x_dot = inArgs.get_x_dot();
205 if (x_dot != Teuchos::null)
206 Thyra::V_VmV(f.ptr(), *x_dot, *f);
211 RCP<Thyra::LinearOpBase<Scalar> > op = outArgs.get_W_op();
212 if (op != Teuchos::null) {
213 const Scalar alpha = inArgs.get_alpha();
214 RCP<Thyra::ScaledIdentityLinearOpWithSolve<Scalar> > si_op =
Implicit concrete LinearOpBase subclass that takes a flattended out multi-vector and performs a multi...
AuxiliaryIntegralModelEvaluator(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, const int g_index)
Constructor.
void setScale(const Scalar &s)
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > prototypeInArgs_
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
void setForwardSolutionHistory(const Teuchos::RCP< const Tempus::SolutionHistory< Scalar > > &sh)
Set solution history from forward evaluation.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > space_
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int p) const
void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Thyra::ModelEvaluatorBase::OutArgs< Scalar > prototypeOutArgs_
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int p) const
Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > model_
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const