Guest User

Untitled

a guest
Jun 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1.     for (int pi = 0; pi < _px.size(); pi++)
  2.     {
  3.  
  4.         //pos from array
  5.         float px = _px.at(pi);
  6.         float py = _py.at(pi);
  7.         float pz = _pz.at(pi);
  8.  
  9.         //index of cell particle belongs to
  10.         int i = (_px.at(pi)-_offset[0])/_h[0];
  11.         int j = (_py.at(pi)-_offset[1])/_h[1];
  12.         int k = (_pz.at(pi)-_offset[2])/_h[2];
  13.  
  14.         //bounds
  15.         int low_i = std::max(0,i-1);
  16.         int low_j = std::max(0,j-1);
  17.         int low_k = std::max(0,k-1);
  18.  
  19.         int high_i = std::min(i+1,_nx-1);
  20.         int high_j = std::min(j+1,_ny-1);
  21.         int high_k = std::min(k+1,_nz-1);
  22.  
  23.         //+1/-1 support
  24.         for (int ii = low_i; ii <= high_i; ii++)
  25.             for (int jj = low_j; jj <= high_j; jj++)
  26.                 for (int kk = low_k; kk <= high_k; kk++)
  27.                 {  
  28.                     //target cell center
  29.                     float posii = ii * _h[0] + _offset[0] + 0.5f*_h[0];
  30.                     float posjj = jj * _h[1] + _offset[1] + 0.5f*_h[1];
  31.                     float poskk = kk * _h[2] + _offset[2] + 0.5f*_h[2];
  32.  
  33.                     //tent kernel interpol
  34.                     float m_mass = 1.f*tent(px-posii,_h[0])*tent(py-posjj,_h[1])*tent(pz-poskk,_h[2]);
  35.  
  36.                     //sum mass to target cell
  37.                     _weights[pi] += m_mass;
  38.                 }
  39.  
  40.     }
Add Comment
Please, Sign In to add comment