Thyra_LinearOpWithSolveFactoryHelpers.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_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
00030 #define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
00031 
00032 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
00033 #include "Thyra_DefaultLinearOpSource.hpp"
00034 #include "Thyra_DefaultPreconditioner.hpp"
00035 
00036 namespace Thyra {
00037 
00043 template<class Scalar>
00044 bool isCompatible(
00045   const LinearOpWithSolveFactoryBase<Scalar>    &lowsFactory
00046   ,const LinearOpBase<Scalar>                   &fwdOp
00047   )
00048 {
00049   return lowsFactory.isCompatible(*defaultLinearOpSource(fwdOp));
00050 }
00051 
00056 template<class Scalar>
00057 Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00058 linearOpWithSolve(
00059   const LinearOpWithSolveFactoryBase<Scalar>                  &lowsFactory
00060   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >    &fwdOp
00061   ,const ESupportSolveUse                                     supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00062   )
00063 {
00064   Teuchos::RefCountPtr<LinearOpWithSolveBase<Scalar> >
00065     Op = lowsFactory.createOp();
00066   lowsFactory.initializeOp(defaultLinearOpSource(fwdOp),&*Op,supportSolveUse);
00067   return Op;
00068 }
00069 
00074 template<class Scalar>
00075 void initializeOp(
00076   const LinearOpWithSolveFactoryBase<Scalar>                  &lowsFactory
00077   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >    &fwdOp
00078   ,LinearOpWithSolveBase<Scalar>                              *Op
00079   ,const ESupportSolveUse                                     supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00080   )
00081 {
00082   lowsFactory.initializeOp(defaultLinearOpSource(fwdOp),Op,supportSolveUse);
00083 }
00084 
00090 template<class Scalar>
00091 void initializeAndReuseOp(
00092   const LinearOpWithSolveFactoryBase<Scalar>                  &lowsFactory
00093   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >    &fwdOp
00094   ,LinearOpWithSolveBase<Scalar>                              *Op
00095   )
00096 {
00097   lowsFactory.initializeAndReuseOp(defaultLinearOpSource(fwdOp),Op);
00098 }
00099 
00105 template<class Scalar>
00106 void initializePreconditionedOp(
00107   const LinearOpWithSolveFactoryBase<Scalar>                       &lowsFactory
00108   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >         &fwdOp
00109   ,const Teuchos::RefCountPtr<const PreconditionerBase<Scalar> >   &prec
00110   ,LinearOpWithSolveBase<Scalar>                                   *Op
00111   ,const ESupportSolveUse                                          supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00112   )
00113 {
00114   lowsFactory.initializePreconditionedOp(defaultLinearOpSource(fwdOp),prec,Op,supportSolveUse);
00115 }
00116 
00122 template<class Scalar>
00123 void initializeApproxPreconditionedOp(
00124   const LinearOpWithSolveFactoryBase<Scalar>                    &lowsFactory
00125   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >      &fwdOp
00126   ,const Teuchos::RefCountPtr<const LinearOpBase<Scalar> >      &approxFwdOp
00127   ,LinearOpWithSolveBase<Scalar>                                *Op
00128   ,const ESupportSolveUse                                       supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
00129   )
00130 {
00131   lowsFactory.initializeApproxPreconditionedOp(
00132     defaultLinearOpSource(fwdOp),defaultLinearOpSource(approxFwdOp),Op,supportSolveUse
00133     );
00134 }
00135   
00141 template<class Scalar>
00142 void uninitializeOp(
00143   const LinearOpWithSolveFactoryBase<Scalar>                  &lowsFactory
00144   ,LinearOpWithSolveBase<Scalar>                              *Op
00145   ,Teuchos::RefCountPtr<const LinearOpBase<Scalar> >          *fwdOp           = NULL
00146   ,Teuchos::RefCountPtr<const PreconditionerBase<Scalar> >    *prec            = NULL
00147   ,Teuchos::RefCountPtr<const LinearOpBase<Scalar> >          *approxFwdOp     = NULL
00148   ,ESupportSolveUse                                           *supportSolveUse = NULL
00149   )
00150 {
00151   Teuchos::RefCountPtr<const LinearOpSourceBase<Scalar> > fwdOpSrc;
00152   Teuchos::RefCountPtr<const LinearOpSourceBase<Scalar> > approxFwdOpSrc;
00153   lowsFactory.uninitializeOp(Op,&fwdOpSrc,prec,&approxFwdOpSrc,supportSolveUse);
00154   if(fwdOp)
00155     *fwdOp = ( fwdOpSrc.get() ? fwdOpSrc->getOp() : Teuchos::null );
00156   if(approxFwdOp)
00157     *approxFwdOp = ( approxFwdOpSrc.get() ? approxFwdOpSrc->getOp() : Teuchos::null );
00158 }
00159 
00160 } // namespace Thyra
00161 
00162 #endif // THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP

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