Teko  Version of the Day
 All Classes Files Functions Variables Pages
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  range_ = buildFlatVectorSpace(*mgr_, blockedOp_->range());
9  domain_ = buildFlatVectorSpace(*mgr_, blockedOp_->domain());
10 }
11 
12 VectorSpace ReorderedLinearOp::range() const { return range_; }
13 
14 VectorSpace ReorderedLinearOp::domain() const { return domain_; }
15 
16 void ReorderedLinearOp::implicitApply(const MultiVector& x, MultiVector& y, const double alpha,
17  const double beta) const {
18  using Teuchos::rcp_dynamic_cast;
19 
20  Teuchos::RCP<const Thyra::MultiVectorBase<double> > reorderX = Teko::buildReorderedMultiVector(
21  *mgr_, rcp_dynamic_cast<const Thyra::ProductMultiVectorBase<double> >(x));
22  MultiVector reorderY = Teko::buildReorderedMultiVector(
23  *mgr_, rcp_dynamic_cast<Thyra::ProductMultiVectorBase<double> >(y));
24 
25  // this will automatically fill the right data
26  Thyra::apply(*blockedOp_, Thyra::NOTRANS, *reorderX, reorderY.ptr(), alpha, beta);
27 }
28 
29 void ReorderedLinearOp::describe(Teuchos::FancyOStream& out_arg,
30  const Teuchos::EVerbosityLevel verbLevel) const {
31  using Teuchos::OSTab;
32  using Teuchos::RCP;
33 
34  RCP<Teuchos::FancyOStream> out = rcp(&out_arg, false);
35  OSTab tab(out);
36  switch (verbLevel) {
37  case Teuchos::VERB_DEFAULT:
38  case Teuchos::VERB_LOW: *out << this->description() << std::endl; break;
39  case Teuchos::VERB_MEDIUM:
40  case Teuchos::VERB_HIGH:
41  case Teuchos::VERB_EXTREME: {
42  *out << Teuchos::Describable::description() << "{"
43  << "rangeDim=" << this->range()->dim() << ",domainDim=" << this->domain()->dim()
44  << "}\n";
45  {
46  OSTab tab2(out);
47  *out << "[Blocked Op] = ";
48  *out << Teuchos::describe(*blockedOp_, verbLevel);
49  }
50  {
51  OSTab tab2(out);
52  *out << "[Blocked Manager] = ";
53  *out << mgr_->toString() << std::endl;
54  }
55  break;
56  }
57  default: TEUCHOS_TEST_FOR_EXCEPT(true); // Should never get here!
58  }
59 }
60 
61 } // end namespace Teko
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.
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.