Block-Structured AMR Software Framework
amrex::ParticleInterpolator::Base< Derived, WeightType > Struct Template Reference

A base class for doing general particle/mesh interpolation operations. More...

#include <AMReX_ParticleInterpolators.H>

Public Member Functions

template<typename P , typename V , typename F >
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. More...
 
template<typename P , typename V , typename F , typename G >
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. More...
 

Public Attributes

int index [3]
 
WeightType * w
 

Detailed Description

template<class Derived, class WeightType>
struct amrex::ParticleInterpolator::Base< Derived, WeightType >

A base class for doing general particle/mesh interpolation operations.

Note that you don't call the base class version of this directly, you use one of the derived versions below that implement specific interpolations.

Member Function Documentation

◆ MeshToParticle()

template<class Derived , class WeightType >
template<typename P , typename V , typename F , typename G >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void amrex::ParticleInterpolator::Base< Derived, WeightType >::MeshToParticle ( P &  p,
amrex::Array4< const V > const &  arr,
int  src_comp,
int  dst_comp,
int  num_comps,
F const &  f,
G const &  g 
)
inline

A general function for doing mesh-to-particle interpolation for one particle.

Note that you don't call the base class version of this, you call one of the derived versions below that implement specific interpolations.

Template Parameters
Pthe particle type
Vthe mesh data type (i.e. float, double, int)
Fcallable that generates the mesh quantity to interpolate
Gcallable that updates the particle given the mesh value
Parameters
pthe particle to interpolate
arrthe Array4 to interpolate to
src_compthe particle component to start at
dst_compthe mesh component to start at
num_compsthe number of components to interpolate
ffunction for computing the particle quantity to interpolate
Template Parameters
gfunction that updates the particle given the mesh value

Usage:

Interpolate mesh comps 0-2 to particle comps 4-6 with no weighting using addition:

interp.MeshToParticle(p, acc, 0, 4, 3,
int i, int j, int k, int comp)
{
return arr(i, j, k, comp); // no weighting
},
[=] AMREX_GPU_DEVICE (MyParticleContainer::ParticleType& part,
int comp, amrex::Real val)
{
part.rdata(comp) += val;
});
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
Definition: AMReX_Array4.H:61

Usage:

Interpolate mesh comp 0 to particle comp 0, simply setting the value for the result instead of adding:

interp.MeshToParticle(p, count, 0, 0, 1,
int i, int j, int k, int comp)
{
return arr(i, j, k, comp); // no weighting
},
[=] AMREX_GPU_DEVICE (MyParticleContainer::ParticleType& part,
int comp, int val)
{
part.idata(comp) = val;
});

◆ ParticleToMesh()

template<class Derived , class WeightType >
template<typename P , typename V , typename F >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void amrex::ParticleInterpolator::Base< Derived, WeightType >::ParticleToMesh ( const P &  p,
amrex::Array4< V > const &  arr,
int  src_comp,
int  dst_comp,
int  num_comps,
F const &  f 
)
inline

A general function for doing particle-to-mesh interpolation for one particle.

Note that you don't call the base class version of this, you call one of the derived versions below that implement specific interpolations.

Template Parameters
Pthe particle type
Vthe mesh data type (i.e. float, double, int)
Fcallable that generates the particle quantity to interpolate
Parameters
pthe particle to interpolate
arrthe Array4 to interpolate to
src_compthe particle component to start at
dst_compthe mesh component to start at
num_compsthe number of components to interpolate
ffunction for computing the particle quantity to interpolate

Usage:

Interpolate particle comp 0 to mesh comp 0 with no weighting:

interp.ParticleToMesh(p, rho, 0, 0, 1,
[=] AMREX_GPU_DEVICE (const MyPC::ParticleType& part, int comp)
{
return part.rdata(comp); // no weighting
});

Usage:

Interpolate 3 particle components 1-3 to mesh components 1-3, weighting by particle comp 0:

interp.ParticleToMesh(p, rho, 1, 1, 3,
[=] AMREX_GPU_DEVICE (const MyPC::ParticleType& part, int comp)
{
return part.rdata(0)*part.rdata(comp); // weight by comp0
});

Member Data Documentation

◆ index

template<class Derived , class WeightType >
int amrex::ParticleInterpolator::Base< Derived, WeightType >::index[3]

◆ w

template<class Derived , class WeightType >
WeightType* amrex::ParticleInterpolator::Base< Derived, WeightType >::w

The documentation for this struct was generated from the following file: