30 #ifndef RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP
31 #define RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP
34 #include "Rythmos_SingleResidualModelEvaluatorBase.hpp"
35 #include "Thyra_ModelEvaluatorDelegatorBase.hpp"
36 #include "Thyra_ModelEvaluatorHelpers.hpp"
37 #include "Thyra_VectorStdOps.hpp"
38 #include "Thyra_TestingTools.hpp"
39 #include "Teuchos_as.hpp"
66 template<
class Scalar>
69 virtual public Thyra::ModelEvaluatorDelegatorBase<Scalar>
86 const RCP<
const Thyra::ModelEvaluator<Scalar> > &daeModel,
87 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
88 const Scalar &coeff_x_dot,
89 const RCP<
const Thyra::VectorBase<Scalar> > &x_dot_base,
90 const Scalar &coeff_x,
91 const RCP<
const Thyra::VectorBase<Scalar> > &x_base,
93 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_init
100 RCP<const Thyra::VectorBase<Scalar> >
107 RCP<const Thyra::VectorBase<Scalar> >
121 Thyra::ModelEvaluatorBase::InArgs<Scalar>
createInArgs()
const;
131 Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl()
const;
134 const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs,
135 const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs
143 Thyra::ModelEvaluatorBase::InArgs<Scalar> basePoint_;
145 RCP<const Thyra::VectorBase<Scalar> > x_dot_base_;
147 RCP<const Thyra::VectorBase<Scalar> > x_base_;
150 Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_;
153 RCP<Thyra::VectorBase<Scalar> > x_;
154 RCP<Thyra::VectorBase<Scalar> > x_dot_;
166 template<
class Scalar>
174 template<
class Scalar>
176 const RCP<
const Thyra::ModelEvaluator<Scalar> > &daeModel,
177 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
178 const Scalar &coeff_x_dot,
179 const RCP<
const Thyra::VectorBase<Scalar> > &x_dot_base,
180 const Scalar &coeff_x,
181 const RCP<
const Thyra::VectorBase<Scalar> > &x_base,
182 const Scalar &t_base,
183 const RCP<
const Thyra::VectorBase<Scalar> > &x_bar_init
186 this->Thyra::ModelEvaluatorDelegatorBase<Scalar>::initialize(daeModel);
187 basePoint_ = basePoint;
188 coeff_x_dot_ = coeff_x_dot;
189 x_dot_base_ = x_dot_base;
194 nominalValues_ = daeModel->getNominalValues();
195 nominalValues_.set_x(x_bar_init);
197 x_dot_ = createMember( daeModel->get_x_space() );
198 x_ = createMember( daeModel->get_x_space() );
202 #ifdef THYRA_RYTHMOS_DEBUG
203 std::cout <<
"----------------------------------------------------------------------" << std::endl;
204 std::cout <<
"Rythmos::SingleResidualModelEvaluator::initialize" << std::endl;
205 std::cout <<
"coeff_x_dot_ = " << coeff_x_dot_ << std::endl;
206 std::cout <<
"x_dot_base_ = ";
207 if ( x_dot_base_.get() )
208 std::cout <<
"\n" << *x_dot_base_ << std::endl;
210 std::cout <<
"null" << std::endl;
211 std::cout <<
"coeff_x_ = " << coeff_x_ << std::endl;
212 std::cout <<
"x_base_ = ";
214 std::cout <<
"\n" << *x_base_ << std::endl;
216 std::cout <<
"null" << std::endl;
217 std::cout <<
"t_base_ = " << t_base_ << std::endl;
218 std::cout <<
"x_bar_init = ";
219 if ( x_bar_init.get() )
220 std::cout <<
"\n" << *x_bar_init_ << std::endl;
222 std::cout <<
"null" << std::endl;
223 std::cout <<
"x_dot_ = ";
225 std::cout <<
"\n" << *x_dot_ << std::endl;
227 std::cout <<
"null" << std::endl;
228 std::cout <<
"x_ = ";
230 std::cout <<
"\n" << *x_ << std::endl;
232 std::cout <<
"null" << std::endl;
233 std::cout <<
"----------------------------------------------------------------------" << std::endl;
234 #endif // THYRA_RYTHMOS_DEBUG
238 template<
class Scalar>
245 template<
class Scalar>
246 RCP<const Thyra::VectorBase<Scalar> >
253 template<
class Scalar>
260 template<
class Scalar>
261 RCP<const Thyra::VectorBase<Scalar> >
268 template<
class Scalar>
278 template<
class Scalar>
279 Thyra::ModelEvaluatorBase::InArgs<Scalar>
282 return nominalValues_;
286 template<
class Scalar>
287 Thyra::ModelEvaluatorBase::InArgs<Scalar>
290 typedef Thyra::ModelEvaluatorBase MEB;
291 MEB::InArgsSetup<Scalar> inArgs;
292 inArgs.setModelEvalDescription(this->description());
293 inArgs.setSupports(MEB::IN_ARG_x);
301 template<
class Scalar>
302 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
305 typedef Thyra::ModelEvaluatorBase MEB;
306 const RCP<const Thyra::ModelEvaluator<Scalar> >
307 daeModel = this->getUnderlyingModel();
308 MEB::OutArgs<Scalar> daeOutArgs = daeModel->createOutArgs();
309 MEB::OutArgsSetup<Scalar> outArgs;
310 outArgs.setModelEvalDescription(this->description());
311 outArgs.setSupports(MEB::OUT_ARG_f);
312 if (daeOutArgs.supports(MEB::OUT_ARG_W_op)) {
313 outArgs.setSupports(MEB::OUT_ARG_W_op);
315 if (daeOutArgs.supports(MEB::OUT_ARG_W)) {
316 outArgs.setSupports(MEB::OUT_ARG_W);
322 template<
class Scalar>
323 void SingleResidualModelEvaluator<Scalar>::evalModelImpl(
324 const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs_bar,
325 const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs_bar
331 typedef Thyra::ModelEvaluatorBase MEB;
333 const RCP<const Thyra::ModelEvaluator<Scalar> >
334 daeModel = this->getUnderlyingModel();
336 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(
337 "Rythmos::SingleResidualModelEvaluator",inArgs_bar,outArgs_bar
340 const bool dumpAll = ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) );
342 const Thyra::VectorBase<Scalar> &x_bar = *inArgs_bar.get_x();
346 if (x_dot_base_.get())
347 Thyra::V_StVpV( x_dot_.ptr(), coeff_x_dot_, x_bar, *x_dot_base_ );
349 Thyra::V_StV( x_dot_.ptr(), coeff_x_dot_, x_bar);
352 *out <<
"\nx_dot_ = coeff_x_dot_ * x_bar + x_dot_base_\n";
353 *out <<
"\ncoeff_x_dot_ = " << coeff_x_dot_ << endl;
354 *out <<
"\nx_bar = " << x_bar;
355 *out <<
"\nx_dot_base_ = ";
356 if ( x_dot_base_.get() )
357 *out << *x_dot_base_;
359 *out <<
"null" << endl;
360 *out <<
"\nx_dot_ = ";
364 *out <<
"null" << endl;
370 Thyra::V_StVpV( x_.ptr(), coeff_x_, x_bar, *x_base_ );
372 Thyra::V_StV( x_.ptr(), coeff_x_, x_bar);
375 *out <<
"\nx_ = coeff_x_ * x_bar + x_base_\n";
376 *out <<
"\ncoeff_x_ = " << coeff_x_ << endl;
377 *out <<
"\nx_bar = " << x_bar;
378 *out <<
"\nx_base_ = ";
382 *out <<
"null" << endl;
387 *out <<
"null" << endl;
392 if (as<int>(verbLevel) >= as<int>(Teuchos::VERB_LOW))
393 *out <<
"\nEvaluating the underlying DAE model at (x_bar_dot,x_bar,t) ...\n";
395 RCP<Thyra::LinearOpWithSolveBase<Scalar> > W;
397 MEB::InArgs<Scalar> daeInArgs = daeModel->createInArgs();
398 daeInArgs.setArgs(basePoint_);
399 daeInArgs.set_x_dot(x_dot_);
401 daeInArgs.set_t(t_base_);
402 daeInArgs.set_alpha(coeff_x_dot_);
403 daeInArgs.set_beta(coeff_x_);
404 MEB::OutArgs<Scalar> daeOutArgs = daeModel->createOutArgs();
405 daeOutArgs.set_f(outArgs_bar.get_f());
406 if (daeOutArgs.supports(MEB::OUT_ARG_W)) {
407 daeOutArgs.set_W(outArgs_bar.get_W());
409 if (daeOutArgs.supports(MEB::OUT_ARG_W_op)) {
410 daeOutArgs.set_W_op(outArgs_bar.get_W_op());
412 daeModel->evalModel(daeInArgs,daeOutArgs);
414 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END();
422 #endif // RYTHMOS_SINGLE_RESIDUAL_MODEL_EVALUATOR_HPP
RCP< const Thyra::VectorBase< Scalar > > get_x_base() const
void initializeSingleResidualModel(const RCP< const Thyra::ModelEvaluator< Scalar > > &daeModel, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &basePoint, const Scalar &coeff_x_dot, const RCP< const Thyra::VectorBase< Scalar > > &x_dot_base, const Scalar &coeff_x, const RCP< const Thyra::VectorBase< Scalar > > &x_base, const Scalar &t_base, const RCP< const Thyra::VectorBase< Scalar > > &x_bar_init)
SingleResidualModelEvaluator()
Scalar get_coeff_x_dot() const
RCP< const Thyra::VectorBase< Scalar > > get_x_dot_base() const
Scalar get_t_base() const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Scalar get_coeff_x() const
Decorator subclass for a steady-state version of a DAE for single-residual time stepper methods...
Base class mix-in interface for single-residual model evaluators.
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const