Thyra Version of the Day
Thyra_DelayedLinearOpWithSolve_decl.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 
00043 #ifndef THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
00044 #define THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
00045 
00046 
00047 #include "Thyra_LinearOpWithSolveBase.hpp"
00048 #include "Thyra_LinearOpSourceBase.hpp"
00049 
00050 
00051 namespace Thyra {
00052 
00053 
00065 template <class Scalar>
00066 class DelayedLinearOpWithSolve : virtual public LinearOpWithSolveBase<Scalar>
00067 {
00068 public:
00069 
00072 
00074   DelayedLinearOpWithSolve();
00075 
00077   void initialize(
00078     const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00079     const RCP<const PreconditionerBase<Scalar> > &prec,
00080     const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
00081     const ESupportSolveUse supportSolveUse,
00082     const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf
00083     );
00084 
00086   RCP<const LinearOpSourceBase<Scalar> > getFwdOpSrc() const;
00087 
00089   RCP<const PreconditionerBase<Scalar> > getPrec() const;
00090  
00092   RCP<const LinearOpSourceBase<Scalar> > getApproxFwdOpSrc() const;
00093 
00095   ESupportSolveUse getSupportSolveUse() const;
00096 
00098 
00101 
00103   std::string description() const;
00104 
00106 
00109 
00111   RCP< const VectorSpaceBase<Scalar> > range() const;
00113   RCP< const VectorSpaceBase<Scalar> > domain() const;
00115   RCP<const LinearOpBase<Scalar> > clone() const;
00116 
00118 
00119 protected:
00120 
00124   void informUpdatedVerbosityState() const;
00126 
00130   virtual bool opSupportedImpl(EOpTransp M_trans) const;
00132   virtual void applyImpl(
00133     const EOpTransp M_trans,
00134     const MultiVectorBase<Scalar> &X,
00135     const Ptr<MultiVectorBase<Scalar> > &Y,
00136     const Scalar alpha,
00137     const Scalar beta
00138     ) const;
00140 
00144   virtual bool solveSupportsImpl(EOpTransp M_trans) const;
00146   virtual bool solveSupportsSolveMeasureTypeImpl(
00147     EOpTransp M_trans, const SolveMeasureType& solveMeasureType
00148     ) const;
00150   SolveStatus<Scalar> solveImpl(
00151     const EOpTransp transp,
00152     const MultiVectorBase<Scalar> &B,
00153     const Ptr<MultiVectorBase<Scalar> > &X,
00154     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00155     ) const;
00157 
00158 private:
00159 
00160   // //////////////////////
00161   // Private data members
00162 
00163   RCP<const LinearOpSourceBase<Scalar> > fwdOpSrc_;
00164   RCP<const PreconditionerBase<Scalar> > prec_;
00165   RCP<const LinearOpSourceBase<Scalar> > approxFwdOpSrc_;
00166   ESupportSolveUse supportSolveUse_;
00167   RCP<LinearOpWithSolveFactoryBase<Scalar> > lowsf_;
00168 
00169   RCP<const LinearOpBase<Scalar> > fwdOp_;
00170 
00171   mutable bool lows_is_valid_;
00172   mutable RCP<LinearOpWithSolveBase<Scalar> > lows_;
00173 
00174   // ///////////////////////////
00175   // Private member functions
00176 
00177   void updateSolver() const;
00178 
00179 };
00180 
00181 
00186 template <class Scalar>
00187 RCP<DelayedLinearOpWithSolve<Scalar> > delayedLinearOpWithSolve()
00188 {
00189   return Teuchos::rcp(new DelayedLinearOpWithSolve<Scalar>());
00190 }
00191 
00192 
00197 template <class Scalar>
00198 RCP<DelayedLinearOpWithSolve<Scalar> >
00199 delayedLinearOpWithSolve(
00200   const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
00201   const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf
00202   )
00203 {
00204   using Teuchos::null;
00205   const RCP<DelayedLinearOpWithSolve<Scalar> > dlows =
00206     delayedLinearOpWithSolve<Scalar>();
00207   dlows->initialize(fwdOpSrc, null, null, SUPPORT_SOLVE_UNSPECIFIED, lowsf);
00208   return dlows;
00209 }
00210 
00211 
00212 } // namespace Thyra
00213 
00214 
00215 #endif // THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines