Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
 All Classes Files Functions Variables Typedefs Friends Pages
neighbour_searcher.h
Go to the documentation of this file.
1 
22 #ifndef __NEIGHBOUR_SEARCHER_H__
23 #define __NEIGHBOUR_SEARCHER_H__
24 
25 
26 
27 #ifdef _MSC_VER
28 typedef __int32 int32_t;
29 typedef unsigned __int32 uint32_t;
30 typedef __int64 int64_t;
31 typedef unsigned __int64 uint64_t;
32 #else
33 #include <stdint.h>
34 #endif
35 
36 
37 #include <cstdlib>
38 #include <vector>
39 #include <deque>
40 #include "octree.h"
41 
42 
43 class Initializer;
44 
45 
65 
66 public:
67 
69  virtual ~NeighbourSearcher() {}
70 
83  virtual int buildSearchStructure(const double* x, const double* y, const double* z, size_t numParticles) = 0;
84 
99  virtual int buildSearchStructure(const double* x, const double* y, const double* z, size_t begin, size_t numParticles) = 0;
100 
101 #ifdef _OPENMP
102 
124  virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, double* distance, size_t& result_length, int tid, int index = -1) = 0;
125 #else
126 
147  virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, double* distance, size_t& result_length, int index = -1) = 0;
148 #endif
149 
150 //virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, size_t& result_length, int index = -1) = 0;
151 
152  //virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, size_t& result_length) = 0;
153 
154 
155 };
156 
175 public:
186  OctreeSearcher(const Initializer& init);
187 
188 
199  OctreeSearcher(size_t maxParticleNum, size_t maxNeighbourNum, int treedepth);
200 
201 
210  virtual ~OctreeSearcher() {
211  delete m_pOctree;
212 #ifdef _OPENMP
213  for(int i=0 ; i<m_iTheadNum ; i++) {
214  delete[] m_pSearchResult[i];
215  }
216  delete[] m_pSearchResult;
217 #else
218  delete[] m_pSearchResult;
219 #endif
220  }
221 
222 public:
223 
236  virtual int buildSearchStructure(const double* x, const double* y, const double* z, size_t numParticles) {
237  return buildSearchStructure(x, y, z, 0, numParticles);
238  }
239 
240 
255  virtual int buildSearchStructure(const double* x, const double* y, const double* z, size_t begin, size_t numParticles);
256 
257 
258 #ifdef _OPENMP
259 
281  virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, double* distance, size_t& result_length, int tid, int index = -1);
282 #else
283 
304  virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int* result, double* distance, size_t& result_length, int index = -1);
305 #endif
306 
307 
308 
309 private:
310  Octree* m_pOctree;
311  size_t m_iMaxParticleNum;
312  size_t m_iMaxNeighborNum;
313 
314 #ifdef _OPENMP
315  int m_iTheadNum;
316  SearchResult** m_pSearchResult;
317  //vector<SearchResult*> m_pSearchResult;
318 #else
319  SearchResult* m_pSearchResult;
320 #endif
321 
322 };
323 
324 #endif
OctreeSearcher(const Initializer &init)
Constructor.
Definition: neighbour_searcher.cpp:21
virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int *result, double *distance, size_t &result_length, int index=-1)
Searches the nearest neighbours for a particle on the built Octree object.
Definition: neighbour_searcher.cpp:131
An abstract class for the family of classes that performs the task of nearest neighbour search for pa...
Definition: neighbour_searcher.h:64
This class contains the Octree data structure and algorithm for nearest neighbour search of particles...
Definition: octree.h:94
virtual int buildSearchStructure(const double *x, const double *y, const double *z, size_t numParticles)=0
Build the data structure for the nearest neighbour search, based on the input particle location ayyay...
virtual ~OctreeSearcher()
Destructor.
Definition: neighbour_searcher.h:210
This class initializes the simulation.
Definition: initializer.h:227
This header file contains classes for the Octree data structure and nearest neighbour search algorith...
A simple struct for the neighbour search result.
Definition: octree.h:52
A class that searches nearest neighbours of particles based on the Octree data structure and algorith...
Definition: neighbour_searcher.h:174
virtual ~NeighbourSearcher()
Destructor.
Definition: neighbour_searcher.h:69
virtual int searchNeighbour(const double x, const double y, const double z, const double radius, int *result, double *distance, size_t &result_length, int index=-1)=0
Searches the nearest neighbours for a particle on the built search data structure.
virtual int buildSearchStructure(const double *x, const double *y, const double *z, size_t numParticles)
Build an Octree object for the nearest neighbour search, based on the input particle location ayyays ...
Definition: neighbour_searcher.h:236