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
|
#ifndef WARPX_PARTICLES_GATHER_GETEXTERNALFIELDS_H_
#define WARPX_PARTICLES_GATHER_GETEXTERNALFIELDS_H_
#include "Particles/WarpXParticleContainer.H"
#include "Particles/Pusher/GetAndSetPosition.H"
#include <AMReX_REAL.H>
#include <limits>
enum ExternalFieldInitType { Constant, Parser };
/** \brief Base class for functors that assign external
* field values (E or B) to particles.
*/
struct GetExternalField
{
ExternalFieldInitType m_type;
amrex::GpuArray<amrex::ParticleReal, 3> m_field_value;
HostDeviceParser<4> m_xfield_partparser;
HostDeviceParser<4> m_yfield_partparser;
HostDeviceParser<4> m_zfield_partparser;
GetParticlePosition m_get_position;
amrex::Real m_time;
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void operator () (long i,
amrex::ParticleReal& field_x,
amrex::ParticleReal& field_y,
amrex::ParticleReal& field_z) const noexcept
{
if (m_type == Constant)
{
field_x += m_field_value[0];
field_y += m_field_value[1];
field_z += m_field_value[2];
}
else if (m_type == Parser)
{
amrex::ParticleReal x, y, z;
m_get_position(i, x, y, z);
field_x += m_xfield_partparser(x, y, z, m_time);
field_y += m_yfield_partparser(x, y, z, m_time);
field_z += m_zfield_partparser(x, y, z, m_time);
}
else
{
amrex::Abort("ExternalFieldInitType not known!!! \n");
}
}
};
/** \brief Functor that can be used to assign the external
* E field to a particle inside a ParallelFor kernel
*/
struct GetExternalEField : GetExternalField
{
GetExternalEField () = default;
GetExternalEField (const WarpXParIter& a_pti, int a_offset = 0) noexcept;
};
/** \brief Functor that can be used to assign the external
* B field to a particle inside a ParallelFor kernel
*/
struct GetExternalBField : GetExternalField
{
GetExternalBField () = default;
GetExternalBField (const WarpXParIter& a_pti, int a_offset = 0) noexcept;
};
#endif
|