35#ifndef CLASSIC_COREFITSC_H
36#define CLASSIC_COREFITSC_H
97 virtual void sum(
double* values,
unsigned int count)
const = 0;
99 virtual void min(
double* values,
unsigned int count)
const = 0;
105 void sum(
double*,
unsigned int)
const override { }
106 void min(
double*,
unsigned int)
const override { }
112 void sum(
double* values,
unsigned int count)
const override;
113 void min(
double* values,
unsigned int count)
const override;
152 std::size_t localNum,
double nSigma,
double clip,
172 return (r[0] >= lower[0] && r[0] <= upper[0] &&
173 r[1] >= lower[1] && r[1] <= upper[1] &&
174 r[2] >= lower[2] && r[2] <= upper[2]);
199 return Vector_t({r[0] - r0[0], gamma * (r[1] - r0[1]), r[2] - r0[2]});
206 return Vector_t({gamma * E[0], E[1], gamma * E[2]});
246 std::size_t
begin, std::size_t
end,
bool withQuadrupole,
247 std::vector<Vector_t>& field, std::vector<double>& indicator);
264 const std::vector<Vector_t>& source,
const std::vector<double>& charge,
265 double eps, std::vector<Vector_t>& field);
269 std::pair<std::size_t, std::size_t>
getTableRange(std::size_t n,
int rank,
int numRanks);
275 std::size_t
getSampleStride(std::size_t numTargets, std::size_t numSources,
290 inline bool isSampled(std::size_t
id, std::size_t stride) {
294 std::uint64_t z =
id + 0x9E3779B97F4A7C15ULL;
295 z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ULL;
296 z = (z ^ (z >> 27)) * 0x94D049BB133111EBULL;
297 return (z ^ (z >> 31)) % stride == 0;
325 double farChargeFraction,
double maxFarFraction,
unsigned int minDwell);
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
constexpr double returnCoreFraction
CoreSelection selectCore(const Vector_t *R, const double *Q, const int *bin, std::size_t localNum, double nSigma, double clip, const Reducer &reducer)
constexpr double returnFarFactor
constexpr double coreShellFraction
bool isInside(const Vector_t &r, const Vector_t &lower, const Vector_t &upper)
True if r lies in [lower, upper] in every axis.
constexpr double maxFarFarPairs
constexpr double flatWidth
constexpr double indicatorThreshold
constexpr double maxCorePairsPerCore
constexpr double warnFarFraction
The solve warns when the far charge fraction exceeds this.
void addDirectField(const std::vector< Vector_t > &target, std::size_t begin, std::size_t end, const std::vector< Vector_t > &source, const std::vector< double > &charge, double eps, std::vector< Vector_t > &field)
ModeState decideMode(const ModeState &previous, std::size_t numCore, std::size_t numLive, double farChargeFraction, double maxFarFraction, unsigned int minDwell)
constexpr double haloSigma
The halo proper: live particles beyond haloSigma clipped rms widths in any axis.
ParticleClass classify(int bin, const Vector_t &r, const Vector_t &boundsMin, const Vector_t &boundsMax, const Vector_t &meshMin, const Vector_t &meshMax)
constexpr double minCoreFraction
void computeMultipoleField(const CoreMoments &moments, const std::vector< Vector_t > &position, std::size_t begin, std::size_t end, bool withQuadrupole, std::vector< Vector_t > &field, std::vector< double > &indicator)
std::pair< std::size_t, std::size_t > getTableRange(std::size_t n, int rank, int numRanks)
bool isInCoreShell(const Vector_t &r, const Vector_t &lower, const Vector_t &upper)
constexpr unsigned int maxClipPasses
constexpr double minCoreParticles
bool needsExactCoreField(ParticleClass c, double indicator)
void getMeshBox(const Vector_t *R, const int *bin, std::size_t localNum, const CoreSelection &selection, double nSigma, const Reducer &reducer, Vector_t &boxMin, Vector_t &boxMax)
@ FAR
outside that range: multipole (or exact core) field, plus far-far
@ INSIDE
lost (Bin < 0), inside the core bounds: gathered, not deposited
@ CORE
live, inside the core bounds: deposited, field gathered from the mesh
bool isSampled(std::size_t id, std::size_t stride)
std::size_t getSampleStride(std::size_t numTargets, std::size_t numSources, double maxPairs)
Vector_t toRestFrame(const Vector_t &r, const Vector_t &r0, double gamma)
constexpr double clipTolerance
The clipped passes stop when |dsigma_d| < clipTolerance * sigma_d in every axis.
Vector_t toLabFrame(const Vector_t &E, double gamma)
virtual ~Reducer()=default
virtual void sum(double *values, unsigned int count) const =0
Sums over all ranks.
virtual void min(double *values, unsigned int count) const =0
Minima over all ranks (maxima are the minima of the negated values)
All particles on one process: the reductions do nothing.
void min(double *, unsigned int) const override
Minima over all ranks (maxima are the minima of the negated values)
void sum(double *, unsigned int) const override
Sums over all ranks.
All IPPL nodes, through allreduce().
void sum(double *values, unsigned int count) const override
Sums over all ranks.
void min(double *values, unsigned int count) const override
Minima over all ranks (maxima are the minima of the negated values)
Result of selectCore(), the same on every rank.
unsigned int passes
clipped passes done, 0 to maxClipPasses
double getFarChargeFraction() const
Far charge over live charge, 0 without live charge.
bool converged
false if the passes stopped at maxClipPasses
std::size_t numLive
particles with Bin >= 0
double chargeFar
charge of the far live particles [C]
Vector_t boundsMin
minimum over the core particles [m]
Vector_t mean
clipped mean [m]
std::size_t numFar
the other live particles
Vector_t sigma
clipped rms [m]
std::size_t numHalo
live particles beyond haloSigma * sigma in any axis
double chargeLive
charge of the live particles [C]
std::size_t numCore
live particles within nSigma * sigma in every axis
Rest-frame moments of the core charge.
Vector_t centroid
c', rest frame, about the centre [m]
std::array< Vector_t, 3 > quadrupole
void add(double q, const Vector_t &r)
Adds a particle of charge q at r (local frame, not rest frame)
std::array< double, 10 > sums_m
CoreMoments reduce(const Reducer &reducer) const
Moments of all ranks' particles: one sum of 10 doubles.
Vektor< double, 3 > Vector_t