Debian Codegraph @

packages/belos/tpetra/src/solvers/Belos_Tpetra_SolverManager.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Belos: Block Linear Solvers Package
4 //
5 // Copyright 2004-2016 NTESS and the Belos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef BELOS_TPETRA_SOLVER_MANAGER_HPP
11 #define BELOS_TPETRA_SOLVER_MANAGER_HPP
12
13 #include "Belos_Tpetra_Krylov.hpp"
14 #include "Belos_Tpetra_SolverManagerBase.hpp"
15
16 namespace BelosTpetra {
17 namespace Impl {
18
19 /// \brief Concrete Belos::SolverManager subclass that users get when
20 /// they ask for one of the methods that a subclass of Krylov
21 /// implements.
22 template<class SC, class MV, class OP,
23 template<class, class, class> class KrylovSubclassType>
24 class SolverManager :
25 public SolverManagerBase<SC, MV, OP>
26 {
27 private:
28 using solver_impl_type = KrylovSubclassType<SC, MV, OP>;
29 using solver_base_type = Krylov<SC, MV, OP>;
30
31 static Teuchos::RCP<solver_base_type>
32 makeSolverImplementation ()
33 {
34 return Teuchos::RCP<solver_base_type> (static_cast<solver_base_type*> (new solver_impl_type));
35 }
36
37 public:
38 SolverManager (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) :
39 SolverManagerBase<SC, MV, OP>::SolverManagerBase (makeSolverImplementation (),
40 params)
41 {}
42
43 virtual ~SolverManager () = default;
44
45 virtual Teuchos::RCP<Belos::SolverManager<SC, MV, OP> >
46 clone () const override
47 {
48 using this_type = SolverManager<SC, MV, OP, KrylovSubclassType>;
49 Teuchos::RCP<this_type> solver (new this_type);
50 return Teuchos::rcp_implicit_cast<Belos::SolverManager<SC, MV, OP>> (solver);
51 }
52 };
53
54 } // namespace Impl
55 } // namespace BelosTpetra
56
57 #endif // BELOS_TPETRA_SOLVER_MANAGER_HPP
58