Stratimikos Package Browser (Single Doxygen Collection) Version of the Day
Stratimikos_DefaultLinearSolverBuilder.hpp
Go to the documentation of this file.
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 STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
00030 #define STRATIMIKOS_DEFAULT_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 #include "Teuchos_StandardParameterEntryValidators.hpp"
00037 
00038 // Include these to make all of the helpful decls appear
00039 #include "Thyra_EpetraThyraWrappers.hpp"
00040 #include "Thyra_EpetraLinearOp.hpp"
00041 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
00042 #include "Thyra_LinearOpWithSolveBase.hpp"
00043 #include "Thyra_PreconditionerFactoryHelpers.hpp"
00044 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
00045 #include "Thyra_DefaultPreconditioner.hpp"
00046 #include "Thyra_MultiVectorStdOps.hpp"
00047 #include "Thyra_VectorStdOps.hpp"
00048 #include "Thyra_VectorBase.hpp"
00049 
00050 
00051 namespace Teuchos { class CommandLineProcessor; }
00052 
00053 
00054 namespace Stratimikos {
00055 
00056 
00058 using Teuchos::RCP;
00060 using Teuchos::Array;
00062 using Teuchos::AbstractFactory;
00064 using Teuchos::ParameterList;
00065 
00066 
00095 class DefaultLinearSolverBuilder
00096   : public Thyra::LinearSolverBuilderBase<double>
00097 {
00098 public:
00099 
00102 
00110   DefaultLinearSolverBuilder(
00111     const std::string    &paramsXmlFileName                = ""
00112     ,const std::string   &extraParamsXmlString             = ""
00113     ,const std::string   &paramsUsedXmlOutFileName         = ""
00114     ,const std::string   &paramsXmlFileNameOption          = "linear-solver-params-file"
00115     ,const std::string   &extraParamsXmlStringOption       = "extra-linear-solver-params"
00116     ,const std::string   &paramsUsedXmlOutFileNameOption   = "linear-solver-params-used-file"
00117     );
00118 
00120   ~DefaultLinearSolverBuilder();
00121   
00125   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
00126     
00130   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
00131 
00135   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
00136 
00140   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
00141 
00145   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
00146 
00150   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
00151 
00153   void setLinearSolveStrategyFactory(
00154     const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
00155     &solveStrategyFactory,
00156     const std::string &solveStrategyName,
00157     const bool makeDefault = false
00158     );
00159 
00161   void setDefaultLinearSolveStrategyFactoryName(
00162     const std::string &solveStrategyName);
00163 
00165   void setPreconditioningStrategyFactory(
00166     const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
00167     &precStrategyFactory,
00168     const std::string &precStrategyName,
00169     const bool makeDefault = false
00170     );
00171 
00173   void setDefaultPreconditioningStrategyFactoryName(
00174     const std::string &precStrategyName);
00175 
00192   void setupCLP( Teuchos::CommandLineProcessor *clp );
00193 
00212   void readParameters( std::ostream *out );
00213 
00229   void writeParamsFile(
00230     const Thyra::LinearOpWithSolveFactoryBase<double> &lowsFactory,
00231     const std::string &outputXmlFileName  = "" 
00232     ) const;
00233   
00237   std::string getLinearSolveStrategyName() const;
00238 
00242   std::string getPreconditionerStrategyName() const;
00243 
00245 
00248 
00250   void setParameterList(RCP<ParameterList> const& paramList);
00252   RCP<ParameterList> getNonconstParameterList();
00254   RCP<ParameterList> unsetParameterList();
00256   RCP<const ParameterList> getParameterList() const;
00258   RCP<const ParameterList> getValidParameters() const;
00259 
00261   
00264 
00266   RCP<Thyra::LinearOpWithSolveFactoryBase<double> >
00267   createLinearSolveStrategy(
00268     const std::string &linearSolveStrategyName
00269     ) const;
00271   RCP<Thyra::PreconditionerFactoryBase<double> >
00272   createPreconditioningStrategy(
00273     const std::string &preconditioningStrategyName
00274     ) const;
00275 
00277 
00278 private:
00279 
00280   // //////////////////////////////////////
00281   // Private types
00282 
00283   typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
00284   lowsf_fcty_t;
00285   typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
00286   pf_fcty_t;
00287 
00288   // //////////////////////////////////////
00289   // Private data members
00290   
00291   RCP<ParameterList> paramList_;
00292   Array<std::string> validLowsfNames_;
00293   Array<lowsf_fcty_t> lowsfArray_;
00294   std::string defaultLOWSF_;
00295   Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
00296   Array<pf_fcty_t> pfArray_;
00297   std::string defaultPF_;
00298   bool enableDelayedSolverConstruction_;
00299   mutable RCP<const ParameterList> validParamList_;
00300   mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > lowsfValidator_;
00301   mutable RCP<const Teuchos::StringToIntegralParameterEntryValidator<int> > pfValidator_;
00302 
00303   // //////////////////////////////////////
00304   // Private member functions
00305 
00306   void initializeDefaults();
00307   void justInTimeInitialize() const;
00308 
00309 };
00310 
00311 
00312 } // namespace Stratimikos
00313 
00314 
00315 #endif // STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines