1 #ifndef AMREX_PARTICLEINTERPOLATORS_H_
2 #define AMREX_PARTICLEINTERPOLATORS_H_
3 #include <AMReX_Config.H>
17 template <
class Derived,
class WeightType>
62 template <
typename P,
typename V,
typename F>
66 int src_comp,
int dst_comp,
int num_comps, F
const&
f)
68 static constexpr
int stencil_width = Derived::stencil_width;
69 for (
int ic=0; ic < num_comps; ++ic) {
70 for (
int kk = 0; kk <= Derived::nz; ++kk) {
71 for (
int jj = 0; jj <= Derived::ny; ++jj) {
72 for (
int ii = 0; ii <= Derived::nx; ++ii) {
73 const auto pval =
f(p, src_comp+ic);
74 const auto val =
w[0*stencil_width+ii] *
75 w[1*stencil_width+jj] *
76 w[2*stencil_width+kk] * pval;
138 template <
typename P,
typename V,
typename F,
typename G>
142 int src_comp,
int dst_comp,
int num_comps, F
const&
f, G
const& g)
144 static constexpr
int stencil_width = Derived::stencil_width;
145 for (
int ic=0; ic < num_comps; ++ic) {
146 for (
int kk = 0; kk <= Derived::nz; ++kk) {
147 for (
int jj = 0; jj <= Derived::ny; ++jj) {
148 for (
int ii = 0; ii <= Derived::nx; ++ii) {
150 const auto val =
w[0*stencil_width+ii] *
151 w[1*stencil_width+jj] *
152 w[2*stencil_width+kk] * mval;
153 g(p, ic + dst_comp, val);
189 template <
typename P>
196 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
197 amrex::Real l = (p.pos(i) - plo[i]) * dxi[i] + 0.5;
198 index[i] =
static_cast<int>(amrex::Math::floor(l));
201 for (
int i = AMREX_SPACEDIM; i < 3; ++i) {
231 template <
typename P>
238 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
239 amrex::Real l = (p.pos(i) - plo[i]) * dxi[i] + 0.5;
240 index[i] =
static_cast<int>(amrex::Math::floor(l)) - 1;
241 amrex::Real lint = l - (
index[i] + 1);
245 for (
int i = AMREX_SPACEDIM; i < 3; ++i) {
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition: AMReX_GpuAtomic.H:281
Definition: AMReX_ParticleInterpolators.H:10
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
static constexpr int P
Definition: AMReX_OpenBC.H:14
Definition: AMReX_Array4.H:61
Definition: AMReX_Array.H:34
A base class for doing general particle/mesh interpolation operations.
Definition: AMReX_ParticleInterpolators.H:19
WeightType * w
Definition: AMReX_ParticleInterpolators.H:21
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void MeshToParticle(P &p, amrex::Array4< const V > const &arr, int src_comp, int dst_comp, int num_comps, F const &f, G const &g)
A general function for doing mesh-to-particle interpolation for one particle.
Definition: AMReX_ParticleInterpolators.H:140
int index[3]
Definition: AMReX_ParticleInterpolators.H:20
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void ParticleToMesh(const P &p, amrex::Array4< V > const &arr, int src_comp, int dst_comp, int num_comps, F const &f)
A general function for doing particle-to-mesh interpolation for one particle.
Definition: AMReX_ParticleInterpolators.H:64
A class the implements linear (CIC) particle/mesh interpolation.
Definition: AMReX_ParticleInterpolators.H:222
static constexpr int nx
Definition: AMReX_ParticleInterpolators.H:225
static constexpr int ny
Definition: AMReX_ParticleInterpolators.H:226
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Linear(const P &p, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi)
Definition: AMReX_ParticleInterpolators.H:233
static constexpr int stencil_width
Definition: AMReX_ParticleInterpolators.H:223
static constexpr int nz
Definition: AMReX_ParticleInterpolators.H:227
amrex::Real weights[3 *stencil_width]
Definition: AMReX_ParticleInterpolators.H:229
A class the implements nearest grid point particle/mesh interpolation.
Definition: AMReX_ParticleInterpolators.H:181
int weights[3 *stencil_width]
Definition: AMReX_ParticleInterpolators.H:183
static constexpr int nz
Definition: AMReX_ParticleInterpolators.H:187
static constexpr int ny
Definition: AMReX_ParticleInterpolators.H:186
static constexpr int nx
Definition: AMReX_ParticleInterpolators.H:185
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Nearest(const P &p, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi)
Definition: AMReX_ParticleInterpolators.H:191
static constexpr int stencil_width
Definition: AMReX_ParticleInterpolators.H:182