8#ifndef WARPX_EXTERNAL_FIELD_H_
9#define WARPX_EXTERNAL_FIELD_H_
79#if defined(AMREX_USE_GPU)
85 int const i1 = std::floor( (pos[1]-
offset[1])/
dx[1] );,
86 int const i2 = std::floor( (pos[2]-
offset[2])/
dx[2] ));
90 amrex::Real
const xx1 =
offset[1] + i1 *
dx[1];,
91 amrex::Real
const xx2 =
offset[2] + i2 *
dx[2]);
93#if (AMREX_SPACEDIM == 1)
95 if (i0 < table.begin || i0 >=
table.end-1) {
98 return static_cast<amrex::Real
>(
103#elif (AMREX_SPACEDIM == 2)
105 if (i0 <
table.begin[0] || i0 >=
table.end[0]-1 ||
106 i1 <
table.begin[1] || i1 >=
table.end[1]-1) {
109 return static_cast<amrex::Real
>(
111 xx0, xx0+
dx[0], xx1, xx1+
dx[1],
119#elif (AMREX_SPACEDIM == 3)
121 if (i0 <
table.begin[0] || i0 >=
table.end[0]-1 ||
122 i1 <
table.begin[1] || i1 >=
table.end[1]-1 ||
123 i2 <
table.begin[2] || i2 >=
table.end[2]-1) {
126 return static_cast<amrex::Real
>(
128 xx0, xx0+
dx[0], xx1, xx1+
dx[1], xx2, xx2+
dx[2],
132 table(i0 ,i1+1,i2+1),
134 table(i0+1,i1 ,i2+1),
135 table(i0+1,i1+1,i2 ),
136 table(i0+1,i1+1,i2+1),
137 pos[0], pos[1], pos[2]));
144#if (AMREX_SPACEDIM == 1)
146#elif (AMREX_SPACEDIM == 2)
148#elif (AMREX_SPACEDIM == 3)
157 std::string
const& F_name, std::string
const& F_component);
#define AMREX_FORCE_INLINE
#define AMREX_IF_ON_HOST(CODE)
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_TERM(a, b, c)
ExternalFieldType
Definition ExternalField.H:26
@ default_zero
Definition ExternalField.H:27
@ read_from_file
Definition ExternalField.H:30
@ constant
Definition ExternalField.H:28
@ parse_ext_grid_function
Definition ExternalField.H:29
@ load_from_python
Definition ExternalField.H:31
ExternalFieldReader(std::string const &read_fields_from_path, std::string const &F_name, std::string const &F_component)
Definition ExternalField.cpp:192
ExternalFieldView const & getView() const
Definition ExternalField.H:159
ExternalFieldView m_external_field_view
Definition ExternalField.H:164
std::shared_ptr< double > m_FC_data_cpu
Definition ExternalField.H:162
amrex::Gpu::DeviceVector< double > m_FC_data_gpu
Definition ExternalField.H:163
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto linear_interp(TCoord x0, TCoord x1, TVal f0, TVal f1, TCoord x)
Performs a linear interpolation.
Definition LinearInterpolation.H:23
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto bilinear_interp(TCoord x0, TCoord x1, TCoord y0, TCoord y1, TVal f00, TVal f01, TVal f10, TVal f11, TCoord x, TCoord y)
Performs a bilinear interpolation.
Definition LinearInterpolation.H:38
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto trilinear_interp(TCoord x0, TCoord x1, TCoord y0, TCoord y1, TCoord z0, TCoord z1, TVal f000, TVal f001, TVal f010, TVal f011, TVal f100, TVal f101, TVal f110, TVal f111, TCoord x, TCoord y, TCoord z)
Performs a trilinear interpolation.
Definition LinearInterpolation.H:56
PODVector< T, ArenaAllocator< T > > DeviceVector
void Abort(const std::string &msg)
ExternalFieldType E_ext_grid_type
Initialization type for external electric field on the grid.
Definition ExternalField.H:55
std::unique_ptr< amrex::Parser > Eyfield_parser
User-defined parser to initialize y-component of the electric field on the grid.
Definition ExternalField.H:66
ExternalFieldParams(const amrex::ParmParse &pp_warpx)
The constructor reads and stores the parameters related to the external fields. "pp_warpx" must point...
Definition ExternalField.cpp:68
std::unique_ptr< amrex::Parser > Bzfield_parser
User-defined parser to initialize z-component of the magnetic field on the grid.
Definition ExternalField.H:62
std::unique_ptr< amrex::Parser > Bxfield_parser
User-defined parser to initialize x-component of the magnetic field on the grid.
Definition ExternalField.H:58
amrex::GpuArray< amrex::Real, 3 > E_external_grid
Initial electric field on the grid.
Definition ExternalField.H:48
ExternalFieldType B_ext_grid_type
Initialization type for external magnetic field on the grid.
Definition ExternalField.H:53
std::unique_ptr< amrex::Parser > Byfield_parser
User-defined parser to initialize y-component of the magnetic field on the grid.
Definition ExternalField.H:60
std::string external_fields_path
Path of the file where external fields are stored.
Definition ExternalField.H:71
std::unique_ptr< amrex::Parser > Ezfield_parser
User-defined parser to initialize z-component of the electric field on the grid.
Definition ExternalField.H:68
amrex::GpuArray< amrex::Real, 3 > B_external_grid
Initial magnetic field on the grid.
Definition ExternalField.H:50
std::unique_ptr< amrex::Parser > Exfield_parser
User-defined parser to initialize x-component of the electric field on the grid.
Definition ExternalField.H:64
Definition ExternalField.H:75
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real operator()(amrex::RealVect const &pos) const
Definition ExternalField.H:77
amrex::Table3D< double, amrex::Order::C > table
Definition ExternalField.H:149
amrex::RealVect dx
Definition ExternalField.H:142
amrex::RealVect offset
Definition ExternalField.H:143