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
// 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 25 26
#ifndef AMR_DIRICHLET_BOUNDARY_H
#define AMR_DIRICHLET_BOUNDARY_H

#include "AmrBoundary.h"

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


frey_m's avatar
frey_m committed
50 51 52 53 54 55
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
56
                                        const go_t* nr)
57 58
{
    // find interior neighbour cell
59 60 61
    AmrIntVect_t niv = iv;
    niv[dir] = (iv[dir] == -1) ? iv[dir] + 1 : iv[dir] - 1;
    map[mglevel->serialize(niv)] -= value;
62 63
}

64 65 66



67
#endif