Teko Version of the Day
Teko_PreconditionerFactory.hpp
00001 /*
00002 // @HEADER
00003 // 
00004 // ***********************************************************************
00005 // 
00006 //      Teko: A package for block and physics based preconditioning
00007 //                  Copyright 2010 Sandia Corporation 
00008 //  
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 //  
00012 // Redistribution and use in source and binary forms, with or without
00013 // modification, are permitted provided that the following conditions are
00014 // met:
00015 //  
00016 // 1. Redistributions of source code must retain the above copyright
00017 // notice, this list of conditions and the following disclaimer.
00018 //  
00019 // 2. Redistributions in binary form must reproduce the above copyright
00020 // notice, this list of conditions and the following disclaimer in the
00021 // documentation and/or other materials provided with the distribution.
00022 //  
00023 // 3. Neither the name of the Corporation nor the names of the
00024 // contributors may be used to endorse or promote products derived from
00025 // this software without specific prior written permission. 
00026 //  
00027 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00028 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00031 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
00036 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 //  
00039 // Questions? Contact Eric C. Cyr (eccyr@sandia.gov)
00040 // 
00041 // ***********************************************************************
00042 // 
00043 // @HEADER
00044 
00045 */
00046 
00047 #ifndef __Teko_PreconditionerFactory_hpp__
00048 #define __Teko_PreconditionerFactory_hpp__
00049 
00050 #include "Teuchos_ParameterListAcceptor.hpp"
00051 
00052 // Thyra includes
00053 #include "Thyra_SolveSupportTypes.hpp"
00054 #include "Thyra_LinearOpSourceBase.hpp"
00055 #include "Thyra_PreconditionerFactoryBase.hpp"
00056 #include "Thyra_DefaultBlockedLinearOp.hpp"
00057 #include "Thyra_DefaultPreconditioner.hpp"
00058 
00059 // Teko includes
00060 #include "Teko_Utilities.hpp"
00061 #include "Teko_InverseLibrary.hpp"
00062 #include "Teko_CloneFactory.hpp"
00063 #include "Teko_PreconditionerState.hpp"
00064 #include "Teko_RequestHandler.hpp"
00065 #include "Teko_RequestHandlerContainer.hpp"
00066 
00067 namespace Teko {
00068 
00069 using Thyra::LinearOpBase;
00070 using Thyra::DefaultPreconditioner;
00071 
00082 class PreconditionerFactory 
00083    : public virtual Thyra::PreconditionerFactoryBase<double>, public RequestHandlerContainer
00084    // , public RequestHandler {
00085    {
00086 public:
00087 
00101    virtual LinearOp buildPreconditionerOperator(LinearOp & lo,PreconditionerState & state) const = 0;
00102 
00115    virtual Teuchos::RCP<PreconditionerState> buildPreconditionerState() const
00116    { return Teuchos::rcp(new PreconditionerState()); }
00117 
00119 
00120 
00133    virtual void initializeFromParameterList(const Teuchos::ParameterList & settings)
00134    { }
00135 
00150    virtual Teuchos::RCP<Teuchos::ParameterList> getRequestedParameters() const
00151    { return Teuchos::null; }
00152    
00166    virtual bool updateRequestedParameters(const Teuchos::ParameterList & pl)
00167    { return true; }
00168    
00170 
00172    void setInverseLibrary(const Teuchos::RCP<const InverseLibrary> & il);
00173 
00175    Teuchos::RCP<const InverseLibrary> getInverseLibrary() const;
00176 
00178 
00179  
00181    bool isCompatible(const Thyra::LinearOpSourceBase<double> &fwdOpSrc) const;
00182 
00184    Teuchos::RCP<Thyra::PreconditionerBase<double> > createPrec() const;
00185 
00196    void initializePrec(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > & fwdOpSrc,
00197                        const Teuchos::RCP<const Thyra::MultiVectorBase<double> > & solnVec,
00198                        Thyra::PreconditionerBase<double> * precOp,
00199                        const Thyra::ESupportSolveUse supportSolveUse) const;
00200 
00202    void initializePrec(const Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > & fwdOpSrc,
00203                        Thyra::PreconditionerBase<double> * precOp,
00204                        const Thyra::ESupportSolveUse supportSolveUse) const;
00205 
00207    void uninitializePrec(Thyra::PreconditionerBase<double> * prec, 
00208                          Teuchos::RCP<const Thyra::LinearOpSourceBase<double> > * fwdOpSrc,
00209                          Thyra::ESupportSolveUse *supportSolveUse) const;
00211 
00213 
00214 
00216    void setParameterList(const Teuchos::RCP<Teuchos::ParameterList> & paramList); 
00217 
00219    Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList();
00220 
00222    Teuchos::RCP< Teuchos::ParameterList > unsetParameterList();
00224 
00226    void setRequestHandler(const Teuchos::RCP<RequestHandler> & rh)
00227    { callbackHandler_ = rh; }
00228 
00230    Teuchos::RCP<RequestHandler> getRequestHandler() const 
00231    { return callbackHandler_; }
00232 
00233 protected:
00235    Teuchos::RCP<Teuchos::ParameterList>          paramList_;
00236 
00238    Teuchos::RCP<RequestHandler> callbackHandler_;
00239 
00240 private:
00242    Teuchos::RCP<const InverseLibrary> inverseLibrary_;
00243 
00245    static void setOpRequestHandler(const RequestHandlerContainer & rhc,const LinearOp & op);
00246 
00247 public:
00248 
00263    static Teuchos::RCP<PreconditionerFactory> 
00264    buildPreconditionerFactory(const std::string & name, 
00265                               const Teuchos::ParameterList & settings,
00266                               const Teuchos::RCP<const InverseLibrary> & invLib=Teuchos::null);
00267 
00281    static void addPreconditionerFactory(const std::string & name,const Teuchos::RCP<Cloneable> & clone);
00282 
00285    static void getPreconditionerFactoryNames(std::vector<std::string> & names);
00286 
00287 private:
00288 
00290    static CloneFactory<PreconditionerFactory> precFactoryBuilder_;
00291 
00293    static void initializePrecFactoryBuilder();
00294 };
00295 
00296 } // end namespace Teko
00297 
00298 #endif
 All Classes Files Functions Variables