Teko  Version of the Day
Teko_ReorderedLinearOp.cpp
1 #include "Teko_ReorderedLinearOp.hpp"
2 
3 namespace Teko {
4 
5 ReorderedLinearOp::ReorderedLinearOp(const Teuchos::RCP<const BlockReorderManager> & mgr,
6  const Teuchos::RCP<Thyra::LinearOpBase<double> > & blockedOp)
7  : mgr_(mgr), blockedOp_(blockedOp)
8 {
9 
10  range_ = buildFlatVectorSpace(*mgr_,blockedOp_->range());
11  domain_ = buildFlatVectorSpace(*mgr_,blockedOp_->domain());
12 }
13 
14 VectorSpace ReorderedLinearOp::range() const
15 {
16  return range_;
17 }
18 
19 VectorSpace ReorderedLinearOp::domain() const
20 {
21  return domain_;
22 }
23 
24 void ReorderedLinearOp::implicitApply(const MultiVector & x, MultiVector & y,
25  const double alpha, const double beta) const
26 {
27  using Teuchos::rcp_dynamic_cast;
28 
29  Teuchos::RCP<const Thyra::MultiVectorBase<double> > reorderX
30  = Teko::buildReorderedMultiVector(*mgr_,rcp_dynamic_cast<const Thyra::ProductMultiVectorBase<double> >(x));
31  MultiVector reorderY = Teko::buildReorderedMultiVector(*mgr_,rcp_dynamic_cast<Thyra::ProductMultiVectorBase<double> >(y));
32 
33  // this will automatically fill the right data
34  Thyra::apply(*blockedOp_,Thyra::NOTRANS,*reorderX,reorderY.ptr(),alpha,beta);
35 }
36 
37 } // end namespace Teko
virtual VectorSpace range() const
Range space of this operator.
virtual VectorSpace domain() const
Domain space of this operator.
virtual void implicitApply(const MultiVector &x, MultiVector &y, const double alpha=1.0, const double beta=0.0) const
Perform a matrix vector multiply with this implicitly defined blocked operator.
Teuchos::RCP< const Thyra::MultiVectorBase< double > > buildReorderedMultiVector(const BlockReorderManager &mgr, const Teuchos::RCP< const Thyra::ProductMultiVectorBase< double > > &blkVec)
Convert a flat multi vector into a reordered multivector.