Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Thyra_ScaledIdentityLinearOpWithSolveFactory.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_ScaledIdentityLinearOpWithSolveFactory_hpp
10 #define Thyra_ScaledIdentityLinearOpWithSolveFactory_hpp
11 
12 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
17 #include "Thyra_DefaultLinearOpSource.hpp"
18 
19 namespace Thyra {
20 
21 /** \brief Create a LinearOpWithSolveFactory for a flattened-out multi-vector.
22  */
23 template<class Scalar>
25  : virtual public LinearOpWithSolveFactoryBase<Scalar>
26 {
27 public:
28 
29  /** @name Overridden from Constructors/Initializers/Accessors */
30  //@{
31 
32  /** \brief Construct to uninitialized. */
34 
35 
36  /** \brief Initialize
37  */
38  void initialize(const RCP<const VectorSpaceBase<Scalar> >& space,
39  const Scalar& s)
40  {
41  space_ = space;
42  s_ = s;
43  }
44 
45  //@}
46 
47  /** @name Overridden from ParameterListAcceptor */
48  //@{
49 
50  void setParameterList(RCP<ParameterList> const& /* paramList */) {}
51  RCP<ParameterList> getNonconstParameterList() { return Teuchos::parameterList(); }
52  RCP<ParameterList> unsetParameterList() { return Teuchos::parameterList(); }
53  RCP<const ParameterList> getParameterList() const { return Teuchos::parameterList(); }
54  RCP<const ParameterList> getValidParameters() const { return Teuchos::parameterList(); }
55 
56  //@}
57 
58  /** \name Overridden from LinearOpWithSolveFactoyBase */
59  //@{
60 
61  /** \brief returns false. */
62  virtual bool acceptsPreconditionerFactory() const { return false; }
63 
64  /** \brief Throws exception. */
66  const RCP<PreconditionerFactoryBase<Scalar> > &/* precFactory */,
67  const std::string &/* precFactoryName */
68  ) {}
69 
70  /** \brief Returns null . */
71  virtual RCP<PreconditionerFactoryBase<Scalar> >
72  getPreconditionerFactory() const { return Teuchos::null; }
73 
74  /** \brief Throws exception. */
76  RCP<PreconditionerFactoryBase<Scalar> > * /* precFactory */,
77  std::string * /* precFactoryName */
78  ) {}
79 
80  virtual bool isCompatible(
81  const LinearOpSourceBase<Scalar> &fwdOpSrc
82  ) const
83  {
84  return !is_null(
85  Teuchos::rcp_dynamic_cast<const ScaledIdentityLinearOpWithSolve<Scalar> >(fwdOpSrc.getOp()));
86  }
87 
88  virtual RCP<LinearOpWithSolveBase<Scalar> > createOp() const
89  { return scaledIdentity(space_, s_); }
90 
91  virtual void initializeOp(
92  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
93  LinearOpWithSolveBase<Scalar> *Op,
94  const ESupportSolveUse supportSolveUse
95  ) const;
96 
97  virtual void initializeAndReuseOp(
98  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
99  LinearOpWithSolveBase<Scalar> *Op
100  ) const
101  {
102  initializeOp(fwdOpSrc, Op, SUPPORT_SOLVE_UNSPECIFIED);
103  }
104 
105  virtual void uninitializeOp(
106  LinearOpWithSolveBase<Scalar> *Op,
107  RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
108  RCP<const PreconditionerBase<Scalar> > *prec,
109  RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
110  ESupportSolveUse *supportSolveUse
111  ) const;
112 
114  const EPreconditionerInputType /* precOpType */
115  ) const { return false; }
116 
118  const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
119  const RCP<const PreconditionerBase<Scalar> > &/* prec */,
120  LinearOpWithSolveBase<Scalar> * /* Op */,
121  const ESupportSolveUse /* supportSolveUse */
122  ) const {}
123 
125  const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
126  const RCP<const LinearOpSourceBase<Scalar> > &/* approxFwdOpSrc */,
127  LinearOpWithSolveBase<Scalar> * /* Op */,
128  const ESupportSolveUse /* supportSolveUse */
129  ) const {}
130 
131  //@}
132 
133 protected:
134 
135  /** \brief Overridden from Teuchos::VerboseObjectBase */
136  //@{
137 
139 
140  //@}
141 
142 private:
143 
144  RCP<const VectorSpaceBase<Scalar> > space_;
145  Scalar s_;
146 
147 };
148 
149 /** \brief Nonmember constructor.
150  *
151  * \relates ScaledIdentityLinearOpWithSolveFactory
152  */
153 template<class Scalar>
154 RCP<ScaledIdentityLinearOpWithSolveFactory<Scalar> >
156  const RCP<const VectorSpaceBase<Scalar> >& space,
157  const Scalar& s)
158 {
159  RCP<ScaledIdentityLinearOpWithSolveFactory<Scalar> > lowsf =
161  lowsf->initialize(space,s);
162  return lowsf;
163 }
164 
165 // Overridden from LinearOpWithSolveFactoyBase
166 
167 template<class Scalar>
168 void
171  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
172  LinearOpWithSolveBase<Scalar> *Op,
173  const ESupportSolveUse /* supportSolveUse */
174  ) const
175 {
176  using Teuchos::dyn_cast;
177  using Teuchos::rcp_dynamic_cast;
178 
179 #ifdef TEUCHOS_DEBUG
180  TEUCHOS_TEST_FOR_EXCEPT(0==Op);
181 #endif
182 
183  const RCP<const LinearOpBase<Scalar> > tmpFwdOp = fwdOpSrc->getOp();
184  RCP<const LinearOpBase<Scalar> > fwdOp;
185  Scalar fwdOp_scalar = 0.0;
186  EOpTransp fwdOp_transp;
187  unwrap<Scalar>(tmpFwdOp, &fwdOp_scalar, &fwdOp_transp, &fwdOp);
188 
189  const RCP<const ScaledIdentityLinearOpWithSolve<Scalar> > fwdSi =
190  rcp_dynamic_cast<const ScaledIdentityLinearOpWithSolve<Scalar> >(fwdOp, true);
191 
193  fwdSi->space(), fwdSi->scale());
194 }
195 
196 template<class Scalar>
197 void
200  LinearOpWithSolveBase<Scalar> * Op,
201  RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
202  RCP<const PreconditionerBase<Scalar> > *prec,
203  RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
204  ESupportSolveUse * /* supportSolveUse */
205  ) const
206 {
207  using Teuchos::dyn_cast;
208  using Teuchos::is_null;
209 #ifdef TEUCHOS_DEBUG
210  TEUCHOS_TEST_FOR_EXCEPT(0==Op);
211 #else
212  (void)Op;
213 #endif // TEUCHOS_DEBUG
214  if (fwdOpSrc) *fwdOpSrc = Teuchos::null;
215  if (prec) *prec = Teuchos::null;
216  if (approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
217 }
218 
219 
220 
221 } // namespace Thyra
222 
223 #endif
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType) const
Implicit concrete LinearOpBase subclass that takes a flattended out multi-vector and performs a multi...
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space, const Scalar &s)
virtual void uninitializeOp(LinearOpWithSolveBase< Scalar > *Op, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc, RCP< const PreconditionerBase< Scalar > > *prec, RCP< const LinearOpSourceBase< Scalar > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space, const Scalar &s)
Initialize.
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
Create a LinearOpWithSolveFactory for a flattened-out multi-vector.
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &, const RCP< const LinearOpSourceBase< Scalar > > &, LinearOpWithSolveBase< Scalar > *, const ESupportSolveUse) const
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
RCP< ScaledIdentityLinearOpWithSolveFactory< Scalar > > scaledIdentitySolveFactory(const RCP< const VectorSpaceBase< Scalar > > &space, const Scalar &s)
Nonmember constructor.
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &, const std::string &)
Throws exception.
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *, std::string *)
Throws exception.
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &, const RCP< const PreconditionerBase< Scalar > > &, LinearOpWithSolveBase< Scalar > *, const ESupportSolveUse) const