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 {
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 void ReorderedLinearOp::describe(Teuchos::FancyOStream & out_arg,
38  const Teuchos::EVerbosityLevel verbLevel) const
39 {
40  using Teuchos::RCP;
41  using Teuchos::OSTab;
42 
43  RCP<Teuchos::FancyOStream> out = rcp(&out_arg,false);
44  OSTab tab(out);
45  switch(verbLevel) {
46  case Teuchos::VERB_DEFAULT:
47  case Teuchos::VERB_LOW:
48  *out << this->description() << std::endl;
49  break;
50  case Teuchos::VERB_MEDIUM:
51  case Teuchos::VERB_HIGH:
52  case Teuchos::VERB_EXTREME:
53  {
54  *out << Teuchos::Describable::description() << "{"
55  << "rangeDim=" << this->range()->dim()
56  << ",domainDim=" << this->domain()->dim()
57  << "}\n";
58  {
59  OSTab tab(out);
60  *out << "[Blocked Op] = ";
61  *out << Teuchos::describe(*blockedOp_,verbLevel);
62  }
63  {
64  OSTab tab(out);
65  *out << "[Blocked Manager] = ";
66  *out << mgr_->toString() << std::endl;
67  }
68  break;
69  }
70  default:
71  TEUCHOS_TEST_FOR_EXCEPT(true); // Should never get here!
72  }
73 }
74 
75 } // 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.