Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
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
How the output LOWSB object will be useded for solves in unspecified.
RCP< const PreconditionerBase< Scalar > > getPrec() const
Base class for all linear operators that can support a high-level solve operation.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
RCP< DelayedLinearOpWithSolve< Scalar > > delayedLinearOpWithSolve()
Nonmember constuctor.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
RCP< const VectorSpaceBase< Scalar > > domain() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< const LinearOpSourceBase< Scalar > > getFwdOpSrc() const
Interface for a collection of column vectors called a multi-vector.
Factory interface for creating LinearOpWithSolveBase objects from compatible LinearOpBase objects...
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
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)
Simple struct for the return status from a solve.
Base interface for objects that can return a linear operator.
RCP< DelayedLinearOpWithSolve< Scalar > > delayedLinearOpWithSolve(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Nonmember constuctor.
RCP< const LinearOpSourceBase< Scalar > > getApproxFwdOpSrc() const
RCP< const VectorSpaceBase< Scalar > > range() const
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
virtual bool opSupportedImpl(EOpTransp M_trans) const
virtual bool solveSupportsImpl(EOpTransp M_trans) const
Simple struct that defines the requested solution criteria for a solve.
Delayed linear solver construction LinearOpWithSolveBase decorator class.
RCP< const LinearOpBase< Scalar > > clone() const