WarpX
GetExternalFields.H
Go to the documentation of this file.
1 #ifndef WARPX_PARTICLES_GATHER_GETEXTERNALFIELDS_H_
2 #define WARPX_PARTICLES_GATHER_GETEXTERNALFIELDS_H_
3 
6 
7 #include <AMReX_REAL.H>
8 
9 #include <limits>
10 
12 
17 {
19 
20  amrex::GpuArray<amrex::ParticleReal, 3> m_field_value;
21 
26  amrex::Real m_time;
27 
28  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
29  void operator () (long i,
30  amrex::ParticleReal& field_x,
31  amrex::ParticleReal& field_y,
32  amrex::ParticleReal& field_z) const noexcept
33  {
34  if (m_type == Constant)
35  {
36  field_x += m_field_value[0];
37  field_y += m_field_value[1];
38  field_z += m_field_value[2];
39  }
40  else if (m_type == Parser)
41  {
42  amrex::ParticleReal x, y, z;
43  m_get_position(i, x, y, z);
44  field_x += m_xfield_partparser(x, y, z, m_time);
45  field_y += m_yfield_partparser(x, y, z, m_time);
46  field_z += m_zfield_partparser(x, y, z, m_time);
47  }
48  else
49  {
50  amrex::Abort("ExternalFieldInitType not known!!! \n");
51  }
52  }
53 };
54 
59 {
60  GetExternalEField () = default;
61 
62  GetExternalEField (const WarpXParIter& a_pti, int a_offset = 0) noexcept;
63 };
64 
69 {
70  GetExternalBField () = default;
71 
72  GetExternalBField (const WarpXParIter& a_pti, int a_offset = 0) noexcept;
73 };
74 
75 #endif
Definition: GetExternalFields.H:11
def x
Definition: read_lab_particles.py:25
Base class for functors that assign external field values (E or B) to particles.
Definition: GetExternalFields.H:16
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
Definition: GetExternalFields.H:29
ExternalFieldInitType
Definition: GetExternalFields.H:11
def z
Definition: read_lab_particles.py:26
Functor that can be used to assign the external B field to a particle inside a ParallelFor kernel...
Definition: GetExternalFields.H:68
HostDeviceParser< 4 > m_yfield_partparser
Definition: GetExternalFields.H:23
ExternalFieldInitType m_type
Definition: GetExternalFields.H:18
amrex::Real m_time
Definition: GetExternalFields.H:26
amrex::GpuArray< amrex::ParticleReal, 3 > m_field_value
Definition: GetExternalFields.H:20
i
Definition: check_interp_points_and_weights.py:171
HostDeviceParser< 4 > m_zfield_partparser
Definition: GetExternalFields.H:24
GetParticlePosition m_get_position
Definition: GetExternalFields.H:25
HostDeviceParser< 4 > m_xfield_partparser
Definition: GetExternalFields.H:22
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:25
Definition: WarpXParticleContainer.H:76
Functor that can be used to assign the external E field to a particle inside a ParallelFor kernel...
Definition: GetExternalFields.H:58
Definition: GetExternalFields.H:11