Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_InverseLibrary.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_InverseLibrary_hpp__
11 #define __Teko_InverseLibrary_hpp__
12 
13 #include "Teko_InverseFactory.hpp"
14 
15 // Teuchos includes
16 #include "Teuchos_ParameterList.hpp"
17 
18 // Stratimikos includes
19 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
20 
21 // Teko includes
22 #include "Teko_RequestHandler.hpp"
23 #include "Teko_RequestHandlerContainer.hpp"
24 
25 namespace Teko {
26 
27 void addToStratimikosBuilder(const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& builder);
28 
29 class InverseLibrary : public RequestHandlerContainer {
30  public:
31  InverseLibrary();
32 
33  InverseLibrary(const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat);
34 
36  void addInverse(const std::string& label, const Teuchos::ParameterList& pl);
37 
39  void addStratSolver(const std::string& label, const std::string& type,
40  const Teuchos::ParameterList& pl);
41 
43  void addStratPrecond(const std::string& label, const std::string& type,
44  const Teuchos::ParameterList& pl);
45 
47  void addBlockPrecond(const std::string& label, const std::string& type,
48  const Teuchos::ParameterList& pl);
49 
57  Teuchos::RCP<const Teuchos::ParameterList> getParameterList(const std::string& label) const;
58 
60  Teuchos::RCP<InverseFactory> getInverseFactory(const std::string& label) const;
61 
63  void PrintAvailableInverses(std::ostream& os) const;
64 
66  void setRequestHandler(const Teuchos::RCP<RequestHandler>& rh) { callbackHandler_ = rh; }
67 
69  Teuchos::RCP<RequestHandler> getRequestHandler() const { return callbackHandler_; }
70 
71  protected:
72  // stratimikos type Inverse objects: mapping the label to a parameter list
73  std::map<std::string, Teuchos::RCP<const Teuchos::ParameterList> > stratSolver_;
74  std::map<std::string, Teuchos::RCP<const Teuchos::ParameterList> > stratPrecond_;
75  std::map<std::string, Teuchos::RCP<const Teuchos::ParameterList> > blockPrecond_;
76 
77  // vectors showing which string types are in Stratimikos
78  std::vector<std::string> stratValidSolver_;
79  std::vector<std::string> stratValidPrecond_;
80  std::vector<std::string> blockValidPrecond_;
81 
83  Teuchos::RCP<RequestHandler> callbackHandler_;
84 
86  Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder> defaultBuilder_;
87 
88  public:
99  static Teuchos::RCP<InverseLibrary> buildFromParameterList(const Teuchos::ParameterList& pl,
100  bool useStratDefaults = true);
101 
112  static Teuchos::RCP<InverseLibrary> buildFromParameterList(
113  const Teuchos::ParameterList& pl,
114  const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat);
115 
124  static Teuchos::RCP<InverseLibrary> buildFromStratimikos();
125 
135  static Teuchos::RCP<InverseLibrary> buildFromStratimikos(
136  const Stratimikos::DefaultLinearSolverBuilder& strat);
137 
147  static Teuchos::RCP<InverseLibrary> buildFromStratimikos(
148  const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat);
149 };
150 
151 } // end namespace Teko
152 
153 #endif