1#ifndef AMREX_PARTICLEINTERPOLATORS_H_
2#define AMREX_PARTICLEINTERPOLATORS_H_
3#include <AMReX_Config.H>
17template <
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;
139 template <
typename P,
typename V,
typename F,
typename G>
143 int src_comp,
int dst_comp,
int num_comps,
F const& f, G
const& g)
145 static constexpr int stencil_width = Derived::stencil_width;
146 for (
int ic=0; ic < num_comps; ++ic) {
147 for (
int kk = 0; kk <= Derived::nz; ++kk) {
148 for (
int jj = 0; jj <= Derived::ny; ++jj) {
149 for (
int ii = 0; ii <= Derived::nx; ++ii) {
150 const auto mval = f(arr,
index[0]+ii,
index[1]+jj,
index[2]+kk,src_comp+ic);
151 const auto val =
w[0*stencil_width+ii] *
152 w[1*stencil_width+jj] *
153 w[2*stencil_width+kk] * mval;
154 g(p, ic + dst_comp, val);
190 template <
typename P>
199 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
200 WT l = (p.pos(i) - plo[i]) * dxi[i] + WT(0.5);
201 index[i] =
static_cast<int>(amrex::Math::floor(l));
204 for (
int i = AMREX_SPACEDIM; i < 3; ++i) {
234 template <
typename P>
243 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
244 WT l = (p.pos(i) - plo[i]) * dxi[i] + WT(0.5);
245 index[i] =
static_cast<int>(amrex::Math::floor(l)) - 1;
246 WT lint = l -
static_cast<WT
>(
index[i] + 1);
250 for (
int i = AMREX_SPACEDIM; i < 3; ++i) {
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
Convenience header for the core AMReX GPU facilities.
std::common_type_t< Real, ParticleReal > ParticleMeshReal
Floating Point Type for Particle-Mesh Operations.
Definition AMReX_REAL.H:102
__host__ __device__ AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition AMReX_GpuAtomic.H:283
Definition AMReX_ParticleInterpolators.H:10
A multidimensional array accessor.
Definition AMReX_Array4.H:289
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52
A base class for doing general particle/mesh interpolation operations.
Definition AMReX_ParticleInterpolators.H:19
__device__ 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
WeightType * w
Definition AMReX_ParticleInterpolators.H:21
int index[3]
Definition AMReX_ParticleInterpolators.H:20
__device__ 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:141
A class the implements linear (CIC) particle/mesh interpolation.
Definition AMReX_ParticleInterpolators.H:225
static constexpr int nx
Definition AMReX_ParticleInterpolators.H:228
static constexpr int ny
Definition AMReX_ParticleInterpolators.H:229
static constexpr int stencil_width
Definition AMReX_ParticleInterpolators.H:226
__device__ Linear(const P &p, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi)
Definition AMReX_ParticleInterpolators.H:236
amrex::ParticleMeshReal weights[3 *stencil_width]
Definition AMReX_ParticleInterpolators.H:232
static constexpr int nz
Definition AMReX_ParticleInterpolators.H:230
A class the implements nearest grid point particle/mesh interpolation.
Definition AMReX_ParticleInterpolators.H:182
__device__ Nearest(const P &p, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi)
Definition AMReX_ParticleInterpolators.H:192
int weights[3 *stencil_width]
Definition AMReX_ParticleInterpolators.H:184
static constexpr int nz
Definition AMReX_ParticleInterpolators.H:188
static constexpr int ny
Definition AMReX_ParticleInterpolators.H:187
static constexpr int nx
Definition AMReX_ParticleInterpolators.H:186
static constexpr int stencil_width
Definition AMReX_ParticleInterpolators.H:183