void assertValidModel( const StepperBase<Scalar>& stepper, const Thyra::ModelEvaluator<Scalar>& model ) { typedef Thyra::ModelEvaluatorBase MEB; TEUCHOS_ASSERT(stepper.acceptsModel()); const MEB::InArgs<Scalar> inArgs = model.createInArgs(); const MEB::OutArgs<Scalar> outArgs = model.createOutArgs(); //TEUCHOS_ASSERT(inArgs.supports(MEB::IN_ARG_t)); TEUCHOS_ASSERT(inArgs.supports(MEB::IN_ARG_x)); TEUCHOS_ASSERT(outArgs.supports(MEB::OUT_ARG_f)); if (stepper.isImplicit()) { // implicit stepper TEUCHOS_ASSERT( inArgs.supports(MEB::IN_ARG_x_dot) ); TEUCHOS_ASSERT( inArgs.supports(MEB::IN_ARG_alpha) ); TEUCHOS_ASSERT( inArgs.supports(MEB::IN_ARG_beta) ); TEUCHOS_ASSERT( outArgs.supports(MEB::OUT_ARG_W) ); } //else { // explicit stepper // TEUCHOS_ASSERT( !inArgs.supports(MEB::IN_ARG_x_dot) ); // TEUCHOS_ASSERT( !inArgs.supports(MEB::IN_ARG_alpha) ); // TEUCHOS_ASSERT( !inArgs.supports(MEB::IN_ARG_beta) ); // TEUCHOS_ASSERT( !outArgs.supports(MEB::OUT_ARG_W) ); //} }
void eval_model_explicit( const Thyra::ModelEvaluator<Scalar> &model, Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint, const VectorBase<Scalar>& x_in, const typename Thyra::ModelEvaluatorBase::InArgs<Scalar>::ScalarMag &t_in, const Ptr<VectorBase<Scalar> >& f_out ) { typedef Thyra::ModelEvaluatorBase MEB; MEB::InArgs<Scalar> inArgs = model.createInArgs(); MEB::OutArgs<Scalar> outArgs = model.createOutArgs(); inArgs.setArgs(basePoint); inArgs.set_x(Teuchos::rcp(&x_in,false)); if (inArgs.supports(MEB::IN_ARG_t)) { inArgs.set_t(t_in); } // For model evaluators whose state function f(x, x_dot, t) describes // an implicit ODE, and which accept an optional x_dot input argument, // make sure the latter is set to null in order to request the evaluation // of a state function corresponding to the explicit ODE formulation // x_dot = f(x, t) if (inArgs.supports(MEB::IN_ARG_x_dot)) { inArgs.set_x_dot(Teuchos::null); } outArgs.set_f(Teuchos::rcp(&*f_out,false)); model.evalModel(inArgs,outArgs); }
RCP<Thyra::VectorBase<Scalar> > eval_f_t( const Thyra::ModelEvaluator<Scalar>& me, Scalar t ) { typedef Teuchos::ScalarTraits<Scalar> ST; typedef Thyra::ModelEvaluatorBase MEB; MEB::InArgs<Scalar> inArgs = me.createInArgs(); inArgs.set_t(t); MEB::OutArgs<Scalar> outArgs = me.createOutArgs(); RCP<Thyra::VectorBase<Scalar> > f_out = Thyra::createMember(me.get_f_space()); V_S(outArg(*f_out),ST::zero()); outArgs.set_f(f_out); me.evalModel(inArgs,outArgs); return f_out; }
void eval_model_explicit( const Thyra::ModelEvaluator<Scalar> &model, Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint, const VectorBase<Scalar>& x_in, const typename Thyra::ModelEvaluatorBase::InArgs<Scalar>::ScalarMag &t_in, const Ptr<VectorBase<Scalar> >& f_out ) { typedef Thyra::ModelEvaluatorBase MEB; MEB::InArgs<Scalar> inArgs = model.createInArgs(); MEB::OutArgs<Scalar> outArgs = model.createOutArgs(); inArgs.setArgs(basePoint); inArgs.set_x(Teuchos::rcp(&x_in,false)); if (inArgs.supports(MEB::IN_ARG_t)) { inArgs.set_t(t_in); } outArgs.set_f(Teuchos::rcp(&*f_out,false)); model.evalModel(inArgs,outArgs); }