10 #ifndef Thyra_TpetraExplicitAdjointModelEvaluator_hpp
11 #define Thyra_TpetraExplicitAdjointModelEvaluator_hpp
13 #include "Thyra_ModelEvaluatorDelegatorBase.hpp"
14 #include "Thyra_TpetraLinearOp.hpp"
15 #include "Tpetra_RowMatrixTransposer.hpp"
29 template <
typename Scalar,
typename LocalOrdinal,
typename GlobalOrdinal=LocalOrdinal,
typename Node=Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
65 if (thyra_fwd_op == Teuchos::null)
68 Teuchos::rcp_dynamic_cast<TLO>(thyra_fwd_op,
true);
69 RCP<TO> tpetra_fwd_op = thyra_tpetra_fwd_op->getTpetraOperator();
71 Teuchos::rcp_dynamic_cast<TCM>(tpetra_fwd_op,
true);
72 TRMT transposer(tpetra_fwd_mat);
73 RCP<TCM> tpetra_trans_mat = transposer.createTranspose();
74 return tpetraLinearOp(thyra_op->range(), thyra_op->domain(),
85 MEB::OutArgs<Scalar> model_outArgs =
87 MEB::OutArgsSetup<Scalar> outArgs;
88 outArgs.setModelEvalDescription(this->
description());
89 outArgs.setSupports(MEB::OUT_ARG_f);
90 outArgs.setSupports(MEB::OUT_ARG_W_op);
96 const ModelEvaluatorBase::InArgs<Scalar> &inArgs,
97 const ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
100 typedef TpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node> TLO;
105 MEB::OutArgs<Scalar> model_outArgs =
108 if (model_outArgs.supports(MEB::OUT_ARG_W_op) &&
109 outArgs.get_W_op() != Teuchos::null) {
111 if (thyra_fwd_op == Teuchos::null)
113 model_outArgs->set_W_op(thyra_fwd_op);
119 RCP<TLO> thyra_tpetra_fwd_op =
120 Teuchos::rcp_dynamic_cast<TLO>(thyra_fwd_op,
true);
121 RCP<TO> tpetra_fwd_op = thyra_tpetra_fwd_op->getTpetraOperator();
122 RCP<TCM> tpetra_fwd_mat =
123 Teuchos::rcp_dynamic_cast<TCM>(tpetra_fwd_op,
true);
124 TRMT transposer(tpetra_fwd_mat);
125 RCP<TCM> tpetra_trans_mat = transposer.createTranspose();
128 RCP<LOB> thyra_adj_op = outArgs.get_W_op();
129 RCP<TLO> thyra_tpetra_adj_op =
130 Teuchos::rcp_dynamic_cast<TLO>(thyra_adj_op,
true);
131 RCP<TO> tpetra_adj_op = thyra_tpetra_adj_op->getTpetraOperator();
132 RCP<TCM> tpetra_adj_mat =
133 Teuchos::rcp_dynamic_cast<TCM>(tpetra_adj_op,
true);
134 *tpetra_adj_mat = *tpetra_trans_mat;
140 template <
typename Scalar>
141 RCP<TpetraExplicitAdjointModelEvaluator<Scalar> >
142 tpetraExplicitAdjointModelEvaluator(
143 const RCP<
const ModelEvaluator<Scalar> >& model)
145 return Teuchos::rcp(
new TpetraExplicitAdjointModelEvaluator<Scalar>(model));
148 template <
typename Scalar>
149 RCP<TpetraExplicitAdjointModelEvaluator<Scalar> >
150 tpetraExplicitAdjointModelEvaluator(
151 const RCP<ModelEvaluator<Scalar> >& model)
153 return Teuchos::rcp(
new TpetraExplicitAdjointModelEvaluator<Scalar>(model));
Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
virtual RCP< const ModelEvaluator< Scalar > > getUnderlyingModel() const
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
void setModelEvalDescription(const std::string &modelEvalDescription)
This is a base class that delegetes almost all function to a wrapped model evaluator object...
ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
RCP< LinearOpBase< Scalar > > create_W_op() const
virtual ~TpetraExplicitAdjointModelEvaluator()=default
Destructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
A model evaluator decorator for computing an explicit adjoint.
virtual std::string description() const
Base subclass for ModelEvaluator that defines some basic types.
ModelEvaluatorBase()
constructor
#define TEUCHOS_ASSERT(assertion_test)
Concrete Thyra::LinearOpBase subclass for Tpetra::Operator.
TpetraExplicitAdjointModelEvaluator(const RCP< const ModelEvaluator< Scalar > > &model)
Constructor.
TpetraExplicitAdjointModelEvaluator(const RCP< ModelEvaluator< Scalar > > &model)
Constructor.
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...