83 const Size leafSize = 25,
97 const Size leafSize = 25,
167 TreeWalkResult& result)
const;
Definitions of physical constaints (in SI units).
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Smoothing kernels for including gravity into SPH.
Base class for solvers of gravity.
K-d tree for efficient search of neighbouring particles.
#define NAMESPACE_SPH_END
BasicVector< Float > Vector
Object providing safe access to continuous memory of data.
Multipole approximation of distance particle.
virtual void evalAll(IScheduler &pool, ArrayView< Vector > dv, Statistics &stats) const override
Evaluates the gravitational acceleration concurrently.
void evalNode(IScheduler &scheduler, ArrayView< Vector > dv, const Size nodeIdx, TreeWalkState data, TreeWalkResult &result) const
Performs a recursive treewalk evaluating gravity for all particles.
ArrayView< const Vector > r
View of a position buffer in the storage.
MultipoleOrder order
Order of multipole approximation.
GravityLutKernel kernel
Kernel used to evaluate gravity of close particles.
BarnesHut(const Float theta, const MultipoleOrder order, const Size leafSize=25, const Size maxDepth=50, const Float gravityConstant=Constants::gravity)
Constructs the Barnes-Hut gravity assuming point-like particles (with zero radius).
virtual Vector eval(const Vector &r0) const override
Evaluates the gravitational acceleration at given point.
MultipoleExpansion< 3 > getMoments() const
Returns the multipole moments computed from root node.
void buildInner(BarnesHutNode &node, BarnesHutNode &left, BarnesHutNode &right)
Vector evalExact(const LeafNode< BarnesHutNode > &node, const Vector &r0, const Size idx) const
Size maxDepth
Maximum depth at which the nodes evaluation is parallelized.
Vector evalImpl(const Vector &r0, const Size idx) const
Evaluates the gravity at a single point in space.
void evalParticleList(const LeafNode< BarnesHutNode > &leaf, ArrayView< Size > particleList, ArrayView< Vector > dv) const
virtual RawPtr< const IBasicFinder > getFinder() const override
Optionally returns a finder used by the gravity implementation.
Array< Float > m
Particle masses multiplied by gravitational constant.
void evalNodeList(const LeafNode< BarnesHutNode > &leaf, ArrayView< Size > nodeList, ArrayView< Vector > dv) const
void buildLeaf(BarnesHutNode &node)
KdTree< BarnesHutNode > kdTree
K-d tree storing gravitational moments.
virtual Float evalEnergy(IScheduler &scheduler, Statistics &stats) const override
Computes the total potential energy of the particles.
Float gravityConstant
Gravitational constant in the selected unit system.
Float thetaInv
Inverted value of the opening angle for multipole approximation (in radians)
virtual void build(IScheduler &pool, const Storage &storage) override
Masses of particles must be strictly positive, otherwise center of mass would be undefined.
Gravitational kernel approximated by LUT for close particles.
Interface for computing gravitational interactions of particles.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Non-owning wrapper of pointer.
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
constexpr Float gravity
Gravitational constant (CODATA 2014)
MultipoleExpansion< 3 > moments
Gravitational moments with a respect to the center of mass, using expansion to octupole order.
Vector com
Center of mass of contained particles.
BarnesHutNode(const Type &type)
std::atomic_int approximatedNodes
Number of nodes approximated using multipole expansion.
std::atomic_int exactNodes
Number of opened leafs where exact (pair-wise) solution has been used.
Data passed into each node during treewalk.
TreeWalkState clone() const
Clones all lists in the state object.
Array< Size > nodeList
Indices of nodes that shall be evaluated using multipole approximation.
Size depth
Current depth in the tree; root node has depth equal to zero.
Array< Size > particleList
Indices of nodes where the exact (pair-wise) gravity solution have to be used.
Base class for nodes of K-d tree.
Type
Here X, Y, Z must be 0, 1, 2.
Leaf (bucket) node of K-d tree.