AmrInterpolater.h 5.54 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4
//
// Class AmrInterpolater
//   Abstract base class for all coarse to fine cell interpolaters.
//
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_INTERPOLATER_H
#define AMR_INTERPOLATER_H

24
#include "Amr/AmrDefs.h"
25

frey_m's avatar
frey_m committed
26
template <class Level>
27
class AmrInterpolater {
28 29

public:
30 31 32 33 34 35
    typedef typename Level::go_t        go_t;
    typedef typename Level::lo_t        lo_t;
    typedef typename Level::scalar_t    scalar_t;
    typedef typename Level::umap_t      umap_t;
    typedef typename Level::basefab_t   basefab_t;
    typedef amr::AmrIntVect_t           AmrIntVect_t;
36 37 38 39 40 41
    
public:
    
    /*!
     * @param nPoints is the number of interpolation points used
     */
42
    AmrInterpolater(lo_t nPoints) : nPoints_m(nPoints) { }
43 44 45 46
    
    /*!
     * Number of cell points used for interpolation.
     */
47
    const lo_t& getNumberOfPoints() const {
48 49 50 51 52 53
        return nPoints_m;
    }
    
    /*!
     * Get the stencil to interpolate a value from coarse to fine level
     * @param iv is the fine cell where we want to have the interpolated value
54 55 56
     * @param map with global matrix indices of coarse level cells and
     * matrix entries of coarse level cells (coefficients)
     * @param scale to apply to matrix values
57 58 59 60
     * @param mglevel used to get the global indices and refinement ratio among levels,
     * and boundary values at physical domain, e.g. Dirichlet, open BC
     */
    virtual void stencil(const AmrIntVect_t& iv,
61 62 63
                         const basefab_t& fab,
                         umap_t& map,
                         const scalar_t& scale,
frey_m's avatar
frey_m committed
64
                         Level* mglevel) = 0;
65 66 67 68 69
    
    /*!
     * Coarse-Fine-Interface
     * Get stencil of coarse side
     * @param iv is the coarse cell at the interface (center cell of Laplacian)
70 71 72
     * @param map with global matrix indices of coarse level cells and
     * matrix entries of coarse level cells (coefficients)
     * @param scale of matrix values
73 74 75 76 77 78 79 80 81 82
     * @param dir direction of interface (0 "horizontal", 1 "vertical", 2 "longitudinal")
     * @param shift is either -1 or 1. If the refined coarse cell is on the left / lower / front
     * side, shift is equal to -1, otherwise the interface is on the right / upper / back side
     * and the value is 1.
     * @param ba contains all coarse cells that got refined
     * @param riv is the fine cell at the interface
     * @param mglevel used to get the global indices and refinement ratio among levels,
     * and boundary values at physical domain, e.g. Dirichlet, open BC
     */
    virtual void coarse(const AmrIntVect_t& iv,
83 84 85
                        umap_t& map,
                        const scalar_t& scale,
                        lo_t dir, lo_t shift, const basefab_t& rfab,
86
                        const AmrIntVect_t& riv,
frey_m's avatar
frey_m committed
87
                        Level* mglevel) = 0;
88 89 90 91 92 93
    
    /*!
     * Coarse-Fine-Interface
     * Get stencil of fine side
     * @param iv is the fine ghost cell at the interface (on coarse cell that is not
     * refined)
94 95 96
     * @param map with global matrix indices of fine level cells and
     * matrix entries of fine level cells (coefficients)
     * @param scale of matrix values
97 98 99 100 101 102 103 104 105
     * @param dir direction of interface (0 "horizontal", 1 "vertical", 2 "longitudinal")
     * @param shift is either -1 or 1. If the refined coarse cell is on the left / lower / front
     * side, shift is equal to -1, otherwise the interface is on the right / upper / back side
     * and the value is 1.
     * @param ba contains all coarse cells that got refined
     * @param mglevel used to get the global indices and refinement ratio among levels,
     * and boundary avlues at physical domain, e.g. Dirichlet, open BC
     */
    virtual void fine(const AmrIntVect_t& iv,
106 107 108
                      umap_t& map,
                      const scalar_t& scale,
                      lo_t dir, lo_t shift, const basefab_t& fab,
frey_m's avatar
frey_m committed
109
                      Level* mglevel)
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
    { };

    /*!
     * Coarse-Fine-Interface
     * Get stencil of fine side
     * @param iv is the fine ghost cell at the interface (on coarse cell that is not
     * refined)
     * @param map with global matrix indices of fine level cells and
     * matrix entries of fine level cells (coefficients)
     * @param scale of matrix values
     * @param dir direction of interface (0 "horizontal", 1 "vertical", 2 "longitudinal")
     * @param shift is either -1 or 1. If the refined coarse cell is on the left / lower / front
     * side, shift is equal to -1, otherwise the interface is on the right / upper / back side
     * and the value is 1.
     * @param mglevel used to get the global indices and refinement ratio among levels,
     * and boundary avlues at physical domain, e.g. Dirichlet, open BC
     */
    virtual void fine(const AmrIntVect_t& iv,
                      umap_t& map,
                      const scalar_t& scale,
                      lo_t dir, lo_t shift,
frey_m's avatar
frey_m committed
131
                      Level* mglevel)
132
    { };
133 134
    
protected:
135
    const lo_t nPoints_m;    ///< Number of points used for interpolation
136 137 138
};

#endif