Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_BlockImplicitLinearOp.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teko_BlockImplicitLinearOp.hpp"
11 
12 namespace Teko {
13 
14 using Teuchos::RCP;
15 using Teuchos::rcp_const_cast;
16 using Teuchos::rcp_dynamic_cast;
17 using Teuchos::rcpFromRef;
18 
19 using Thyra::ProductMultiVectorBase;
20 
21 void BlockImplicitLinearOp::implicitApply(const Thyra::EOpTransp M_trans,
22  const BlockedMultiVector& x, BlockedMultiVector& y,
23  const double alpha, const double beta) const {
24  TEUCHOS_TEST_FOR_EXCEPTION(M_trans != Thyra::NOTRANS, std::runtime_error,
25  "Linear operators of inherited type BlockImplicitLinearOp "
26  "cannot handle conjugation (yet!)");
27 
28  // call apply
29  implicitApply(x, y, alpha, beta);
30 }
31 
32 bool BlockImplicitLinearOp::opSupportedImpl(const Thyra::EOpTransp M_trans) const {
33  return (M_trans == Thyra::NOTRANS);
34 }
35 
36 void BlockImplicitLinearOp::applyImpl(const Thyra::EOpTransp M_trans,
37  const Thyra::MultiVectorBase<double>& x,
38  const Teuchos::Ptr<Thyra::MultiVectorBase<double> >& y,
39  const double alpha, const double beta) const {
40  // cast source vector
41  RCP<const ProductMultiVectorBase<double> > src =
42  rcp_dynamic_cast<const ProductMultiVectorBase<double> >(rcpFromRef(x));
43  BlockedMultiVector srcX = rcp_const_cast<ProductMultiVectorBase<double> >(src);
44 
45  // cast destination vector
46  BlockedMultiVector destY = rcp_dynamic_cast<ProductMultiVectorBase<double> >(rcpFromPtr(y));
47 
48  // call apply
49  implicitApply(M_trans, srcX, destY, alpha, beta);
50 }
51 
52 } // end namespace Teko
virtual void implicitApply(const BlockedMultiVector &x, BlockedMultiVector &y, const double alpha=1.0, const double beta=0.0) const =0
Perform a matrix vector multiply with this implicitly defined blocked operator.
virtual bool opSupportedImpl(const Thyra::EOpTransp M_trans) const
Functions required by Thyra::LinearOpBase.