BITL_Solver.hpp 1.71 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <dune/amdis/linear_algebra/mtl/ITL_Solver.hpp>

namespace AMDiS
{

  template <class SubMatrix, size_t N, size_t M, class Vector>
  struct SolverCreator< BlockMTLMatrix<SubMatrix, N, M>, Vector >
  {
    using Matrix = BlockMTLMatrix<SubMatrix, N, M>;
    using SolverBase = LinearSolverInterface<Matrix, Vector, Vector>;
    
    template <class ITLSolver>
    using Solver = LinearSolver<Matrix, Vector, 
                      KrylovRunner<ITLSolver, Matrix, BaseVector<Vector>>>;
    
    /// Instantiate a new linear solver
    static std::unique_ptr<SolverBase> create(std::string name, std::string prefix)
    { 
      if (name == "cg")
        return std::make_unique<Solver<cg_solver_type>>(prefix);
      else if (name == "cgs")
        return std::make_unique<Solver<cgs_solver_type>>(prefix);
      else if (name == "bicgstab" || name == "bcgs")
        return std::make_unique<Solver<bicgstab_type>>(prefix);
      else if (name == "tfqmr")
        return std::make_unique<Solver<tfqmr_solver_type>>(prefix);
      else if (name == "bicgstab_ell" || name == "bcgsl")
        return std::make_unique<Solver<bicgstab_ell_type>>(prefix);
      else if (name == "gmres")
        return std::make_unique<Solver<gmres_type>>(prefix);
      else if (name == "fgmres")
        return std::make_unique<Solver<fgmres_type>>(prefix);
      else if (name == "minres")
        return std::make_unique<Solver<minres_solver_type>>(prefix);
      else if (name == "gcr")
        return std::make_unique<Solver<gcr_type>>(prefix);
//       else if (name == "preonly")
//         return std::make_unique<Solver<preonly_type>>(prefix);
      else
        AMDIS_ERROR_EXIT("Unknown Solver-name!");
    }
  };

} // end namespace AMDiS