Thyra_DefaultRealLinearSolverBuilder.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Stratimikos: Thyra-based strategies for linear solvers
00005 //                Copyright (2006) 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 Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_DEFAULT_REAL_LINEAR_SOLVER_BUILDING_BASE
00030 #define THYRA_DEFAULT_REAL_LINEAR_SOLVER_BUILDING_BASE
00031 
00032 #include "Stratimikos_ConfigDefs.hpp"
00033 #include "Thyra_LinearSolverBuilderBase.hpp"
00034 #include "Teuchos_AbstractFactory.hpp"
00035 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00036 
00037 namespace Teuchos { class CommandLineProcessor; }
00038 
00039 namespace Thyra {
00040 
00069 class DefaultRealLinearSolverBuilder : public LinearSolverBuilderBase<double>
00070 {
00071 public:
00072 
00075 
00083   DefaultRealLinearSolverBuilder(
00084     const std::string    &paramsXmlFileName                = ""
00085     ,const std::string   &extraParamsXmlString             = ""
00086     ,const std::string   &paramsUsedXmlOutFileName         = ""
00087     ,const std::string   &paramsXmlFileNameOption          = "linear-solver-params-file"
00088     ,const std::string   &extraParamsXmlStringOption       = "extra-linear-solver-params"
00089     ,const std::string   &paramsUsedXmlOutFileNameOption   = "linear-solver-params-used-file"
00090     );
00091 
00093   ~DefaultRealLinearSolverBuilder();
00094   
00098   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
00099     
00103   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
00104 
00108   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
00109 
00113   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
00114 
00118   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
00119 
00123   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
00124 
00126   void setLinearSolveStrategyFactory(
00127     const Teuchos::RCP<const Teuchos::AbstractFactory<LinearOpWithSolveFactoryBase<double> > >  &solveStrategyFactory
00128     ,const std::string                                                                                  &solveStrategyName
00129     );
00130 
00132   void setPreconditioningStrategyFactory(
00133     const Teuchos::RCP<const Teuchos::AbstractFactory<PreconditionerFactoryBase<double> > >     &precStrategyFactory
00134     ,const std::string                                                                                  &precStrategyName
00135     );
00136 
00153   void setupCLP( Teuchos::CommandLineProcessor *clp );
00154 
00173   void readParameters( std::ostream *out );
00174 
00190   void writeParamsFile(
00191     const LinearOpWithSolveFactoryBase<double>   &lowsFactory
00192     ,const std::string                           &outputXmlFileName  = "" 
00193     ) const;
00194   
00198   std::string getLinearSolveStrategyName() const;
00199 
00203   std::string getPreconditionerStrategyName() const;
00204 
00206 
00209 
00211   void setParameterList(Teuchos::RCP<Teuchos::ParameterList> const& paramList);
00213   Teuchos::RCP<Teuchos::ParameterList> getParameterList();
00215   Teuchos::RCP<Teuchos::ParameterList> unsetParameterList();
00217   Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const;
00219   Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
00220 
00222   
00225 
00227   Teuchos::RCP<LinearOpWithSolveFactoryBase<double> >
00228   createLinearSolveStrategy(
00229     const std::string &linearSolveStrategyName
00230     ) const;
00232   Teuchos::RCP<PreconditionerFactoryBase<double> >
00233   createPreconditioningStrategy(
00234     const std::string &preconditioningStrategyName
00235     ) const;
00236 
00238 
00239 private:
00240 
00241   // //////////////////////////////////////
00242   // Private types
00243 
00244   typedef Teuchos::RCP<const Teuchos::AbstractFactory<LinearOpWithSolveFactoryBase<double> > > lowsf_fcty_t;
00245   typedef Teuchos::RCP<const Teuchos::AbstractFactory<PreconditionerFactoryBase<double> > > pf_fcty_t;
00246 
00247   // //////////////////////////////////////
00248   // Private data members
00249   
00250   Teuchos::RCP<Teuchos::ParameterList> paramList_;
00251   mutable Teuchos::RCP<const Teuchos::ParameterList> validParamList_;
00252   Teuchos::Array<std::string> validLowsfNames_;
00253   Teuchos::Array<lowsf_fcty_t> lowsfArray_;
00254   std::string defaultLOWSF_;
00255   Teuchos::Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
00256   Teuchos::Array<pf_fcty_t> pfArray_;
00257   std::string defaultPF_;
00258   bool enableDelayedSolverConstruction_;
00259 
00260   // //////////////////////////////////////
00261   // Private member functions
00262 
00263   void initializeDefaults();
00264 
00265 };
00266 
00267 } // namespace Thyra
00268 
00269 #endif // THYRA_DEFAULT_REAL_LINEAR_SOLVER_BUILDING_BASE

Generated on Wed Jul 22 13:20:35 2009 for Stratimikos by doxygen 1.5.8