38 const amrex::ParticleReal yp,
39 const amrex::ParticleReal zp,
42 int& i,
int& j,
int& k, amrex::Real W[AMREX_SPACEDIM][2])
noexcept
44 using namespace amrex::literals;
46 constexpr auto half_if_cell_centered = [](){
55#if (defined WARPX_DIM_3D)
56 const amrex::Real x = (xp - plo[0]) * dxi[0] - half_if_cell_centered;
57 const amrex::Real y = (yp - plo[1]) * dxi[1] - half_if_cell_centered;
58 const amrex::Real z = (zp - plo[2]) * dxi[2] - half_if_cell_centered;
60 i =
static_cast<int>(amrex::Math::floor(x));
61 j =
static_cast<int>(amrex::Math::floor(y));
62 k =
static_cast<int>(amrex::Math::floor(z));
68 W[0][0] = 1.0_rt - W[0][1];
69 W[1][0] = 1.0_rt - W[1][1];
70 W[2][0] = 1.0_rt - W[2][1];
72#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
74# if (defined WARPX_DIM_XZ)
75 const amrex::Real x = (xp - plo[0]) * dxi[0] - half_if_cell_centered;
77 i =
static_cast<int>(amrex::Math::floor(x));
79# elif (defined WARPX_DIM_RZ)
80 const amrex::Real r = (std::sqrt(xp*xp+yp*yp) - plo[0]) * dxi[0] - half_if_cell_centered;
81 i =
static_cast<int>(amrex::Math::floor(r));
85 const amrex::Real z = (zp - plo[1]) * dxi[1] - half_if_cell_centered;
86 j =
static_cast<int>(amrex::Math::floor(z));
89 W[0][0] = 1.0_rt - W[0][1];
90 W[1][0] = 1.0_rt - W[1][1];
94#elif defined(WARPX_DIM_RCYLINDER)
97 const amrex::Real r = (std::sqrt(xp*xp+yp*yp) - plo[0]) * dxi[0] - half_if_cell_centered;
98 i =
static_cast<int>(amrex::Math::floor(r));
101 W[0][0] = 1.0_rt - W[0][1];
106#elif defined(WARPX_DIM_RSPHERE)
108 const amrex::Real r = (std::sqrt(xp*xp+yp*yp+zp*zp) - plo[0]) * dxi[0] - half_if_cell_centered;
109 i =
static_cast<int>(amrex::Math::floor(r));
112 W[0][0] = 1.0_rt - W[0][1];
117#elif (defined WARPX_DIM_1D_Z)
118 const amrex::Real z = (zp - plo[0]) * dxi[0] - half_if_cell_centered;
120 i =
static_cast<int>(amrex::Math::floor(z));
123 W[0][0] = 1.0_rt - W[0][1];
140 const amrex::Real W[AMREX_SPACEDIM][2],
143 amrex::Real value = 0;
144 if constexpr (DIMS == 3) {
145 value += scalar_field(i, j , k ) * W[0][0] * W[1][0] * W[2][0];
146 value += scalar_field(i+1, j , k ) * W[0][1] * W[1][0] * W[2][0];
147 value += scalar_field(i, j+1, k ) * W[0][0] * W[1][1] * W[2][0];
148 value += scalar_field(i+1, j+1, k ) * W[0][1] * W[1][1] * W[2][0];
149 value += scalar_field(i, j , k+1) * W[0][0] * W[1][0] * W[2][1];
150 value += scalar_field(i+1, j , k+1) * W[0][1] * W[1][0] * W[2][1];
151 value += scalar_field(i , j+1, k+1) * W[0][0] * W[1][1] * W[2][1];
152 value += scalar_field(i+1, j+1, k+1) * W[0][1] * W[1][1] * W[2][1];
153 }
else if constexpr (DIMS == 2) {
154 value += scalar_field(i, j , k) * W[0][0] * W[1][0];
155 value += scalar_field(i+1, j , k) * W[0][1] * W[1][0];
156 value += scalar_field(i, j+1, k) * W[0][0] * W[1][1];
157 value += scalar_field(i+1, j+1, k) * W[0][1] * W[1][1];
159 value += scalar_field(i, j , k) * W[0][0];
160 value += scalar_field(i+1, j , k) * W[0][1];
204 const amrex::ParticleReal yp,
205 const amrex::ParticleReal zp,
214 amrex::Real W[AMREX_SPACEDIM][2];
Definition DepositCharge.H:21
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::Real interp_field_nodal(int i, int j, int k, const amrex::Real W[3][2], amrex::Array4< const amrex::Real > const &scalar_field) noexcept
Interpolate nodal field value based on surrounding indices and weights.
Definition NodalFieldGather.H:139
AMREX_GPU_HOST_DEVICE AMREX_INLINE void compute_weights(const amrex::ParticleReal xp, const amrex::ParticleReal yp, const amrex::ParticleReal zp, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi, int &i, int &j, int &k, amrex::Real W[3][2]) noexcept
Compute weight of each surrounding node (or cell-centered nodes) in interpolating a nodal ((or a cell...
Definition NodalFieldGather.H:37
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::GpuArray< amrex::Real, 3 > doGatherVectorFieldNodal(const amrex::ParticleReal xp, const amrex::ParticleReal yp, const amrex::ParticleReal zp, amrex::Array4< const amrex::Real > const &vector_field_x, amrex::Array4< const amrex::Real > const &vector_field_y, amrex::Array4< const amrex::Real > const &vector_field_z, amrex::GpuArray< amrex::Real, 3 > const &dxi, amrex::GpuArray< amrex::Real, 3 > const &lo) noexcept
Vector field gather for a single particle. The field has to be defined at the cell nodes (see https:/...
Definition NodalFieldGather.H:203
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::Real doGatherScalarFieldNodal(const amrex::ParticleReal xp, const amrex::ParticleReal yp, const amrex::ParticleReal zp, amrex::Array4< const amrex::Real > const &scalar_field, amrex::GpuArray< amrex::Real, 3 > const &dxi, amrex::GpuArray< amrex::Real, 3 > const &lo) noexcept
Scalar field gather for a single particle. The field has to be defined at the cell nodes (see https:/...
Definition NodalFieldGather.H:176