Thyra_DefaultInverseLinearOpDecl.hpp

Go to the documentation of this file.
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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_InverseLinearOpBase.hpp"
00033 #include "Thyra_SingleScalarLinearOpBase.hpp"
00034 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00035 #include "Teuchos_arrayArg.hpp"
00036 
00037 namespace Thyra {
00038 
00040 enum EThrowOnSolveFailure {
00041   THROW_ON_SOLVE_FAILURE=1 
00042   ,IGNORE_SOLVE_FAILURE=0  
00043 };
00044 
00068 template<class Scalar>
00069 class DefaultInverseLinearOp
00070   : virtual public InverseLinearOpBase<Scalar>             // Public interface
00071   , virtual protected SingleScalarLinearOpBase<Scalar>     // Implementation detail
00072 {
00073 public:
00074 
00076   using SingleScalarLinearOpBase<Scalar>::apply;
00077 
00080 
00084   DefaultInverseLinearOp();
00085 
00088   DefaultInverseLinearOp(
00089     const Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >      &lows
00090     ,const SolveCriteria<Scalar>                                    *fwdSolveCriteria       = NULL
00091     ,const EThrowOnSolveFailure                                     throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00092     ,const SolveCriteria<Scalar>                                    *adjSolveCriteria       = NULL
00093     ,const EThrowOnSolveFailure                                     throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00094     );
00095 
00101   DefaultInverseLinearOp(
00102     const Teuchos::RefCountPtr<const LinearOpWithSolveBase<Scalar> >      &lows
00103     ,const SolveCriteria<Scalar>                                          *fwdSolveCriteria       = NULL
00104     ,const EThrowOnSolveFailure                                           throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00105     ,const SolveCriteria<Scalar>                                          *adjSolveCriteria       = NULL
00106     ,const EThrowOnSolveFailure                                           throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00107     );
00108 
00143   void initialize(
00144     const Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >      &lows
00145     ,const SolveCriteria<Scalar>                                    *fwdSolveCriteria       = NULL
00146     ,const EThrowOnSolveFailure                                     throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00147     ,const SolveCriteria<Scalar>                                    *adjSolveCriteria       = NULL
00148     ,const EThrowOnSolveFailure                                     throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00149     );
00150 
00185   void initialize(
00186     const Teuchos::RefCountPtr<const LinearOpWithSolveBase<Scalar> >      &lows
00187     ,const SolveCriteria<Scalar>                                          *fwdSolveCriteria       = NULL
00188     ,const EThrowOnSolveFailure                                           throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00189     ,const SolveCriteria<Scalar>                                          *adjSolveCriteria       = NULL
00190     ,const EThrowOnSolveFailure                                           throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00191     );
00192 
00201   void uninitialize();
00202 
00204 
00207 
00209   bool isLowsConst() const;
00211   Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00212   getNonconstLows(); 
00214   Teuchos::RefCountPtr<const LinearOpWithSolveBase<Scalar> >
00215   getLows() const; 
00216 
00218 
00221 
00226   Teuchos::RefCountPtr< const VectorSpaceBase<Scalar> > range() const;
00227 
00232   Teuchos::RefCountPtr< const VectorSpaceBase<Scalar> > domain() const;
00233 
00235   Teuchos::RefCountPtr<const LinearOpBase<Scalar> > clone() const;
00236 
00238 
00241                                                 
00243   std::string description() const;
00244 
00246   void describe(
00247     Teuchos::FancyOStream                &out
00248     ,const Teuchos::EVerbosityLevel      verbLevel
00249     ) const;
00250 
00252 
00253 protected:
00254 
00257 
00261   bool opSupported(ETransp M_trans) const;
00262 
00264   void apply(
00265     const ETransp                     M_trans
00266     ,const MultiVectorBase<Scalar>    &X
00267     ,MultiVectorBase<Scalar>          *Y
00268     ,const Scalar                     alpha
00269     ,const Scalar                     beta
00270     ) const;
00271 
00273 
00274 private:
00275 
00276   Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveBase<Scalar> >   lows_;
00277   Teuchos::RefCountPtr<SolveCriteria<Scalar> >                            fwdSolveCriteria_;
00278   EThrowOnSolveFailure                                                    throwOnFwdSolveFailure_;
00279   Teuchos::RefCountPtr<SolveCriteria<Scalar> >                            adjSolveCriteria_;
00280   EThrowOnSolveFailure                                                    throwOnAdjSolveFailure_;
00281 
00282   void assertInitialized() const;
00283 
00284   template<class LOWS>
00285   void initializeImpl(
00286     const Teuchos::RefCountPtr<LOWS>      &lows
00287     ,const SolveCriteria<Scalar>          *fwdSolveCriteria
00288     ,const EThrowOnSolveFailure           throwOnFwdSolveFailure
00289     ,const SolveCriteria<Scalar>          *adjSolveCriteria
00290     ,const EThrowOnSolveFailure           throwOnAdjSolveFailure
00291     );
00292 
00293   // Not defined and not to be called
00294   DefaultInverseLinearOp(const DefaultInverseLinearOp&);
00295   DefaultInverseLinearOp& operator=(const DefaultInverseLinearOp&);
00296 
00297 };
00298 
00303 template<class Scalar>
00304 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00305 nonconstInverse(
00306   const Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >    &A
00307   ,const SolveCriteria<Scalar>                                  *fwdSolveCriteria       = NULL
00308   ,const EThrowOnSolveFailure                                   throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00309   ,const SolveCriteria<Scalar>                                  *adjSolveCriteria       = NULL
00310   ,const EThrowOnSolveFailure                                   throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00311   );
00312 
00317 template<class Scalar>
00318 Teuchos::RefCountPtr<LinearOpBase<Scalar> >
00319 inverse(
00320   const Teuchos::RefCountPtr<const LinearOpWithSolveBase<Scalar> >     &A
00321   ,const SolveCriteria<Scalar>                                         *fwdSolveCriteria       = NULL
00322   ,const EThrowOnSolveFailure                                          throwOnFwdSolveFailure  = THROW_ON_SOLVE_FAILURE
00323   ,const SolveCriteria<Scalar>                                         *adjSolveCriteria       = NULL
00324   ,const EThrowOnSolveFailure                                          throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00325   );
00326 
00327 // /////////////////////////////////
00328 // Inline members
00329 
00330 template<class Scalar>
00331 inline
00332 void DefaultInverseLinearOp<Scalar>::assertInitialized() const
00333 {
00334 #ifdef TEUCHOS_DEBUG
00335   TEST_FOR_EXCEPT( !lows_.getConstObj().get() );
00336 #endif
00337 }
00338 
00339 } // end namespace Thyra
00340 
00341 #endif  // THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1