MueLuPreconditioner.h 2.12 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4 5
//
// Class MueLuPreconditioner
//   Interface to the SAAMG solver of MueLu. Here it is used as preconditioner for Belos
//   iterative solvers.
//
frey_m's avatar
frey_m committed
6
// Copyright (c) 2017 - 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
frey_m's avatar
frey_m committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// 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/>.
//

23 24 25 26 27 28 29 30 31
#ifndef MUELU_PRECONDITIONER_H
#define MUELU_PRECONDITIONER_H

#include "AmrPreconditioner.h"
#include "Amr/AmrDefs.h"

#include <MueLu.hpp>
#include <MueLu_TpetraOperator.hpp>

frey_m's avatar
frey_m committed
32 33
template <class Level>
class MueLuPreconditioner : public AmrPreconditioner<amr::matrix_t, Level>
34 35
{
public:
36 37
    typedef amr::Preconditioner Preconditioner;
    
frey_m's avatar
frey_m committed
38 39 40 41 42
    typedef amr::scalar_t scalar_t;
    typedef amr::local_ordinal_t lo_t;
    typedef amr::global_ordinal_t go_t;
    typedef amr::AmrBox_t AmrBox_t;
    
43
    typedef MueLu::TpetraOperator<
frey_m's avatar
frey_m committed
44 45 46
        scalar_t,
        lo_t,
        go_t,
47 48 49 50 51
        amr::node_t
    > precond_t;
    
    typedef amr::AmrIntVect_t AmrIntVect_t;
    
52 53
    typedef std::map<std::string, Preconditioner> map_t;
    
54 55
public:
    
frey_m's avatar
frey_m committed
56 57
    MueLuPreconditioner(const bool& rebalance,
                        const std::string& reuse);
58
    
frey_m's avatar
frey_m committed
59
    void create(const Teuchos::RCP<amr::matrix_t>& A, Level* level_p =  nullptr);
60 61 62
    
    Teuchos::RCP<amr::operator_t> get();
    
63 64
    static void fillMap(map_t& map);
    
frey_m's avatar
frey_m committed
65 66
    static std::string convertToMueLuReuseOption(const std::string& reuse);
    
67
private:
frey_m's avatar
frey_m committed
68
    void init_m(const std::string& reuse);
69

70 71 72 73 74 75
private:
    Teuchos::ParameterList params_m;
    
    Teuchos::RCP<precond_t> prec_mp;

    Teuchos::RCP<amr::multivector_t> coords_mp;
frey_m's avatar
frey_m committed
76
    
77
    const bool rebalance_m;
78 79
};

frey_m's avatar
frey_m committed
80 81
#include "MueLuPreconditioner.hpp"

82
#endif