AmrDirichletBoundary.h 2.04 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4 5
//
// Class AmrDirichletBoundary
//   Dirichlet boundary is on faces of physical domain the boundary
//   value would be at different locations depending on the level.
//
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
#ifndef AMR_DIRICHLET_BOUNDARY_H
#define AMR_DIRICHLET_BOUNDARY_H

#include "AmrBoundary.h"

frey_m's avatar
frey_m committed
28 29
template <class Level>
class AmrDirichletBoundary : public AmrBoundary<Level> {
30
    
31
public:
frey_m's avatar
frey_m committed
32 33
    typedef typename Level::umap_t      umap_t;
    typedef typename Level::lo_t        lo_t;
frey_m's avatar
frey_m committed
34
    typedef typename Level::go_t        go_t;
frey_m's avatar
frey_m committed
35 36
    typedef typename Level::scalar_t    scalar_t;
    typedef amr::AmrIntVect_t           AmrIntVect_t;
37
    
38 39
public:
    
frey_m's avatar
frey_m committed
40
    AmrDirichletBoundary() : AmrBoundary<Level>(1) { }
41 42
    
    void apply(const AmrIntVect_t& iv,
43 44 45
               const lo_t& dir,
               umap_t& map,
               const scalar_t& value,
frey_m's avatar
frey_m committed
46
               Level* mglevel,
frey_m's avatar
frey_m committed
47
               const go_t* nr);
48 49 50
};


frey_m's avatar
frey_m committed
51 52 53 54 55 56
template <class Level>
void AmrDirichletBoundary<Level>::apply(const AmrIntVect_t& iv,
                                        const lo_t& dir,
                                        umap_t& map,
                                        const scalar_t& value,
                                        Level* mglevel,
frey_m's avatar
frey_m committed
57
                                        const go_t* nr)
58 59
{
    // find interior neighbour cell
60 61 62
    AmrIntVect_t niv = iv;
    niv[dir] = (iv[dir] == -1) ? iv[dir] + 1 : iv[dir] - 1;
    map[mglevel->serialize(niv)] -= value;
63 64
}

65 66 67



68
#endif