Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MultiVectorPreconditioner.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Thyra_MultiVectorPreconditioner_hpp
10 #define Thyra_MultiVectorPreconditioner_hpp
11 
12 #include "Thyra_PreconditionerBase.hpp"
13 #include "Teuchos_ConstNonconstObjectContainer.hpp"
15 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
16 
17 namespace Thyra {
18 
22 template<class Scalar>
23 class MultiVectorPreconditioner : virtual public PreconditionerBase<Scalar>
24 {
25 public:
26 
29 
32 
34  const RCP<PreconditionerBase<Scalar> > &prec,
35  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
36  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
37  ) {
38  validateInitialize(prec,multiVecRange,multiVecDomain);
39  prec_ = prec;
40  multiVecRange_ = multiVecRange;
41  multiVecDomain_ = multiVecDomain;
42  }
43 
44  void initialize(
45  const RCP<const PreconditionerBase<Scalar> > &prec,
46  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
47  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain) {
48  validateInitialize(prec,multiVecRange,multiVecDomain);
49  prec_ = prec;
50  multiVecRange_ = multiVecRange;
51  multiVecDomain_ = multiVecDomain;
52  }
53 
54  RCP<PreconditionerBase<Scalar> >
56 
57  RCP<const PreconditionerBase<Scalar> >
58  getPreconditioner() const { return prec_.getConstObj(); }
59 
60  void uninitialize() {
62  multiVecRange_ = Teuchos::null;
63  multiVecDomain_ = Teuchos::null;
64  }
65 
67 
70 
71  bool isLeftPrecOpConst() const
72  { return prec_.getConstObj()->isLeftPrecOpConst(); }
73 
75  { return nonconstMultiVectorLinearOp(
76  prec_.getNonconstObj()->getNonconstLeftPrecOp(),
78  multiVecDomain_); }
79 
81  { return multiVectorLinearOp(
82  prec_.getConstObj()->getLeftPrecOp(),
84  multiVecDomain_); }
85 
86  bool isRightPrecOpConst() const
87  { return prec_.getConstObj()->isRightPrecOpConst(); }
88 
90  { return nonconstMultiVectorLinearOp(
91  prec_.getNonconstObj()->getNonconstRightPrecOp(),
93  multiVecDomain_); }
94 
96  { return multiVectorLinearOp(
97  prec_.getConstObj()->getRightPrecOp(),
99  multiVecDomain_); }
100 
102  { return prec_.getConstObj()->isUnspecifiedPrecOpConst(); }
103 
105  { return nonconstMultiVectorLinearOp(
106  prec_.getNonconstObj()->getNonconstUnspecifiedPrecOp(),
108  multiVecDomain_); }
109 
111  { return multiVectorLinearOp(
112  prec_.getNonconstObj()->getUnspecifiedPrecOp(),
114  multiVecDomain_); }
115 
117 
118 private:
119 
120  // //////////////////////////////
121  // Private types
122 
124 
125  // //////////////////////////////
126  // Private data members
127 
129  RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > multiVecRange_;
130  RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > multiVecDomain_;
131 
132  // //////////////////////////////
133  // Private member functions
134 
135  static void validateInitialize(
136  const RCP<const PreconditionerBase<Scalar> > &prec,
137  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
138  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
139  ) {
140 #ifdef TEUCHOS_DEBUG
142  TEUCHOS_TEST_FOR_EXCEPT(is_null(multiVecRange));
143  TEUCHOS_TEST_FOR_EXCEPT(is_null(multiVecDomain));
144  TEUCHOS_TEST_FOR_EXCEPT( multiVecRange->numBlocks() != multiVecDomain->numBlocks() );
145 #else
146  (void)prec;
147  (void)multiVecRange;
148  (void)multiVecDomain;
149 #endif
150  }
151 
152 };
153 
158 template<class Scalar>
159 RCP<MultiVectorPreconditioner<Scalar> >
161 {
163 }
164 
169 template<class Scalar>
170 RCP<MultiVectorPreconditioner<Scalar> >
172  const RCP<PreconditionerBase<Scalar> > &prec,
173  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
174  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
175  )
176 {
177  RCP<MultiVectorPreconditioner<Scalar> >
179  mvprec->nonconstInitialize(prec,multiVecRange,multiVecDomain);
180  return mvprec;
181 }
182 
187 template<class Scalar>
188 RCP<MultiVectorPreconditioner<Scalar> >
190  const RCP<const PreconditionerBase<Scalar> > &prec,
191  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
192  const RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
193  )
194 {
195  RCP<MultiVectorPreconditioner<Scalar> >
197  mvprec->initialize(prec,multiVecRange,multiVecDomain);
198  return mvprec;
199 }
200 
201 } // end namespace Thyra
202 
203 #endif
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstLeftPrecOp()
bool is_null(const boost::shared_ptr< T > &p)
RCP< PreconditionerBase< Scalar > > getNonconstPreconditioner()
void nonconstInitialize(const RCP< PreconditionerBase< Scalar > > &prec, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Teuchos::RCP< const LinearOpBase< Scalar > > getLeftPrecOp() const
RCP< MultiVectorPreconditioner< Scalar > > multiVectorPreconditioner()
Nonmember constructor function.
RCP< const PreconditionerBase< Scalar > > getPreconditioner() const
Teuchos::ConstNonconstObjectContainer< PreconditionerBase< Scalar > > CNPB
RCP< MultiVectorPreconditioner< Scalar > > nonconstMultiVectorPreconditioner(const RCP< PreconditionerBase< Scalar > > &prec, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor function.
Teuchos::RCP< const LinearOpBase< Scalar > > getRightPrecOp() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void validateInitialize(const RCP< const PreconditionerBase< Scalar > > &prec, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
RCP< const ObjType > getConstObj() const
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecRange_
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstRightPrecOp()
RCP< MultiVectorPreconditioner< Scalar > > multiVectorPreconditioner(const RCP< const PreconditionerBase< Scalar > > &prec, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor function.
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecDomain_
Teuchos::RCP< const LinearOpBase< Scalar > > getUnspecifiedPrecOp() const
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstUnspecifiedPrecOp()
Concrete PreconditionerBase subclass that wraps a preconditioner operator in MultiVectorLinearOp.
MultiVectorPreconditioner()
Construct to uninitialized.
RCP< ObjType > getNonconstObj() const
void initialize(const RCP< const PreconditionerBase< Scalar > > &prec, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)