Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Thyra_ReusePreconditionerFactory.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_ReusePreconditionerFactory_hpp
10 #define Thyra_ReusePreconditionerFactory_hpp
11 
12 #include "Thyra_PreconditionerFactoryBase.hpp"
13 
14 namespace Thyra {
15 
16 /** \brief Concrete <tt>PreconditionerFactoryBase</tt> subclass that
17  * just returns an already created/initialized preconditioner object.
18  */
19 template<class Scalar>
21  : virtual public PreconditionerFactoryBase<Scalar>
22 {
23 public:
24 
25  /** @name Constructors/initializers/accessors */
26  //@{
27 
28  /** \brief Construct to uninitialized. */
30 
31  void initialize(
32  const RCP<PreconditionerBase<Scalar> > &prec
33  ) {
34 #ifdef TEUCHOS_DEBUG
35  TEUCHOS_TEST_FOR_EXCEPT(is_null(prec));
36 #endif
37  prec_ = prec;
38  }
39 
40  RCP<PreconditionerBase<Scalar> >
42 
43  RCP<const PreconditionerBase<Scalar> >
44  getPreconditioner() const { return prec_; }
45 
46  void uninitialize() {
47  prec_ = Teuchos::null;
48  }
49 
50  /** \name Overridden from Teuchos::Describable. */
51  //@{
52 
53  std::string description() const
54  {
55  std::ostringstream oss;
56  oss << this->Teuchos::Describable::description()
57  << "{"
58  << "prec=";
59  if (!is_null(prec_))
60  oss << prec_->description();
61  else
62  oss << "NULL";
63  oss << "}";
64  return oss.str();
65  }
66 
67  //@}
68 
69  /** @name Overridden from ParameterListAcceptor (simple forwarding functions) */
70  //@{
71 
72  void setParameterList(RCP<ParameterList> const& /* paramList */)
73  {
74  }
75 
76  RCP<ParameterList> getNonconstParameterList()
77  {
78  return Teuchos::null;
79  }
80 
81  RCP<ParameterList> unsetParameterList()
82  {
83  return Teuchos::null;
84  }
85 
86  RCP<const ParameterList> getParameterList() const
87  {
88  return Teuchos::null;
89  }
90 
91  RCP<const ParameterList> getValidParameters() const
92  {
93  return rcp(new ParameterList);
94  }
95 
96  //@}
97 
98  //@}
99 
100  /** @name Overridden from PreconditionerFactoryBase */
101  //@{
102 
103  bool isCompatible(const LinearOpSourceBase<Scalar> &/* fwdOpSrc */) const
104  { return false; }
105 
106  RCP<PreconditionerBase<Scalar> > createPrec() const
107  { return prec_; }
108 
110  const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
111  PreconditionerBase<Scalar> * /* precOp */,
112  const ESupportSolveUse /* supportSolveUse */ = SUPPORT_SOLVE_UNSPECIFIED
113  ) const
114  {
115  }
116 
118  PreconditionerBase<Scalar> * /* precOp */,
119  RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc = NULL,
120  ESupportSolveUse *supportSolveUse = NULL
121  ) const
122  {
123  }
124 
125  //@}
126 
127 private:
128 
129  // //////////////////////////////
130  // Private data members
131 
132  RCP< PreconditionerBase<Scalar> > prec_;
133 
134 };
135 
136 /** \brief Nonmember constructor function.
137  *
138  * \relates ReusePreconditionerFactory
139  */
140 template<class Scalar>
141 RCP<ReusePreconditionerFactory<Scalar> >
143 {
144  return Teuchos::rcp(new ReusePreconditionerFactory<Scalar>());
145 }
146 
147 /** \brief Nonmember constructor function.
148  *
149  * \relates ReusePreconditionerFactory
150  */
151 template<class Scalar>
152 RCP<ReusePreconditionerFactory<Scalar> >
154  const RCP<PreconditionerBase<Scalar> > &prec
155  )
156 {
157  RCP<ReusePreconditionerFactory<Scalar> >
158  fac = Teuchos::rcp(new ReusePreconditionerFactory<Scalar>());
159  fac->initialize(prec);
160  return fac;
161 }
162 
163 } // end namespace Thyra
164 
165 #endif
Concrete PreconditionerFactoryBase subclass that just returns an already created/initialized precondi...
RCP< const ParameterList > getParameterList() const
RCP< ReusePreconditionerFactory< Scalar > > reusePreconditionerFactory(const RCP< PreconditionerBase< Scalar > > &prec)
Nonmember constructor function.
void setParameterList(RCP< ParameterList > const &)
ReusePreconditionerFactory()
Construct to uninitialized.
void initialize(const RCP< PreconditionerBase< Scalar > > &prec)
RCP< const ParameterList > getValidParameters() const
void initializePrec(const RCP< const LinearOpSourceBase< Scalar > > &, PreconditionerBase< Scalar > *, const ESupportSolveUse=SUPPORT_SOLVE_UNSPECIFIED) const
RCP< ReusePreconditionerFactory< Scalar > > reusePreconditionerFactory()
Nonmember constructor function.
RCP< PreconditionerBase< Scalar > > getNonconstPreconditioner()
RCP< PreconditionerBase< Scalar > > createPrec() const
RCP< const PreconditionerBase< Scalar > > getPreconditioner() const
bool isCompatible(const LinearOpSourceBase< Scalar > &) const
void uninitializePrec(PreconditionerBase< Scalar > *, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc=NULL, ESupportSolveUse *supportSolveUse=NULL) const