8#ifndef WARPX_EXTERNAL_FIELD_H_
9#define WARPX_EXTERNAL_FIELD_H_
90#if defined(AMREX_USE_GPU)
96 const auto i1 =
static_cast<int>(std::floor( (pos[1]-
offset[1])/
dx[1] ));,
97 const auto i2 =
static_cast<int>(std::floor( (pos[2]-
offset[2])/
dx[2] )));
104#if (AMREX_SPACEDIM == 1)
106 if (i0 < table.begin || i0 >=
table.end-1)
116#elif (AMREX_SPACEDIM == 2)
118 if (i0 <
table.begin[0] || i0 >=
table.end[0]-1 ||
127 xx0, xx0+
dx[0], xx1, xx1+
dx[1],
135#elif (AMREX_SPACEDIM == 3)
137 if (i0 <
table.begin[0] || i0 >=
table.end[0]-1 ||
138 i1 <
table.begin[1] || i1 >=
table.end[1]-1 ||
148 xx0, xx0+
dx[0], xx1, xx1+
dx[1], xx2, xx2+
dx[2],
152 table(i0 ,i1+1,i2+1),
154 table(i0+1,i1 ,i2+1),
155 table(i0+1,i1+1,i2 ),
156 table(i0+1,i1+1,i2+1),
157 pos[0], pos[1], pos[2]));
164#if (AMREX_SPACEDIM == 1)
166#elif (AMREX_SPACEDIM == 2)
168#elif (AMREX_SPACEDIM == 3)
197 std::string F_name, std::string F_component,
#define AMREX_ALWAYS_ASSERT(EX)
#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:30
@ default_zero
Definition ExternalField.H:31
@ read_from_file
Definition ExternalField.H:34
@ constant
Definition ExternalField.H:32
@ parse_ext_grid_function
Definition ExternalField.H:33
@ load_from_python
Definition ExternalField.H:35
amrex::IntVect m_size
Definition ExternalField.H:257
std::string m_file
Definition ExternalField.H:247
amrex::GpuArray< amrex::Real, 3 > m_probdx
WarpX's initial prob lo.
Definition ExternalField.H:251
std::string m_name
OpenMPD file name.
Definition ExternalField.H:248
amrex::Box m_dombox
WarpX's cell size.
Definition ExternalField.H:252
void make_cache_box(amrex::RealBox const &pbox, int moving_dir, int moving_sign)
Definition ExternalField.cpp:494
bool m_distributed
WarpX's initial domain.
Definition ExternalField.H:253
bool m_moving_window
Is the data loaded distributedly?
Definition ExternalField.H:254
ExternalFieldReader(std::string read_fields_from_path, std::string F_name, std::string F_component, amrex::GpuArray< amrex::Real, 3 > const &problo, amrex::GpuArray< amrex::Real, 3 > const &pdx, amrex::Box const &dombox, bool distributed)
Constructor.
Definition ExternalField.cpp:193
bool distributed() const
Is the data loaded distributedly?
Definition ExternalField.H:235
ExternalFieldView make_view(amrex::BaseFab< double > const &fab) const
Used by getView to make ExternalFieldView.
Definition ExternalField.cpp:555
void load_data(amrex::RealBox const &pbox)
Read data within this box.
Definition ExternalField.cpp:208
void prepare(amrex::BoxArray const &grids, amrex::DistributionMapping const &dmap, amrex::IntVect const &ngrow, std::function< amrex::Real(amrex::Real)> const &get_zlab=nullptr)
This must be called before calling getView to prepare for loading distributed data....
Definition ExternalField.cpp:436
amrex::RealVect m_offset
Definition ExternalField.H:256
std::string m_component
Field name.
Definition ExternalField.H:249
amrex::BaseFab< double > m_fab
buffer in cpu memory for loading data
Definition ExternalField.H:261
amrex::RealVect m_dx
In moving window stage?
Definition ExternalField.H:255
amrex::RealBox m_domain
Definition ExternalField.H:258
std::shared_ptr< double > m_FC_data_cpu
Definition ExternalField.H:260
amrex::RealBox m_cache_domain
Definition ExternalField.H:259
amrex::FabArray< amrex::BaseFab< double > > m_mf
data container for loaded data
Definition ExternalField.H:262
amrex::GpuArray< amrex::Real, 3 > m_problo
Component name.
Definition ExternalField.H:250
ExternalFieldView getView() const
Return lightweight view that can be used in kernels.
Definition ExternalField.cpp:550
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
void Abort(const std::string &msg)
ExternalFieldType E_ext_grid_type
Initialization type for external electric field on the grid.
Definition ExternalField.H:59
std::unique_ptr< amrex::Parser > Eyfield_parser
User-defined parser to initialize y-component of the electric field on the grid.
Definition ExternalField.H:70
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:69
std::unique_ptr< amrex::Parser > Bzfield_parser
User-defined parser to initialize z-component of the magnetic field on the grid.
Definition ExternalField.H:66
std::unique_ptr< amrex::Parser > Bxfield_parser
User-defined parser to initialize x-component of the magnetic field on the grid.
Definition ExternalField.H:62
amrex::GpuArray< amrex::Real, 3 > E_external_grid
Initial electric field on the grid.
Definition ExternalField.H:52
ExternalFieldType B_ext_grid_type
Initialization type for external magnetic field on the grid.
Definition ExternalField.H:57
std::unique_ptr< amrex::Parser > Byfield_parser
User-defined parser to initialize y-component of the magnetic field on the grid.
Definition ExternalField.H:64
std::string external_fields_path
Path of the file where external fields are stored.
Definition ExternalField.H:75
std::unique_ptr< amrex::Parser > Ezfield_parser
User-defined parser to initialize z-component of the electric field on the grid.
Definition ExternalField.H:72
amrex::GpuArray< amrex::Real, 3 > B_external_grid
Initial magnetic field on the grid.
Definition ExternalField.H:54
std::unique_ptr< amrex::Parser > Exfield_parser
User-defined parser to initialize x-component of the electric field on the grid.
Definition ExternalField.H:68
Companion class for ExternalFieldReader.
Definition ExternalField.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real operator()(amrex::RealVect const &pos) const
Definition ExternalField.H:88
amrex::IntVect global_size
data
Definition ExternalField.H:171
amrex::RealVect dx
Definition ExternalField.H:162
amrex::Table3D< double > table
data's physical location at (0,0,0)
Definition ExternalField.H:169
amrex::RealVect offset
mesh spacing of the data
Definition ExternalField.H:163