1#ifndef FOFBINNING_HEADER
2#define FOFBINNING_HEADER
29 template <
class T,
int NDIM>
39 std::array<double, NDIM>
pos{};
41 std::array<double, NDIM>
vel{};
60#ifdef STORE_MEMBERS_PTRS
74 static_assert(FML::PARTICLE::has_get_pos<T>());
78 assert_mpi(_mass > 0.0,
"FoFBinning::add::Particle mass is negative or zero, this is not normal!");
80#ifdef STORE_MEMBERS_PTRS
87 for (
int idim = 0; idim <
NDIM; idim++) {
96 std::array<double, NDIM> dx;
97 double weight = _mass / (
mass + _mass);
98 for (
int idim = 0; idim <
NDIM; idim++) {
99 dx[idim] = _pos[idim] -
pos[idim];
106 pos[idim] += dx[idim] * weight;
110 if (
pos[idim] >= 1.0)
116 if constexpr (FML::PARTICLE::has_get_vel<T>()) {
118 for (
int idim = 0; idim <
NDIM; idim++) {
119 vel[idim] =
vel[idim] * (1 - weight) + _vel[idim] * weight;
120 vel_rms[idim] =
vel_rms[idim] * (1 - weight) + _vel[idim] * _vel[idim] * weight;
136 for (
int idim = 0; idim <
NDIM; idim++)
139#ifdef STORE_MEMBERS_PTRS
This class defines how to compute the halos from the particles.
double mass
Mass of the halo (units is the same as those in the particles; get_mass)
void add(T &particle, bool periodic=true)
Add a new particle to the FoF group.
std::array< double, NDIM > pos
Center of the halo.
std::vector< T * > member_particles
size_t np
Number of particles in the halo.
std::array< double, NDIM > vel_rms
RMS velocity of the particles in the halo (velocity dispersion per dimension) Contains <v^2> before f...
void finalize(bool periodic=true)
This method is called after all particles has been added to the halo and we can do any normalization ...
constexpr int get_ndim() const
std::array< double, NDIM > vel
Velocity of the halo.
std::array< double, NDIM > get_velocity_dispersion() const
double get_halo_mass() const
get_vel constexpr double * GetPos(...)
constexpr double * GetVel(...)
set_mass constexpr double GetMass(Args &... args)
double periodic(double d)