aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Gather/GetExternalFields.cpp
blob: d97a69985a40a417456e2fc2af060fd823b0a6ec (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
82
83
84
85
86
#include "Particles/Gather/GetExternalFields.H"

#include "Particles/MultiParticleContainer.H"
#include "Particles/WarpXParticleContainer.H"
#include "WarpX.H"

#include <AMReX_Vector.H>

#include <string>


GetExternalEField::GetExternalEField (const WarpXParIter& a_pti, int a_offset) noexcept
{
    auto& warpx = WarpX::GetInstance();
    auto& mypc = warpx.GetPartContainer();
    if (mypc.m_E_ext_particle_s=="constant" || mypc.m_E_ext_particle_s=="default")
    {
        m_type = Constant;
        m_field_value[0] = mypc.m_E_external_particle[0];
        m_field_value[1] = mypc.m_E_external_particle[1];
        m_field_value[2] = mypc.m_E_external_particle[2];
    }
    else if (mypc.m_E_ext_particle_s=="parse_e_ext_particle_function")
    {
        m_type = Parser;
        m_time = warpx.gett_new(a_pti.GetLevel());
        m_get_position = GetParticlePosition(a_pti, a_offset);
        m_xfield_partparser = mypc.m_Ex_particle_parser->compile<4>();
        m_yfield_partparser = mypc.m_Ey_particle_parser->compile<4>();
        m_zfield_partparser = mypc.m_Ez_particle_parser->compile<4>();
    }
    else if (mypc.m_E_ext_particle_s=="repeated_plasma_lens")
    {
        m_type = RepeatedPlasmaLens;
        m_lens_is_electric = 1;
        m_dt = warpx.getdt(a_pti.GetLevel());
        m_get_position = GetParticlePosition(a_pti, a_offset);
        auto& attribs = a_pti.GetAttribs();
        m_ux = attribs[PIdx::ux].dataPtr() + a_offset;
        m_uy = attribs[PIdx::uy].dataPtr() + a_offset;
        m_uz = attribs[PIdx::uz].dataPtr() + a_offset;
        m_repeated_plasma_lens_period = mypc.m_repeated_plasma_lens_period;
        m_n_lenses = static_cast<int>(mypc.h_repeated_plasma_lens_starts.size());
        m_repeated_plasma_lens_starts = mypc.d_repeated_plasma_lens_starts.data();
        m_repeated_plasma_lens_lengths = mypc.d_repeated_plasma_lens_lengths.data();
        m_repeated_plasma_lens_strengths = mypc.d_repeated_plasma_lens_strengths_E.data();
    }
}

GetExternalBField::GetExternalBField (const WarpXParIter& a_pti, int a_offset) noexcept
{
    auto& warpx = WarpX::GetInstance();
    auto& mypc = warpx.GetPartContainer();
    if (mypc.m_B_ext_particle_s=="constant" || mypc.m_B_ext_particle_s=="default")
    {
        m_type = Constant;
        m_field_value[0] = mypc.m_B_external_particle[0];
        m_field_value[1] = mypc.m_B_external_particle[1];
        m_field_value[2] = mypc.m_B_external_particle[2];
    }
    else if (mypc.m_B_ext_particle_s=="parse_b_ext_particle_function")
    {
        m_type = Parser;
        m_time = warpx.gett_new(a_pti.GetLevel());
        m_get_position = GetParticlePosition(a_pti, a_offset);
        m_xfield_partparser = mypc.m_Bx_particle_parser->compile<4>();
        m_yfield_partparser = mypc.m_By_particle_parser->compile<4>();
        m_zfield_partparser = mypc.m_Bz_particle_parser->compile<4>();
    }
    else if (mypc.m_B_ext_particle_s=="repeated_plasma_lens")
    {
        m_type = RepeatedPlasmaLens;
        m_lens_is_electric = 0;
        m_dt = warpx.getdt(a_pti.GetLevel());
        m_get_position = GetParticlePosition(a_pti, a_offset);
        auto& attribs = a_pti.GetAttribs();
        m_ux = attribs[PIdx::ux].dataPtr() + a_offset;
        m_uy = attribs[PIdx::uy].dataPtr() + a_offset;
        m_uz = attribs[PIdx::uz].dataPtr() + a_offset;
        m_repeated_plasma_lens_period = mypc.m_repeated_plasma_lens_period;
        m_n_lenses = static_cast<int>(mypc.h_repeated_plasma_lens_starts.size());
        m_repeated_plasma_lens_starts = mypc.d_repeated_plasma_lens_starts.data();
        m_repeated_plasma_lens_lengths = mypc.d_repeated_plasma_lens_lengths.data();
        m_repeated_plasma_lens_strengths = mypc.d_repeated_plasma_lens_strengths_B.data();
    }
}