Thyra  Version of the Day
Thyra_DelayedLinearOpWithSolve_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 
43 #ifndef THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
44 #define THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
45 
46 
47 #include "Thyra_LinearOpWithSolveBase.hpp"
48 #include "Thyra_LinearOpSourceBase.hpp"
49 
50 
51 namespace Thyra {
52 
53 
65 template <class Scalar>
66 class DelayedLinearOpWithSolve : virtual public LinearOpWithSolveBase<Scalar>
67 {
68 public:
69 
72 
75 
77  void initialize(
78  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
79  const RCP<const PreconditionerBase<Scalar> > &prec,
80  const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
81  const ESupportSolveUse supportSolveUse,
83  );
84 
87 
90 
93 
96 
98 
101 
103  std::string description() const;
104 
106 
109 
116 
118 
119 protected:
120 
124  void informUpdatedVerbosityState() const;
126 
130  virtual bool opSupportedImpl(EOpTransp M_trans) const;
132  virtual void applyImpl(
133  const EOpTransp M_trans,
134  const MultiVectorBase<Scalar> &X,
135  const Ptr<MultiVectorBase<Scalar> > &Y,
136  const Scalar alpha,
137  const Scalar beta
138  ) const;
140 
144  virtual bool solveSupportsImpl(EOpTransp M_trans) const;
147  EOpTransp M_trans, const SolveMeasureType& solveMeasureType
148  ) const;
151  const EOpTransp transp,
152  const MultiVectorBase<Scalar> &B,
153  const Ptr<MultiVectorBase<Scalar> > &X,
154  const Ptr<const SolveCriteria<Scalar> > solveCriteria
155  ) const;
157 
158 private:
159 
160  // //////////////////////
161  // Private data members
162 
165  RCP<const LinearOpSourceBase<Scalar> > approxFwdOpSrc_;
166  ESupportSolveUse supportSolveUse_;
168 
170 
171  mutable bool lows_is_valid_;
172  mutable RCP<LinearOpWithSolveBase<Scalar> > lows_;
173 
174  // ///////////////////////////
175  // Private member functions
176 
177  void updateSolver() const;
178 
179 };
180 
181 
186 template <class Scalar>
188 {
189  return Teuchos::rcp(new DelayedLinearOpWithSolve<Scalar>());
190 }
191 
192 
197 template <class Scalar>
200  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
202  )
203 {
204  using Teuchos::null;
206  delayedLinearOpWithSolve<Scalar>();
207  dlows->initialize(fwdOpSrc, null, null, SUPPORT_SOLVE_UNSPECIFIED, lowsf);
208  return dlows;
209 }
210 
211 
212 } // namespace Thyra
213 
214 
215 #endif // THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
Thyra::DelayedLinearOpWithSolve::domain
RCP< const VectorSpaceBase< Scalar > > domain() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:161
Thyra::LinearOpWithSolveFactoryBase
Factory interface for creating LinearOpWithSolveBase objects from compatible LinearOpBase objects.
Definition: Thyra_LinearOpWithSolveFactoryBase_decl.hpp:404
Thyra::SUPPORT_SOLVE_UNSPECIFIED
How the output LOWSB object will be useded for solves in unspecified.
Definition: Thyra_SolveSupportTypes.hpp:490
Thyra::DelayedLinearOpWithSolve::getPrec
RCP< const PreconditionerBase< Scalar > > getPrec() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:100
Thyra::DelayedLinearOpWithSolve
Delayed linear solver construction LinearOpWithSolveBase decorator class.
Definition: Thyra_DelayedLinearOpWithSolve_decl.hpp:66
Thyra::EOpTransp
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Definition: Thyra_OperatorVectorTypes.hpp:160
Thyra::ESupportSolveUse
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
Definition: Thyra_SolveSupportTypes.hpp:489
Thyra::DelayedLinearOpWithSolve::solveSupportsSolveMeasureTypeImpl
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:229
Thyra::DelayedLinearOpWithSolve::getApproxFwdOpSrc
RCP< const LinearOpSourceBase< Scalar > > getApproxFwdOpSrc() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:108
Thyra::DelayedLinearOpWithSolve::DelayedLinearOpWithSolve
DelayedLinearOpWithSolve()
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:61
Thyra::DelayedLinearOpWithSolve::initialize
void initialize(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, const ESupportSolveUse supportSolveUse, const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:67
Thyra::LinearOpSourceBase
Base interface for objects that can return a linear operator.
Definition: Thyra_LinearOpSourceBase.hpp:57
Thyra::DelayedLinearOpWithSolve::getFwdOpSrc
RCP< const LinearOpSourceBase< Scalar > > getFwdOpSrc() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:92
Teuchos::RCP
Thyra::LinearOpWithSolveBase
Base class for all linear operators that can support a high-level solve operation.
Definition: Thyra_LinearOpWithSolveBase_decl.hpp:308
Thyra::DelayedLinearOpWithSolve::applyImpl
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:205
Teuchos::Ptr
Thyra::DelayedLinearOpWithSolve::informUpdatedVerbosityState
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:181
Thyra::PreconditionerBase
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Definition: Thyra_OperatorSolveTypes.hpp:53
Thyra::DelayedLinearOpWithSolve::solveImpl
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:240
Thyra::SolveMeasureType
Solve tolerance type.
Definition: Thyra_SolveSupportTypes.hpp:112
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition: Thyra_MultiVectorBase_decl.hpp:493
Thyra::DelayedLinearOpWithSolve::opSupportedImpl
virtual bool opSupportedImpl(EOpTransp M_trans) const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:198
Thyra::DelayedLinearOpWithSolve::clone
RCP< const LinearOpBase< Scalar > > clone() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:171
Thyra::SolveStatus
Simple struct for the return status from a solve.
Definition: Thyra_SolveSupportTypes.hpp:423
Thyra::DelayedLinearOpWithSolve::description
std::string description() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:126
Thyra::SolveCriteria
Simple struct that defines the requested solution criteria for a solve.
Definition: Thyra_SolveSupportTypes.hpp:312
Thyra::DelayedLinearOpWithSolve::delayedLinearOpWithSolve
RCP< DelayedLinearOpWithSolve< Scalar > > delayedLinearOpWithSolve()
Nonmember constuctor.
Definition: Thyra_DelayedLinearOpWithSolve_decl.hpp:187
Thyra::DelayedLinearOpWithSolve::range
RCP< const VectorSpaceBase< Scalar > > range() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:151
Thyra::DelayedLinearOpWithSolve::getSupportSolveUse
ESupportSolveUse getSupportSolveUse() const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:116
Thyra::DelayedLinearOpWithSolve::delayedLinearOpWithSolve
RCP< DelayedLinearOpWithSolve< Scalar > > delayedLinearOpWithSolve(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Nonmember constuctor.
Definition: Thyra_DelayedLinearOpWithSolve_decl.hpp:199
Thyra::DelayedLinearOpWithSolve::solveSupportsImpl
virtual bool solveSupportsImpl(EOpTransp M_trans) const
Definition: Thyra_DelayedLinearOpWithSolve_def.hpp:221