chombo-discharge
Static Public Member Functions | List of all members
ParticleOps Class Reference

A shallow static class for doing various kinds of particle-related operations. More...

#include <CD_ParticleOps.H>

Static Public Member Functions

static IntVect getParticleCellIndex (const RealVect &a_particlePosition, const RealVect &a_probLo, const Real &a_dx) noexcept
 Get the cell index corresponding to the particle position. More...
 
static IntVect getParticleCellIndex (const RealVect &a_particlePosition, const RealVect &a_probLo, const RealVect &a_dx) noexcept
 Get the cell index corresponding to the particle position. More...
 
template<typename P , const Real &(P::*)() const weight>
static void getPhysicalParticlesPerCell (EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
 Get the number of physical particles per cell. More...
 
template<typename P >
static void getComputationalParticlesPerCell (EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
 Get the number of computational particles per cell. More...
 
static IntVect getParticleGridCell (const RealVect &a_particlePosition, const RealVect &a_probLo, const RealVect &a_dx) noexcept
 Get the grid cell where the particle lives. More...
 
static bool domainIntersection (const RealVect &a_oldPos, const RealVect &a_newPos, const RealVect &a_probLo, const RealVect &a_probHi, Real &a_s)
 Compute the intersection point between a particle path and a domain side. More...
 
static bool ebIntersectionBisect (const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_bisectStep, Real &a_s)
 Compute the intersection point between a particle path and an implicit function using a bisection algorithm. More...
 
static bool ebIntersectionRaycast (const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_tolerance, Real &a_s)
 Compute the intersection point between a particle path and an implicit function using a ray-casting algorithm. More...
 
template<typename P >
static void copy (ParticleContainer< P > &a_dst, const ParticleContainer< P > &a_src) noexcept
 Copy all the particles from the a_src to a_dst. More...
 
template<typename P >
static void copyDestructive (ParticleContainer< P > &a_dst, ParticleContainer< P > &a_src) noexcept
 Copy all the particles from the a_src to a_dst. This destroys the source particles. More...
 
template<typename P , const Real &(P::*)() const scalarQuantity>
static Real sum (const ParticleContainer< P > &a_particles) noexcept
 Perform a sum of some particle quantity. More...
 
template<typename P , Real(P::*)() scalarQuantity>
static Real sum (const ParticleContainer< P > &a_particles) noexcept
 Perform a sum of some particle quantity. More...
 
template<typename P >
static void removeParticles (ParticleContainer< P > &a_particles, const std::function< bool(const P &)> &a_removeCriterion) noexcept
 Remove particles if they fulfill certain removal criterion. More...
 
template<typename P >
static void transferParticles (ParticleContainer< P > &a_dstParticles, ParticleContainer< P > &a_srcParticles, const std::function< bool(const P &)> &a_transferCrit) noexcept
 Transfer particles if they fulfill a certain removal criterion. Takes particles from a_srcParticles and puts them in a_dstParticles. More...
 
template<typename P >
static void setData (ParticleContainer< P > &a_particles, const std::function< void(P &)> &a_functor) noexcept
 Set value function. Lets the user set particle parameters. More...
 
template<typename P , Real &(P::*)() particleScalarField>
static void setValue (ParticleContainer< P > &a_particles, const Real a_value) noexcept
 Set value function. Lets the user set scalar particle quantity. Use with e.g. setValue<P, &P::weight>(particles, 0.0) etc. More...
 
template<typename P , RealVect &(P::*)() particleVectorField>
static void setValue (ParticleContainer< P > &a_particles, const RealVect a_value) noexcept
 Set value function. Lets the user set scalar particle quantity. Use with e.g. setValue<P, &P::velocity>(particles, RealVect::Unit) etc. More...
 

Detailed Description

A shallow static class for doing various kinds of particle-related operations.

Member Function Documentation

◆ copy()

template<typename P >
void ParticleOps::copy ( ParticleContainer< P > &  a_dst,
const ParticleContainer< P > &  a_src 
)
inlinestaticnoexcept

Copy all the particles from the a_src to a_dst.

Parameters
[out]a_dstCopy of original particles.
[out]a_srcSource particles

◆ copyDestructive()

template<typename P >
void ParticleOps::copyDestructive ( ParticleContainer< P > &  a_dst,
ParticleContainer< P > &  a_src 
)
inlinestaticnoexcept

Copy all the particles from the a_src to a_dst. This destroys the source particles.

Parameters
[out]a_dstCopy of original particles.
[out]a_srcSource particles

◆ domainIntersection()

bool ParticleOps::domainIntersection ( const RealVect &  a_oldPos,
const RealVect &  a_newPos,
const RealVect &  a_probLo,
const RealVect &  a_probHi,
Real &  a_s 
)
inlinestatic

Compute the intersection point between a particle path and a domain side.

If the particle crossed the domain side, the output argument a_s determines the intersection point by x(s) = x0 + s*(x1-x0) where x0 is the starting position (a_oldPos), x1 is the end position (a_newPos), and x(s) is the intersection point with the boundary.

Parameters
[in]a_oldPosParticle starting position
[in]a_newPosParticle end position
[in]a_probLoLower-left corner in physical coordinates
[in]a_probHiUpper-right corner in physical coordinates
[out]a_sRelative length along the path
Returns
Returns true if the particle crossed the domain boundary.

◆ ebIntersectionBisect()

bool ParticleOps::ebIntersectionBisect ( const RefCountedPtr< BaseIF > &  a_impFunc,
const RealVect &  a_oldPos,
const RealVect &  a_newPos,
const Real &  a_bisectStep,
Real &  a_s 
)
inlinestatic

Compute the intersection point between a particle path and an implicit function using a bisection algorithm.

This routine will bisect the particle path into intervals of length a_bisectStep. Each interval is examined for a crossing with the implicit function and if the particle crossed the into the EB, the output argument a_s determines the intersection point by x(s) = x0 + s*(x1-x0) where x0 is the starting position (a_oldPos), x1 is the end position (a_newPos), and x(s) is the intersection point with the geometry.

Parameters
[in]a_impFuncImplicit function.
[in]a_oldPosParticle starting position
[in]a_newPosParticle end position
[in]a_bisectStepBisection step length
[out]a_sRelative length along the path
Returns
Returns true if the particle crossed into the EB.

◆ ebIntersectionRaycast()

bool ParticleOps::ebIntersectionRaycast ( const RefCountedPtr< BaseIF > &  a_impFunc,
const RealVect &  a_oldPos,
const RealVect &  a_newPos,
const Real &  a_tolerance,
Real &  a_s 
)
inlinestatic

Compute the intersection point between a particle path and an implicit function using a ray-casting algorithm.

This routine will assume that a_impcFunc is an approximation to the signed distance function and compute the intersection point using ray-marching. Starting on the starting position we compute the distance to the EB and move the particle the compute distance along the particle trajectory. If the particle comes too close to the EB (within a_tolerance) we consider it to be absorbed. In that case the output argument a_s determines the intersection point by x(s) = x0 + s*(x1-x0) where x0 is the starting position (a_oldPos), x1 is the end position (a_newPos), and x(s) is the intersection point with the geometry.

Parameters
[in]a_impFuncImplicit function.
[in]a_oldPosParticle starting position
[in]a_newPosParticle end position
[in]a_toleraceTolerance for intersectinon method. If the distance to the EB is less than this, the particle is absorbed.
[out]a_sRelative length along the path
Returns
Returns true if the particle crossed into the EB.

◆ getComputationalParticlesPerCell()

template<typename P >
void ParticleOps::getComputationalParticlesPerCell ( EBAMRCellData a_ppc,
const ParticleContainer< P > &  a_src 
)
inlinestaticnoexcept

Get the number of computational particles per cell.

Parameters
[out]a_ppcPhysical particles per cell
[in]a_srcParticle source container.

◆ getParticleCellIndex() [1/2]

IntVect ParticleOps::getParticleCellIndex ( const RealVect &  a_particlePosition,
const RealVect &  a_probLo,
const Real &  a_dx 
)
inlinestaticnoexcept

Get the cell index corresponding to the particle position.

Parameters
[in]a_particlePositionParticle position
[in]a_probLoLower-left corner of computational domain
[in]a_dxGrid resolution

◆ getParticleCellIndex() [2/2]

IntVect ParticleOps::getParticleCellIndex ( const RealVect &  a_particlePosition,
const RealVect &  a_probLo,
const RealVect &  a_dx 
)
inlinestaticnoexcept

Get the cell index corresponding to the particle position.

Parameters
[in]a_particlePositionParticle position
[in]a_probLoLower-left corner of computational domain
[in]a_dxGrid resolution

◆ getParticleGridCell()

IntVect ParticleOps::getParticleGridCell ( const RealVect &  a_particlePosition,
const RealVect &  a_probLo,
const RealVect &  a_dx 
)
inlinestaticnoexcept

Get the grid cell where the particle lives.

Parameters
[in]a_particlePositionPhysical particle position
[in]a_probLoLower-left physical corner of simulation domain
[in]a_dxGrid resolution.

◆ getPhysicalParticlesPerCell()

template<typename P , const Real &(P::*)() const weight>
void ParticleOps::getPhysicalParticlesPerCell ( EBAMRCellData a_ppc,
const ParticleContainer< P > &  a_src 
)
inlinestaticnoexcept

Get the number of physical particles per cell.

Parameters
[out]a_ppcPhysical particles per cell
[in]a_srcParticle source container.

The second template parameter is a pointer to a member function in P that provides the number of physical particles for the computational particles. If P has a function const Real& P::weight() const, we can call this as

ParticleOps::getPhysicalParticlesPerCell<P, &P::weight>(...)

◆ removeParticles()

template<typename P >
void ParticleOps::removeParticles ( ParticleContainer< P > &  a_particles,
const std::function< bool(const P &)> &  a_removeCriterion 
)
inlinestaticnoexcept

Remove particles if they fulfill certain removal criterion.

Parameters
[in,out]a_particlesParticles
[in]a_removeCriterionRemoval criterion.

◆ setData()

template<typename P >
void ParticleOps::setData ( ParticleContainer< P > &  a_particles,
const std::function< void(P &)> &  a_functor 
)
inlinestaticnoexcept

Set value function. Lets the user set particle parameters.

Parameters
[in,out]a_particlesParticles
[in]a_functorLambda for setting particle values

◆ setValue() [1/2]

template<typename P , Real &(P::*)() particleScalarField>
void ParticleOps::setValue ( ParticleContainer< P > &  a_particles,
const Real  a_value 
)
inlinestaticnoexcept

Set value function. Lets the user set scalar particle quantity. Use with e.g. setValue<P, &P::weight>(particles, 0.0) etc.

Parameters
[in,out]a_particlesParticles
[in]a_valueValue to set

◆ setValue() [2/2]

template<typename P , RealVect &(P::*)() particleVectorField>
void ParticleOps::setValue ( ParticleContainer< P > &  a_particles,
const RealVect  a_value 
)
inlinestaticnoexcept

Set value function. Lets the user set scalar particle quantity. Use with e.g. setValue<P, &P::velocity>(particles, RealVect::Unit) etc.

Parameters
[in,out]a_particlesParticles
[in]a_valueValue to set

◆ sum() [1/2]

template<typename P , Real(P::*)() scalarQuantity>
Real ParticleOps::sum ( const ParticleContainer< P > &  a_particles)
inlinestaticnoexcept

Perform a sum of some particle quantity.

Parameters
[in]a_particlesParticles

◆ sum() [2/2]

template<typename P , Real(P::*)() scalarQuantity>
static Real ParticleOps::sum ( const ParticleContainer< P > &  a_particles)
inlinestaticnoexcept

Perform a sum of some particle quantity.

Parameters
[in]a_particlesParticles
Note
Just like the other version, except that this one doesn't take a member function.

◆ transferParticles()

template<typename P >
void ParticleOps::transferParticles ( ParticleContainer< P > &  a_dstParticles,
ParticleContainer< P > &  a_srcParticles,
const std::function< bool(const P &)> &  a_transferCrit 
)
inlinestaticnoexcept

Transfer particles if they fulfill a certain removal criterion. Takes particles from a_srcParticles and puts them in a_dstParticles.

Parameters
[in,out]a_dstParticlesDestination particle data holder
[in,out]a_srcParticlesSource particle data holder
[in]a_removeCriterionRemoval criterion.

The documentation for this class was generated from the following files: