Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Thyra_AdjointPreconditioner.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_AdjointPreconditioner_hpp
10 #define Thyra_AdjointPreconditioner_hpp
11 
12 #include "Thyra_PreconditionerBase.hpp"
13 #include "Teuchos_ConstNonconstObjectContainer.hpp"
14 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
15 
16 namespace Thyra {
17 
18 /** \brief Concrete <tt>PreconditionerBase</tt> subclass that
19  * wraps a preconditioner operator in MultiVectorLinearOp.
20  */
21 template<class Scalar>
22 class AdjointPreconditioner : virtual public PreconditionerBase<Scalar>
23 {
24 public:
25 
26  /** @name Constructors/initializers/accessors */
27  //@{
28 
29  /** \brief Construct to uninitialized. */
31 
33  const RCP<PreconditionerBase<Scalar> > &prec) {
34  validateInitialize(prec);
35  prec_ = prec;
36  }
37 
38  void initialize(
39  const RCP<const PreconditionerBase<Scalar> > &prec) {
40  validateInitialize(prec);
41  prec_ = prec;
42  }
43 
44  RCP<PreconditionerBase<Scalar> >
45  getNonconstPreconditioner() { return prec_.getNonconstObj(); }
46 
47  RCP<const PreconditionerBase<Scalar> >
48  getPreconditioner() const { return prec_.getConstObj(); }
49 
50  void uninitialize() {
51  prec_.uninitialize();
52  }
53 
54  //@}
55 
56  /** @name Overridden from PreconditionerBase */
57  //@{
58 
59  bool isLeftPrecOpConst() const
60  { return prec_.getConstObj()->isLeftPrecOpConst(); }
61 
62  Teuchos::RCP<LinearOpBase<Scalar> > getNonconstLeftPrecOp()
63  { return nonconstAdjoint(prec_.getNonconstObj()->getNonconstLeftPrecOp()); }
64 
65  Teuchos::RCP<const LinearOpBase<Scalar> > getLeftPrecOp() const
66  { return adjoint(prec_.getConstObj()->getLeftPrecOp()); }
67 
68  bool isRightPrecOpConst() const
69  { return prec_.getConstObj()->isRightPrecOpConst(); }
70 
71  Teuchos::RCP<LinearOpBase<Scalar> > getNonconstRightPrecOp()
72  { return nonconstAdjoint(prec_.getNonconstObj()->getNonconstRightPrecOp()); }
73 
74  Teuchos::RCP<const LinearOpBase<Scalar> > getRightPrecOp() const
75  { return adjoint(prec_.getConstObj()->getRightPrecOp()); }
76 
78  { return prec_.getConstObj()->isUnspecifiedPrecOpConst(); }
79 
80  Teuchos::RCP<LinearOpBase<Scalar> > getNonconstUnspecifiedPrecOp()
81  { return nonconstAdjoint(
82  prec_.getNonconstObj()->getNonconstUnspecifiedPrecOp()); }
83 
84  Teuchos::RCP<const LinearOpBase<Scalar> > getUnspecifiedPrecOp() const
85  { return adjoint(prec_.getNonconstObj()->getUnspecifiedPrecOp()); }
86 
87  //@}
88 
89 private:
90 
91  // //////////////////////////////
92  // Private types
93 
94  typedef Teuchos::ConstNonconstObjectContainer<PreconditionerBase<Scalar> > CNPB;
95 
96  // //////////////////////////////
97  // Private data members
98 
100 
101  // //////////////////////////////
102  // Private member functions
103 
104  static void validateInitialize(
105  const RCP<const PreconditionerBase<Scalar> > &prec) {
106 #ifdef TEUCHOS_DEBUG
107  TEUCHOS_TEST_FOR_EXCEPT(is_null(prec));
108 #else
109  (void)prec;
110 #endif
111  }
112 
113 };
114 
115 /** \brief Nonmember constructor function.
116  *
117  * \relates AdjointPreconditioner
118  */
119 template<class Scalar>
120 RCP<AdjointPreconditioner<Scalar> >
122 {
123  return Teuchos::rcp(new AdjointPreconditioner<Scalar>());
124 }
125 
126 /** \brief Nonmember constructor function.
127  *
128  * \relates AdjointPreconditioner
129  */
130 template<class Scalar>
131 RCP<AdjointPreconditioner<Scalar> >
133  const RCP<PreconditionerBase<Scalar> > &prec
134  )
135 {
136  RCP<AdjointPreconditioner<Scalar> >
137  aprec = Teuchos::rcp(new AdjointPreconditioner<Scalar>());
138  aprec->nonconstInitialize(prec);
139  return aprec;
140 }
141 
142 /** \brief Nonmember constructor function.
143  *
144  * \relates AdjointPreconditioner
145  */
146 template<class Scalar>
147 RCP<AdjointPreconditioner<Scalar> >
149  const RCP<const PreconditionerBase<Scalar> > &prec
150  )
151 {
152  RCP<AdjointPreconditioner<Scalar> >
153  aprec = Teuchos::rcp(new AdjointPreconditioner<Scalar>());
154  aprec->initialize(prec);
155  return aprec;
156 }
157 
158 } // end namespace Thyra
159 
160 #endif
Concrete PreconditionerBase subclass that wraps a preconditioner operator in MultiVectorLinearOp.
RCP< AdjointPreconditioner< Scalar > > adjointPreconditioner()
Nonmember constructor function.
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstRightPrecOp()
RCP< AdjointPreconditioner< Scalar > > adjointPreconditioner(const RCP< const PreconditionerBase< Scalar > > &prec)
Nonmember constructor function.
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstLeftPrecOp()
void initialize(const RCP< const PreconditionerBase< Scalar > > &prec)
Teuchos::RCP< const LinearOpBase< Scalar > > getRightPrecOp() const
AdjointPreconditioner()
Construct to uninitialized.
void nonconstInitialize(const RCP< PreconditionerBase< Scalar > > &prec)
Teuchos::RCP< const LinearOpBase< Scalar > > getLeftPrecOp() const
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstUnspecifiedPrecOp()
static void validateInitialize(const RCP< const PreconditionerBase< Scalar > > &prec)
RCP< PreconditionerBase< Scalar > > getNonconstPreconditioner()
Teuchos::RCP< const LinearOpBase< Scalar > > getUnspecifiedPrecOp() const
Teuchos::ConstNonconstObjectContainer< PreconditionerBase< Scalar > > CNPB
RCP< AdjointPreconditioner< Scalar > > nonconstAdjointPreconditioner(const RCP< PreconditionerBase< Scalar > > &prec)
Nonmember constructor function.
RCP< const PreconditionerBase< Scalar > > getPreconditioner() const