Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
23 template<class Scalar>
25  : virtual public LinearOpWithSolveFactoryBase<Scalar>
26 {
27 public:
28 
31 
34 
35 
38  void initialize(const RCP<const VectorSpaceBase<Scalar> >& space,
39  const Scalar& s)
40  {
41  space_ = space;
42  s_ = s;
43  }
44 
46 
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 
57 
60 
62  virtual bool acceptsPreconditionerFactory() const { return false; }
63 
66  const RCP<PreconditionerFactoryBase<Scalar> > &/* precFactory */,
67  const std::string &/* precFactoryName */
68  ) {}
69 
71  virtual RCP<PreconditionerFactoryBase<Scalar> >
72  getPreconditionerFactory() const { return Teuchos::null; }
73 
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,
94  const ESupportSolveUse supportSolveUse
95  ) const;
96 
97  virtual void initializeAndReuseOp(
98  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
100  ) const
101  {
103  }
104 
105  virtual void uninitializeOp(
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 */,
121  const ESupportSolveUse /* supportSolveUse */
122  ) const {}
123 
125  const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
126  const RCP<const LinearOpSourceBase<Scalar> > &/* approxFwdOpSrc */,
128  const ESupportSolveUse /* supportSolveUse */
129  ) const {}
130 
132 
133 protected:
134 
137 
139 
141 
142 private:
143 
144  RCP<const VectorSpaceBase<Scalar> > space_;
145  Scalar s_;
146 
147 };
148 
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,
173  const ESupportSolveUse /* supportSolveUse */
174  ) const
175 {
176  using Teuchos::dyn_cast;
177  using Teuchos::rcp_dynamic_cast;
178 
179 #ifdef TEUCHOS_DEBUG
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
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
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...
bool is_null(const boost::shared_ptr< T > &p)
EOpTransp
bool is_null(const std::shared_ptr< T > &p)
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
T_To & dyn_cast(T_From &from)
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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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 .
ESupportSolveUse
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
EPreconditionerInputType
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 Teuchos::RCP< const LinearOpBase< Scalar > > getOp() const =0
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
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