VM2D  1.12
Vortex methods for 2D flows simulation
knnCPU.h File Reference
#include "Vortex2D.h"
Include dependency graph for knnCPU.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void WakekNN (const std::vector< Vortex2D > &vtx, const size_t k, std::vector< std::vector< std::pair< double, size_t >>> &initdist)
 

Function Documentation

void WakekNN ( const std::vector< Vortex2D > &  vtx,
const size_t  k,
std::vector< std::vector< std::pair< double, size_t >>> &  initdist 
)

Definition at line 447 of file knnCPU.cpp.

447  {
448  const size_t n = vtx.size();
449 
450  auto gab = GetGabarit(vtx);
451  double scale = std::max(gab.second[0] - gab.first[0], gab.second[1] - gab.first[1]);
452 
453  // data query
454  std::vector<TParticleCode> mortonCodeBoth(2 * vtx.size());
455 
456  // (data query) std::vector<TParticleCode> mortonCodeBoth_temp(2 * vtx.size()); // iq -- // mortonCodeBoth mcquery ( ) mcdata ( ) std::vector<TParticleCode> mcdata, mcquery; std::vector<unsigned int> iq; // k k ( , ) // , 2*k std::vector<size_t> initneig(vtx.size(), -1); // 2*k k ( ) // initdist = {; } // /*std::vector < std::vector < std::pair<double, size_t> >> initdist(vtx.size()); for (auto& d : initdist) d.resize(2 * k, { -1.0, -1 });*/ // double t1 = omp_get_wtime(); double tStart[5], tFinish[5]; double time[5][8]; for (size_t sdvig = 0; sdvig <= 4; ++sdvig) //4 { tStart[sdvig] = omp_get_wtime(); mainCycle((int)k, vtx, gab, scale, (int)sdvig, mortonCodeBoth, s, mortonCodeBoth_temp, mcdata, mcquery, iq, initneig, initdist, time[sdvig]); tFinish[sdvig] = omp_get_wtime(); //std::cout << "time_knn:" // << " " << time[sdvig][1] - time[sdvig][0] // << " " << time[sdvig][2] - time[sdvig][1] // << " " << time[sdvig][3] - time[sdvig][2] // << " " << time[sdvig][4] - time[sdvig][3] // << " " << time[sdvig][5] - time[sdvig][4] // << " " << time[sdvig][6] - time[sdvig][5] // << " " << time[sdvig][7] - time[sdvig][6] << std::endl; }//for sdvig }
457  std::vector<unsigned int> s(256 * omp_get_max_threads());
458  std::vector<TParticleCode> mortonCodeBoth_temp(2 * vtx.size());
459 
460  // iq --
461  // mortonCodeBoth mcquery ( ) mcdata ( )
462  std::vector<TParticleCode> mcdata, mcquery;
463 
464  std::vector<unsigned int> iq;
465 
466 
467  // k k ( , )
468  // , 2*k // 2*k k ( ) // initdist = {; } // /*std::vector < std::vector < std::pair<double, size_t> >> initdist(vtx.size()); for (auto& d : initdist) d.resize(2 * k, { -1.0, -1 });*/ // double t1 = omp_get_wtime(); double tStart[5], tFinish[5]; double time[5][8]; for (size_t sdvig = 0; sdvig <= 4; ++sdvig) //4 { tStart[sdvig] = omp_get_wtime(); mainCycle((int)k, vtx, gab, scale, (int)sdvig, mortonCodeBoth, s, mortonCodeBoth_temp, mcdata, mcquery, iq, initneig, initdist, time[sdvig]); tFinish[sdvig] = omp_get_wtime(); //std::cout << "time_knn:" // << " " << time[sdvig][1] - time[sdvig][0] // << " " << time[sdvig][2] - time[sdvig][1] // << " " << time[sdvig][3] - time[sdvig][2] // << " " << time[sdvig][4] - time[sdvig][3] // << " " << time[sdvig][5] - time[sdvig][4] // << " " << time[sdvig][6] - time[sdvig][5] // << " " << time[sdvig][7] - time[sdvig][6] << std::endl; }//for sdvig }
469  std::vector<size_t> initneig(vtx.size(), -1);
470 
471  // 2*k k ( )
472  // initdist = {; }
473  //
474  /*std::vector < std::vector < std::pair<double, size_t> >> initdist(vtx.size());
475  for (auto& d : initdist)
476  d.resize(2 * k, { -1.0, -1 });*/
477 
478  // double tStart[5], tFinish[5]; double time[5][8]; for (size_t sdvig = 0; sdvig <= 4; ++sdvig) //4 { tStart[sdvig] = omp_get_wtime(); mainCycle((int)k, vtx, gab, scale, (int)sdvig, mortonCodeBoth, s, mortonCodeBoth_temp, mcdata, mcquery, iq, initneig, initdist, time[sdvig]); tFinish[sdvig] = omp_get_wtime(); //std::cout << "time_knn:" // << " " << time[sdvig][1] - time[sdvig][0] // << " " << time[sdvig][2] - time[sdvig][1] // << " " << time[sdvig][3] - time[sdvig][2] // << " " << time[sdvig][4] - time[sdvig][3] // << " " << time[sdvig][5] - time[sdvig][4] // << " " << time[sdvig][6] - time[sdvig][5] // << " " << time[sdvig][7] - time[sdvig][6] << std::endl; }//for sdvig }
479  double t1 = omp_get_wtime();
480  double tStart[5], tFinish[5];
481  double time[5][8];
482  for (size_t sdvig = 0; sdvig <= 4; ++sdvig) //4
483  {
484 
485  tStart[sdvig] = omp_get_wtime();
486  mainCycle((int)k, vtx, gab, scale, (int)sdvig,
487  mortonCodeBoth,
488  s, mortonCodeBoth_temp, mcdata, mcquery,
489  iq, initneig, initdist, time[sdvig]);
490  tFinish[sdvig] = omp_get_wtime();
491 
492  //std::cout << "time_knn:"
493  // << " " << time[sdvig][1] - time[sdvig][0]
494  // << " " << time[sdvig][2] - time[sdvig][1]
495  // << " " << time[sdvig][3] - time[sdvig][2]
496  // << " " << time[sdvig][4] - time[sdvig][3]
497  // << " " << time[sdvig][5] - time[sdvig][4]
498  // << " " << time[sdvig][6] - time[sdvig][5]
499  // << " " << time[sdvig][7] - time[sdvig][6] << std::endl;
500  }//for sdvig
501 }
void mainCycle(const int k, const std::vector< Vortex2D > &vtx, const std::pair< Point2D, Point2D > &gab, const double scale, const int sdvig, std::vector< TParticleCode > &mortonCodeBoth, std::vector< unsigned int > &s, std::vector< TParticleCode > &mortonCodeBoth_temp, std::vector< TParticleCode > &mcdata, std::vector< TParticleCode > &mcquery, std::vector< unsigned int > &iq, std::vector< size_t > &initneig, std::vector< std::vector< std::pair< double, size_t >>> &initdist, double *time)
Definition: knnCPU.cpp:264
std::pair< Point2D, Point2D > GetGabarit(const std::vector< Vortex2D > &vtx)
( )
Definition: knnCPU.cpp:13

Here is the call graph for this function:

Here is the caller graph for this function: