SPH
PeriodicFinder.cpp
Go to the documentation of this file.
3 
5 
7  const Box& domain,
8  SharedPtr<IScheduler> scheduler)
9  : actual(std::move(actual))
10  , domain(domain)
11  , scheduler(scheduler)
12  , extra(*scheduler) {}
13 
14 Size PeriodicFinder::findAll(const Size index, const Float radius, Array<NeighbourRecord>& neighbours) const {
15  return this->findAll(values[index], radius, neighbours);
16 }
17 
18 static const StaticArray<Vector, 3> UNIT = {
19  Vector(1._f, 0._f, 0._f),
20  Vector(0._f, 1._f, 0._f),
21  Vector(0._f, 0._f, 1._f),
22 };
23 
25  const Float radius,
26  Array<NeighbourRecord>& neighbours) const {
27  Size count = actual->findAll(pos, radius, neighbours);
28 
29  for (Size i = 0; i < 3; ++i) {
30  if (pos[i] < domain.lower()[i] + radius) {
31  count += actual->findAll(pos + domain.size()[i] * UNIT[i], radius, extra.local());
32  neighbours.pushAll(extra.local());
33  }
34  if (pos[i] > domain.upper()[i] - radius) {
35  count += actual->findAll(pos - domain.size()[i] * UNIT[i], radius, extra.local());
36  neighbours.pushAll(extra.local());
37  }
38  }
39  return count;
40 }
41 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
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
#define NAMESPACE_SPH_END
Definition: Object.h:12
BasicVector< Float > Vector
Definition: Vector.h:539
void pushAll(const TIter first, const TIter last)
Definition: Array.h:312
Helper object defining three-dimensional interval (box).
Definition: Box.h:17
INLINE const Vector & lower() const
Returns lower bounds of the box.
Definition: Box.h:82
INLINE const Vector & upper() const
Returns upper bounds of the box.
Definition: Box.h:94
INLINE Vector size() const
Returns box dimensions.
Definition: Box.h:106
ArrayView< const Vector > values
View of the source datapoints, updated every time (re)build is called.
virtual Size findAll(const Size index, const Float radius, Array< NeighbourRecord > &neighbours) const =0
Finds all neighbours within given radius from the point given by index.
virtual Size findAll(const Size index, const Float radius, Array< NeighbourRecord > &neighbours) const override
Finds all neighbours within given radius from the point given by index.
PeriodicFinder(AutoPtr< ISymmetricFinder > &&actual, const Box &domain, SharedPtr< IScheduler > scheduler)
Array with fixed number of allocated elements.
Definition: StaticArray.h:19
INLINE Type & local()
Return a value for current thread.
Definition: ThreadLocal.h:88
Overload of std::swap for Sph::Array.
Definition: Array.h:578