SPH
BruteForceFinder.h
Go to the documentation of this file.
1 #pragma once
2 
7 
9 #include "objects/geometry/Box.h"
10 
12 
18 class BruteForceFinder : public FinderTemplate<BruteForceFinder> {
19 protected:
20  // no need to implement these for brute force
21  virtual void buildImpl(IScheduler& UNUSED(scheduler), ArrayView<const Vector> UNUSED(values)) override {}
22 
23 public:
24  template <bool FindAll>
25  Size find(const Vector& pos, const Size index, const Float radius, Array<NeighbourRecord>& neighs) const {
26  for (Size i = 0; i < this->values.size(); ++i) {
27  const Float distSqr = getSqrLength(this->values[i] - pos);
28  if (distSqr < sqr(radius) && (FindAll || rank[i] < rank[index])) {
29  neighs.push(NeighbourRecord{ i, distSqr });
30  }
31  }
32  return neighs.size();
33  }
34 };
35 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Object representing a three-dimensional axis-aligned box.
const float radius
Definition: CurveDialog.cpp:18
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
Definition: MathUtils.h:67
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
INLINE Float getSqrLength(const Vector &v)
Definition: Vector.h:574
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
Definition: Array.h:306
INLINE TCounter size() const noexcept
Definition: Array.h:193
Searches for neighbours by 'brute force', comparing every pair of vectors.
Size find(const Vector &pos, const Size index, const Float radius, Array< NeighbourRecord > &neighs) const
virtual void buildImpl(IScheduler &UNUSED(scheduler), ArrayView< const Vector > UNUSED(values)) override
Helper template, allowing to define all three functions with a single function.
ArrayView< const Vector > values
View of the source datapoints, updated every time (re)build is called.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Definition: Scheduler.h:27
Order rank
Ranks of particles according to their smoothing lengths.
Holds information about a neighbour particles.