13#ifndef CD_PARTICLEOPSIMPLEM_H
14#define CD_PARTICLEOPSIMPLEM_H
28#include <CD_NamespaceHeader.H>
50template <
typename P, const Real& (P::*weight)() const>
54 CH_TIME(
"ParticleOps::getPhysicalParticlesPerCell");
65#pragma omp parallel for schedule(runtime)
77 const Real w = (p.*weight)();
90 CH_TIME(
"ParticleOps::getComputationalParticlesPerCell");
101#pragma omp parallel for schedule(runtime)
142 a_s = std::numeric_limits<Real>::max();
164 if (
s >= 0.0 &&
s <= 1.0) {
188 a_s = std::numeric_limits<Real>::max();
203 if (
fa *
fb <= 0.0) {
229 a_s = std::numeric_limits<Real>::max();
275 CH_TIME(
"ParticleOps::copy(ParticleContainer<P> x2)");
285#pragma omp parallel for schedule(runtime)
298 CH_TIME(
"ParticleOps::copyDestructive(ParticleContainer<P> x2)");
308#pragma omp parallel for schedule(runtime)
319template <
typename P, const Real& (P::*scalarQuantity)() const>
323 CH_TIME(
"ParticleOps::sum(ParticleContainer<P>)");
333#pragma omp parallel for schedule(runtime) reduction(+ : particleSum)
348template <
typename P, Real (P::*scalarQuantity)()>
352 CH_TIME(
"ParticleOps::sum(ParticleContainer<P>)");
362#pragma omp parallel for schedule(runtime) reduction(+ : particleSum)
382 CH_TIME(
"ParticleOps::removeParticles(ParticleContainer<P>, std::function<bool(const P&)>)");
390#pragma omp parallel for schedule(runtime)
414 CH_TIME(
"ParticleOps::transferParticles(ParticleContainer<P>, ParticleContainer<P>& std::function<bool(const P&)>)");
425#pragma omp parallel for schedule(runtime)
448 CH_TIME(
"ParticleOps::setData(ParticleContainer<P>, std::function<void(P&)>)");
456#pragma omp parallel for schedule(runtime)
469template <
typename P, Real& (P::*particleScalarField)()>
473 CH_TIME(
"ParticleOps::setValue(ParticleContainer<P>, Real");
481#pragma omp parallel for schedule(runtime)
496template <
typename P, RealVect& (P::*particleVectorField)()>
500 CH_TIME(
"ParticleOps::setValue(ParticleContainer<P>, RealVect");
508#pragma omp parallel for schedule(runtime)
529 CH_TIME(
"ParticleOps::scatterParticles");
562 MayDay::Error(
"ParticleOps::scatterParticles - MPI communication error in MPI_AlltoAll(1)");
567 MayDay::Error(
"ParticleOps::scatterParticles - 'recvSizes[procID()] != 0' failed");
574 for (
size_t i = 1;
i <
counts.size();
i++) {
608 *((
size_t*)
data) =
cur.second.length();
615 p.linearOut((
void*)
data);
625 for (
size_t i = 0;
i <
v64.size(); ++
i) {
628 v[
i] =
static_cast<int>(
v64[
i]);
650 MayDay::Error(
"ParticleOps::scatterParticles - MPI communication error in MPI_AlltoAll(2)");
684 p.linearIn(
static_cast<void*
>(
data));
697#include <CD_NamespaceFooter.H>
Agglomeration of basic MPI reductions.
std::unordered_map< std::pair< uint32_t, uint32_t >, T, PairHash > ParticleMap
Underlying particle map when gathering/scattering particles.
Definition CD_ParticleMap.H:75
Declaration of a static class containing some common useful particle routines that would otherwise be...
Agglomeration of some useful algebraic/polynomial routines.
File containing some useful static methods related to random number generation.
static void copy(ParticleContainer< P > &a_dst, const ParticleContainer< P > &a_src) noexcept
Copy all the particles from the a_src to a_dst.
Definition CD_ParticleOpsImplem.H:273
static Real sum(const ParticleContainer< P > &a_particles) noexcept
Perform a sum of some particle quantity.
Definition CD_ParticleOpsImplem.H:321
static void getComputationalParticlesPerCell(EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
Get the number of computational particles per cell.
Definition CD_ParticleOpsImplem.H:88
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 a...
Definition CD_ParticleOpsImplem.H:410
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 a...
Definition CD_ParticleOpsImplem.H:222
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 alg...
Definition CD_ParticleOpsImplem.H:178
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,...
Definition CD_ParticleOpsImplem.H:471
static void removeParticles(ParticleContainer< P > &a_particles, const std::function< bool(const P &)> &a_removeCriterion) noexcept
Remove particles if they fulfill certain removal criterion.
Definition CD_ParticleOpsImplem.H:379
static void getPhysicalParticlesPerCell(EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
Get the number of physical particles per cell.
Definition CD_ParticleOpsImplem.H:52
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.
Definition CD_ParticleOpsImplem.H:296
static IntVect getParticleGridCell(const RealVect &a_particlePosition, const RealVect &a_probLo, const RealVect &a_dx) noexcept
Get the grid cell where the particle lives.
Definition CD_ParticleOpsImplem.H:122
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.
Definition CD_ParticleOpsImplem.H:31
static void setData(ParticleContainer< P > &a_particles, const std::function< void(P &)> &a_functor) noexcept
Set value function. Lets the user set particle parameters.
Definition CD_ParticleOpsImplem.H:446
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.
Definition CD_ParticleOpsImplem.H:132
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26
Real sum(const Real &a_value) noexcept
Compute the sum across all MPI ranks.
Definition CD_ParallelOpsImplem.H:354
RealVect brentRootFinder(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_point1, const RealVect &a_point2)
Compute the root of a function between two points. This is a 1D problem along the line.
Definition CD_PolyUtils.cpp:25