aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/ParticleBoundaries.cpp
blob: 2bdbd0d1405fe289b33e1d3a27b35ec2a34ba1b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Copyright 2021 David Grote
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */

#include "ParticleBoundaries.H"

ParticleBoundaries::ParticleBoundaries () noexcept
{
    SetAll(ParticleBoundaryType::Absorbing);
    data.reflect_all_velocities = false;
}

void
ParticleBoundaries::Set_reflect_all_velocities (bool flag)
{
    data.reflect_all_velocities = flag;
}

void
ParticleBoundaries::SetAll (ParticleBoundaryType bc)
{
    data.xmin_bc = bc;
    data.xmax_bc = bc;
    data.ymin_bc = bc;
    data.ymax_bc = bc;
    data.zmin_bc = bc;
    data.zmax_bc = bc;
}

void
ParticleBoundaries::SetBoundsX (ParticleBoundaryType bc_lo, ParticleBoundaryType bc_hi)
{
    data.xmin_bc = bc_lo;
    data.xmax_bc = bc_hi;
}

void
ParticleBoundaries::SetBoundsY (ParticleBoundaryType bc_lo, ParticleBoundaryType bc_hi)
{
    data.ymin_bc = bc_lo;
    data.ymax_bc = bc_hi;
}

void
ParticleBoundaries::SetBoundsZ (ParticleBoundaryType bc_lo, ParticleBoundaryType bc_hi)
{
    data.zmin_bc = bc_lo;
    data.zmax_bc = bc_hi;
}

bool
ParticleBoundaries::CheckAll (ParticleBoundaryType bc)
{
    return (data.xmin_bc == bc && data.xmax_bc == bc
#ifdef WARPX_DIM_3D
         && data.ymin_bc == bc && data.ymax_bc == bc
#endif
         && data.zmin_bc == bc && data.zmax_bc == bc);
}

void
ParticleBoundaries::BuildReflectionModelParsers ()
{
    reflection_model_xlo_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_xlo_str, {"v"}));
    data.reflection_model_xlo = reflection_model_xlo_parser->compile<1>();
    reflection_model_xhi_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_xhi_str, {"v"}));
    data.reflection_model_xhi = reflection_model_xhi_parser->compile<1>();
#ifdef WARPX_DIM_3D
    reflection_model_ylo_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_ylo_str, {"v"}));
    data.reflection_model_ylo = reflection_model_ylo_parser->compile<1>();
    reflection_model_yhi_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_yhi_str, {"v"}));
    data.reflection_model_yhi = reflection_model_yhi_parser->compile<1>();
#endif
    reflection_model_zlo_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_zlo_str, {"v"}));
    data.reflection_model_zlo = reflection_model_zlo_parser->compile<1>();
    reflection_model_zhi_parser = std::make_unique<amrex::Parser>(makeParser(reflection_model_zhi_str, {"v"}));
    data.reflection_model_zhi = reflection_model_zhi_parser->compile<1>();
}