Thyra_PreconditionerFactoryHelpers.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 // 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_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP
00030 #define THYRA_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP
00031 
00032 
00033 #include "Thyra_PreconditionerFactoryBase.hpp"
00034 #include "Thyra_DefaultLinearOpSource.hpp"
00035 #include "Thyra_DefaultPreconditioner.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00043 template <class Scalar>
00044 void initializePrec(
00045   const PreconditionerFactoryBase<Scalar>                    &precFactory
00046   ,const Teuchos::RCP<const LinearOpBase<Scalar> >   &fwdOp
00047   ,PreconditionerBase<Scalar>                                *prec
00048   ,const ESupportSolveUse                                    supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00049   )
00050 {
00051   precFactory.initializePrec(defaultLinearOpSource(fwdOp),prec,supportSolveUse);
00052 }
00053 
00054 
00058 template <class Scalar>
00059 void uninitializePrec(
00060   const PreconditionerFactoryBase<Scalar>               &precFactory
00061   ,PreconditionerBase<Scalar>                           *prec
00062   ,Teuchos::RCP<const LinearOpBase<Scalar> >    *fwdOp           = NULL
00063   ,ESupportSolveUse                                     *supportSolveUse = NULL
00064   )
00065 {
00066   Teuchos::RCP<const LinearOpSourceBase<Scalar> > fwdOpSrc;
00067   precFactory.uninitializePrec(prec,&fwdOpSrc,supportSolveUse);
00068   if(fwdOp) *fwdOp = fwdOpSrc->getOp();
00069 }
00070 
00071 
00074 template <class Scalar>
00075 Teuchos::RCP<PreconditionerBase<Scalar> >
00076 prec(
00077   const PreconditionerFactoryBase<Scalar>                    &precFactory
00078   ,const Teuchos::RCP<const LinearOpBase<Scalar> >   &fwdOp
00079   ,const ESupportSolveUse                                    supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00080   )
00081 {
00082   Teuchos::RCP<PreconditionerBase<Scalar> >
00083     prec = precFactory.createPrec();
00084   precFactory.initializePrec(defaultLinearOpSource(fwdOp),&*prec,supportSolveUse);
00085   return prec;
00086 }
00087 
00088 
00089 } // namespace Thyra
00090 
00091 
00092 #endif // THYRA_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP

Generated on Tue Oct 20 12:47:11 2009 for Thyra Operator Solve Support by doxygen 1.4.7