29 #ifndef RYTHMOS_STATE_AND_FORWARD_SENSITIVITY_MODEL_EVALUATOR_HPP
30 #define RYTHMOS_STATE_AND_FORWARD_SENSITIVITY_MODEL_EVALUATOR_HPP
33 #include "Rythmos_ForwardSensitivityModelEvaluatorBase.hpp"
34 #include "Thyra_ModelEvaluator.hpp"
35 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
36 #include "Thyra_DefaultProductVectorSpace.hpp"
37 #include "Thyra_ModelEvaluatorDelegatorBase.hpp"
38 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
39 #include "Thyra_DefaultMultiVectorProductVector.hpp"
40 #include "Thyra_DefaultMultiVectorLinearOpWithSolve.hpp"
41 #include "Teuchos_implicit_cast.hpp"
183 template<
class Scalar>
185 :
virtual public Thyra::StateFuncModelEvaluatorBase<Scalar>
213 Teuchos::RCP<const Thyra::DefaultProductVector<Scalar> >
215 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> > &x_vec,
216 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> > &s_bar_vec
227 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
get_p_space(
int l)
const;
229 Teuchos::RCP<const Teuchos::Array<std::string> >
get_p_names(
int l)
const;
231 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
get_x_space()
const;
233 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
get_f_space()
const;
237 Teuchos::RCP<Thyra::LinearOpWithSolveBase<Scalar> >
create_W()
const;
239 Thyra::ModelEvaluatorBase::InArgs<Scalar>
createInArgs()
const;
249 Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl()
const;
252 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
253 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs
263 Teuchos::RCP<const ForwardSensitivityModelEvaluatorBase<Scalar> > sensModel_;
266 Teuchos::RCP<const Thyra::DefaultProductVectorSpace<Scalar> > x_bar_space_;
267 Teuchos::RCP<const Thyra::DefaultProductVectorSpace<Scalar> > f_bar_space_;
279 template<
class Scalar>
285 template<
class Scalar>
291 using Teuchos::tuple;
using Teuchos::RCP;
293 TEUCHOS_TEST_FOR_EXCEPT( is_null(sensModel) );
295 sensModel_ = sensModel;
297 const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
298 stateModel = sensModel_->getStateModel();
300 x_bar_space_ = Thyra::productVectorSpace<Scalar>(
301 tuple<RCP<const Thyra::VectorSpaceBase<Scalar> > >(
302 stateModel->get_x_space(), sensModel_->get_x_space()
306 f_bar_space_ = Thyra::productVectorSpace<Scalar>(
307 tuple<RCP<const Thyra::VectorSpaceBase<Scalar> > >(
308 stateModel->get_f_space(), sensModel_->get_f_space()
312 Np_ = stateModel->Np();
317 template<
class Scalar>
318 Teuchos::RCP<const Thyra::DefaultProductVector<Scalar> >
320 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> > &x_vec,
321 const Teuchos::RCP<
const Thyra::VectorBase<Scalar> > &s_bar_vec
325 using Teuchos::tuple;
327 typedef RCP<const Thyra::VectorBase<Scalar> > RCPCV;
329 return Thyra::defaultProductVector<Scalar>(
330 x_bar_space_, tuple<RCPCV>(x_vec,s_bar_vec)
339 template<
class Scalar>
346 template<
class Scalar>
347 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
350 return sensModel_->getStateModel()->get_p_space(l);
354 template<
class Scalar>
355 Teuchos::RCP<const Teuchos::Array<std::string> >
358 return sensModel_->getStateModel()->get_p_names(l);
362 template<
class Scalar>
363 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
370 template<
class Scalar>
371 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> >
378 template<
class Scalar>
379 Thyra::ModelEvaluatorBase::InArgs<Scalar>
382 return this->createInArgs();
386 template<
class Scalar>
387 Teuchos::RCP<Thyra::LinearOpWithSolveBase<Scalar> >
390 TEUCHOS_TEST_FOR_EXCEPT(
"ToDo: Implement create_W() when needed!");
391 return Teuchos::null;
395 template<
class Scalar>
396 Thyra::ModelEvaluatorBase::InArgs<Scalar>
399 typedef Thyra::ModelEvaluatorBase MEB;
401 stateModelInArgs = sensModel_->getStateModel()->createInArgs();
402 MEB::InArgsSetup<Scalar> inArgs;
403 inArgs.setModelEvalDescription(this->description());
405 inArgs.setSupports( MEB::IN_ARG_x_dot,
406 stateModelInArgs.supports(MEB::IN_ARG_x_dot) );
407 inArgs.setSupports( MEB::IN_ARG_x );
408 inArgs.setSupports( MEB::IN_ARG_t );
409 inArgs.setSupports( MEB::IN_ARG_alpha,
410 stateModelInArgs.supports(MEB::IN_ARG_alpha) );
411 inArgs.setSupports( MEB::IN_ARG_beta,
412 stateModelInArgs.supports(MEB::IN_ARG_beta) );
420 template<
class Scalar>
421 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
424 typedef Thyra::ModelEvaluatorBase MEB;
426 stateModelOutArgs = sensModel_->getStateModel()->createOutArgs();
427 MEB::OutArgsSetup<Scalar> outArgs;
428 outArgs.setModelEvalDescription(this->description());
429 outArgs.set_Np_Ng(Np_,0);
430 outArgs.setSupports(MEB::OUT_ARG_f);
431 if (stateModelOutArgs.supports(MEB::OUT_ARG_W) ) {
432 outArgs.setSupports(MEB::OUT_ARG_W);
433 outArgs.set_W_properties(stateModelOutArgs.get_W_properties());
439 template<
class Scalar>
440 void StateAndForwardSensitivityModelEvaluator<Scalar>::evalModelImpl(
441 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &,
442 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &
445 TEUCHOS_TEST_FOR_EXCEPT(
"ToDo: Implement evalModel(...) when needed!");
452 #endif // RYTHMOS_STATE_AND_FORWARD_SENSITIVITY_MODEL_EVALUATOR_HPP
StateAndForwardSensitivityModelEvaluator()
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Combined State and Forward sensitivity transient ModelEvaluator subclass.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int l) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > create_W() const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Teuchos::RCP< const Thyra::DefaultProductVector< Scalar > > create_x_bar_vec(const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &x_vec, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &s_bar_vec) const
Create a wrapped product vector of the form x_bar = [ x; s_bar ].
Forward sensitivity transient ModelEvaluator node interface class.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const
void initializeStructure(const Teuchos::RCP< const ForwardSensitivityModelEvaluatorBase< Scalar > > &sensModel)
Set up the structure of the state and sensitivity equations.
int Np() const
Returns 0 .