OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
BelosBottomSolver.h
Go to the documentation of this file.
1 //
2 // Class BelosBottomSolver
3 // Interface to Belos solvers of the Trilinos package.
4 //
5 // Copyright (c) 2017 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // Implemented as part of the PhD thesis
9 // "Precise Simulations of Multibunches in High Intensity Cyclotrons"
10 //
11 // This file is part of OPAL.
12 //
13 // OPAL is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20 //
21 #ifndef BELOS_SOLVER_H
22 #define BELOS_SOLVER_H
23 
24 #include "BottomSolver.h"
25 
26 #include <BelosLinearProblem.hpp>
27 #include <BelosTpetraAdapter.hpp>
28 #include <BelosSolverFactory.hpp>
29 
30 #include "AmrPreconditioner.h"
31 
32 #include <string>
33 
34 template <class Level>
35 class BelosBottomSolver : public BottomSolver<Teuchos::RCP<amr::matrix_t>,
36  Teuchos::RCP<amr::multivector_t>,
37  Level>
38 {
39 public:
48 
49  typedef Belos::SolverManager<scalar_t, mv_t, op_t> solver_t;
50  typedef Belos::LinearProblem<scalar_t, mv_t, op_t> problem_t;
51 
53 
54 public:
55 
60  BelosBottomSolver(std::string solvertype = "Pseudoblock CG",
61  const std::shared_ptr<prec_t>& prec_p = nullptr);
62 
63  void solve(const Teuchos::RCP<mv_t>& x,
64  const Teuchos::RCP<mv_t>& b);
65 
66  void setOperator(const Teuchos::RCP<matrix_t>& A,
67  Level* level_p = nullptr);
68 
69  std::size_t getNumIters();
70 
71 private:
76  void initSolver_m(std::string solvertype);
77 
78 private:
79  Teuchos::RCP<problem_t> problem_mp;
80  Teuchos::RCP<Teuchos::ParameterList> params_mp;
81  Teuchos::RCP<solver_t> solver_mp;
82  std::shared_ptr<prec_t> prec_mp;
83  Teuchos::RCP<matrix_t> A_mp;
84 
86 
88  int maxiter_m;
89 };
90 
91 #include "BelosBottomSolver.hpp"
92 
93 #endif
long global_ordinal_t
Tpetra::Operator< scalar_t, local_ordinal_t, global_ordinal_t, node_t > operator_t
KokkosClassic::DefaultNode::DefaultNodeType node_t
int local_ordinal_t
Tpetra::Vector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > vector_t
double scalar_t
Tpetra::MultiVector< scalar_t, local_ordinal_t, global_ordinal_t, node_t > multivector_t
Tpetra::CrsMatrix< scalar_t, local_ordinal_t, global_ordinal_t, node_t > matrix_t
void initSolver_m(std::string solvertype)
Belos::LinearProblem< scalar_t, mv_t, op_t > problem_t
amr::global_ordinal_t go_t
Teuchos::RCP< Teuchos::ParameterList > params_mp
parameter list of solver
amr::vector_t vector_t
amr::local_ordinal_t lo_t
int maxiter_m
allowed number of steps for iterative solvers
Teuchos::RCP< matrix_t > A_mp
copy of matrix (has to be positive definite)
amr::scalar_t scalar_t
Teuchos::RCP< solver_t > solver_mp
solver instance
std::shared_ptr< prec_t > prec_mp
preconditioner
void solve(const Teuchos::RCP< mv_t > &x, const Teuchos::RCP< mv_t > &b)
AmrPreconditioner< matrix_t, Level > prec_t
Teuchos::RCP< problem_t > problem_mp
represents linear problem
scalar_t reltol_m
relative tolerance
BelosBottomSolver(std::string solvertype="Pseudoblock CG", const std::shared_ptr< prec_t > &prec_p=nullptr)
void setOperator(const Teuchos::RCP< matrix_t > &A, Level *level_p=nullptr)
amr::multivector_t mv_t
Belos::SolverManager< scalar_t, mv_t, op_t > solver_t
amr::matrix_t matrix_t
amr::operator_t op_t
std::size_t getNumIters()