Amesos2BottomSolver.h 1.8 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4
//
// Class Amesos2BottomSolver
//   Interface to Amesos2 solvers of the Trilinos package.
//
frey_m's avatar
frey_m committed
5
// Copyright (c) 2017 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
frey_m's avatar
frey_m committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//

frey_m's avatar
frey_m committed
22 23
#ifndef AMESOS2_SOLVER_H
#define AMESOS2_SOLVER_H
24

frey_m's avatar
frey_m committed
25
#include "BottomSolver.h"
26 27 28 29 30

#include <Amesos2.hpp>

#include <string>

frey_m's avatar
frey_m committed
31 32
extern Inform* gmsg;

frey_m's avatar
frey_m committed
33
template <class Level>
frey_m's avatar
frey_m committed
34 35 36
class Amesos2BottomSolver : public BottomSolver<Teuchos::RCP<amr::matrix_t>,
                                                Teuchos::RCP<amr::multivector_t>,
                                                Level>
37 38 39
{
public:
    typedef amr::matrix_t matrix_t;
40
    typedef amr::multivector_t mv_t;
41
    
42
    typedef Amesos2::Solver<matrix_t, mv_t> solver_t;
43 44 45
    
public:
    
46 47 48 49
    /*!
     * Instantiate
     * @param solvertype of Amesos2
     */
frey_m's avatar
frey_m committed
50
    Amesos2BottomSolver(std::string solvertype = "klu2");
51
    
52 53
    void solve(const Teuchos::RCP<mv_t>& x,
               const Teuchos::RCP<mv_t>& b);
54
    
frey_m's avatar
frey_m committed
55 56
    void setOperator(const Teuchos::RCP<matrix_t>& A,
                     Level* level_p = nullptr);
57
    
frey_m's avatar
frey_m committed
58 59
    std::size_t getNumIters();
    
60 61
private:
    
62
    std::string solvertype_m;           ///< kind of solver
63
    
64
    Teuchos::RCP<solver_t> solver_mp;   ///< solver instance
65 66
};

frey_m's avatar
frey_m committed
67
#include "Amesos2BottomSolver.hpp"
frey_m's avatar
frey_m committed
68

69
#endif