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 
00037 
00038 namespace Teuchos { class CommandLineProcessor; }
00039 
00040 
00041 namespace Stratimikos {
00042 
00043 
00045 using Teuchos::RCP;
00047 using Teuchos::Array;
00049 using Teuchos::AbstractFactory;
00051 using Teuchos::ParameterList;
00052 
00053 
00082 class DefaultLinearSolverBuilder
00083   : public Thyra::LinearSolverBuilderBase<double>
00084 {
00085 public:
00086 
00089 
00097   DefaultLinearSolverBuilder(
00098     const std::string    &paramsXmlFileName                = ""
00099     ,const std::string   &extraParamsXmlString             = ""
00100     ,const std::string   &paramsUsedXmlOutFileName         = ""
00101     ,const std::string   &paramsXmlFileNameOption          = "linear-solver-params-file"
00102     ,const std::string   &extraParamsXmlStringOption       = "extra-linear-solver-params"
00103     ,const std::string   &paramsUsedXmlOutFileNameOption   = "linear-solver-params-used-file"
00104     );
00105 
00107   ~DefaultLinearSolverBuilder();
00108   
00112   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileName);
00113     
00117   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlString);
00118 
00122   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileName);
00123 
00127   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsXmlFileNameOption);
00128 
00132   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,extraParamsXmlStringOption);
00133 
00137   STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string,paramsUsedXmlOutFileNameOption);
00138 
00140   void setLinearSolveStrategyFactory(
00141     const RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
00142     &solveStrategyFactory,
00143     const std::string &solveStrategyName
00144     );
00145 
00147   void setPreconditioningStrategyFactory(
00148     const RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
00149     &precStrategyFactory,
00150     const std::string &precStrategyName
00151     );
00152 
00169   void setupCLP( Teuchos::CommandLineProcessor *clp );
00170 
00189   void readParameters( std::ostream *out );
00190 
00206   void writeParamsFile(
00207     const Thyra::LinearOpWithSolveFactoryBase<double> &lowsFactory,
00208     const std::string &outputXmlFileName  = "" 
00209     ) const;
00210   
00214   std::string getLinearSolveStrategyName() const;
00215 
00219   std::string getPreconditionerStrategyName() const;
00220 
00222 
00225 
00227   void setParameterList(RCP<ParameterList> const& paramList);
00229   RCP<ParameterList> getNonconstParameterList();
00231   RCP<ParameterList> unsetParameterList();
00233   RCP<const ParameterList> getParameterList() const;
00235   RCP<const ParameterList> getValidParameters() const;
00236 
00238   
00241 
00243   RCP<Thyra::LinearOpWithSolveFactoryBase<double> >
00244   createLinearSolveStrategy(
00245     const std::string &linearSolveStrategyName
00246     ) const;
00248   RCP<Thyra::PreconditionerFactoryBase<double> >
00249   createPreconditioningStrategy(
00250     const std::string &preconditioningStrategyName
00251     ) const;
00252 
00254 
00255 private:
00256 
00257   // //////////////////////////////////////
00258   // Private types
00259 
00260   typedef RCP<const AbstractFactory<Thyra::LinearOpWithSolveFactoryBase<double> > >
00261   lowsf_fcty_t;
00262   typedef RCP<const AbstractFactory<Thyra::PreconditionerFactoryBase<double> > >
00263   pf_fcty_t;
00264 
00265   // //////////////////////////////////////
00266   // Private data members
00267   
00268   RCP<ParameterList> paramList_;
00269   mutable RCP<const ParameterList> validParamList_;
00270   Array<std::string> validLowsfNames_;
00271   Array<lowsf_fcty_t> lowsfArray_;
00272   std::string defaultLOWSF_;
00273   Array<std::string> validPfNames_; // Contains "None" as the 0th entry!
00274   Array<pf_fcty_t> pfArray_;
00275   std::string defaultPF_;
00276   bool enableDelayedSolverConstruction_;
00277 
00278   // //////////////////////////////////////
00279   // Private member functions
00280 
00281   void initializeDefaults();
00282 
00283 };
00284 
00285 
00286 } // namespace Stratimikos
00287 
00288 
00289 #endif // STRATIMIKOS_DEFAULT_LINEAR_SOLVER_BUILDING_BASE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Generated on Wed Apr 13 10:19:51 2011 for Stratimikos Package Browser (Single Doxygen Collection) by  doxygen 1.6.3