MPS-Basic
Loading...
Searching...
No Matches
NeighborSearcher Class Reference

#include <neighbor_searcher.hpp>

Collaboration diagram for NeighborSearcher:

Public Member Functions

 NeighborSearcher ()=default
 
 NeighborSearcher (const double &re, const Domain &domain, const size_t &particleSize)
 
void setNeighbors (Particles &particles)
 

Private Attributes

double re
 
Domain domain
 
Bucket bucket
 

Detailed Description

Definition at line 7 of file neighbor_searcher.hpp.

Constructor & Destructor Documentation

◆ NeighborSearcher() [1/2]

NeighborSearcher::NeighborSearcher ( )
default

◆ NeighborSearcher() [2/2]

NeighborSearcher::NeighborSearcher ( const double & re,
const Domain & domain,
const size_t & particleSize )

Definition at line 5 of file neighbor_searcher.cpp.

5 {
6 this->re = re;
7 this->domain = domain;
8 this->bucket = Bucket(re, domain, particleSize);
9}
Class for bucket for neighbor search.
Definition bucket.hpp:17

Member Function Documentation

◆ setNeighbors()

void NeighborSearcher::setNeighbors ( Particles & particles)

Definition at line 11 of file neighbor_searcher.cpp.

11 {
12 bucket.storeParticles(particles);
13
14#pragma omp parallel for
15 for (auto& pi : particles) {
16 if (pi.type == ParticleType::Ghost)
17 continue;
18
19 pi.neighbors.clear();
20
21 int ix = (int) ((pi.position.x() - domain.xMin) / bucket.length) + 1;
22 int iy = (int) ((pi.position.y() - domain.yMin) / bucket.length) + 1;
23 int iz = (int) ((pi.position.z() - domain.zMin) / bucket.length) + 1;
24
25 for (int jx = ix - 1; jx <= ix + 1; jx++) {
26 for (int jy = iy - 1; jy <= iy + 1; jy++) {
27 for (int jz = iz - 1; jz <= iz + 1; jz++) {
28 int jBucket = jx + jy * bucket.numX + jz * bucket.numX * bucket.numY;
29 int j = bucket.first[jBucket];
30
31 while (j != -1) {
32 Particle& pj = particles[j];
33
34 double dist = (pj.position - pi.position).norm();
35 if (j != pi.id && dist < re) {
36 pi.neighbors.emplace_back(j, dist);
37 }
38
39 j = bucket.next[j];
40 }
41 }
42 }
43 }
44 }
45}
void storeParticles(Particles &particles)
store particles in the bucket
Definition bucket.cpp:24
std::vector< int > next
Definition bucket.hpp:23
int numY
Definition bucket.hpp:20
double length
Definition bucket.hpp:21
std::vector< int > first
Definition bucket.hpp:23
int numX
Definition bucket.hpp:20
double zMin
minimum z coordinate of the domain
Definition domain.hpp:15
double xMin
minimum x coordinate of the domain
Definition domain.hpp:11
double yMin
minimum y coordinate of the domain
Definition domain.hpp:13
Class for particle in MPS method.
Definition particle.hpp:47
Eigen::Vector3d position
position of the particle
Definition particle.hpp:55
@ Ghost
Ghost particle (outside of the domain, not used for calculation)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ re

double NeighborSearcher::re
private

Definition at line 16 of file neighbor_searcher.hpp.

◆ domain

Domain NeighborSearcher::domain
private

Definition at line 17 of file neighbor_searcher.hpp.

◆ bucket

Bucket NeighborSearcher::bucket
private

Definition at line 18 of file neighbor_searcher.hpp.


The documentation for this class was generated from the following files: