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
// 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/>.
//
21 22 23
#ifndef AMR_SMOOTHER_H
#define AMR_SMOOTHER_H

24 25
#include <string>

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

#include "Ifpack2_Factory.hpp"

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

#endif