AmrSmoother.h 2.71 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4
//
// Class AmrSmoother
//   Interface to Ifpack2 smoothers 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/>.
//

22 23 24
#ifndef AMR_SMOOTHER_H
#define AMR_SMOOTHER_H

25 26
#include <string>

27
#include "AmrMultiGridDefs.h"
28 29 30 31 32 33

#include "Ifpack2_Factory.hpp"

class AmrSmoother {
    
public:
34 35 36 37 38 39
    typedef amr::global_ordinal_t   go_t;
    typedef amr::local_ordinal_t    lo_t;
    typedef amr::scalar_t           scalar_t;
    typedef amr::node_t             node_t;
    typedef amr::matrix_t           matrix_t;
    typedef amr::vector_t           vector_t;
40
    typedef Ifpack2::Preconditioner<scalar_t,
41 42
                                    lo_t,
                                    go_t,
43
                                    node_t
44
            > preconditioner_t;
45
    
46
    /// All supported Ifpack2 smoothers
47 48 49 50 51 52 53 54
    enum Smoother {
        GAUSS_SEIDEL = 0,
        SGS,    // symmetric Gauss-Seidel
        JACOBI //,
//         SOR
    };
    
public:
55 56 57 58 59
    /*!
     * @param A matrix to build smoother for
     * @param smoother type
     * @param nSweeps number of iterations per smoohting step
     */
60 61
    AmrSmoother(const Teuchos::RCP<const matrix_t>& A,
                const Smoother& smoother,
62
                lo_t nSweeps);
63 64 65
    
    ~AmrSmoother();
    
66 67 68 69 70 71
    /*!
     * Perform one smoothing step
     * @param x right-hand side
     * @param A system matrix
     * @param b right-hand side
     */
72 73 74 75
    void smooth(const Teuchos::RCP<vector_t>& x,
                const Teuchos::RCP<matrix_t>& A,
                const Teuchos::RCP<vector_t>& b);
    
76 77 78 79 80
    /*!
     * Used in AmrMultiGrid constructor
     * @param smoother to create
     */
    static Smoother convertToEnumSmoother(const std::string& smoother);
81 82
    
private:
83 84 85 86 87
    /*!
     * Initialize paramter list for Ifpack2 smoothers
     * @param smoother of Ifpack2
     * @param nSweeps number of iterations
     */
88
    void initParameter_m(const Smoother& smoother,
89
                         lo_t nSweeps);
90 91 92
    
    
private:
93
    /// Preconditioner instance
94 95
    Teuchos::RCP<preconditioner_t> prec_mp;
    
96
    /// Parameters of preconditioner
97 98 99 100
    Teuchos::RCP<Teuchos::ParameterList> params_mp;
};

#endif