Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //the only thing that changed since p2m is the delete vector. get the new one
- _deleted->copy_all_data(*data->deleted);
- //to be sent to gpu
- _alpha->clear_zero();
- for (int pi = 0; pi < _num_part; pi++)
- {
- if (_deleted->at(pi) == 1)
- continue;
- //pos from array
- float px = _px->at(pi);
- float py = _py->at(pi);
- float pz = _pz->at(pi);
- //mass to distribute
- float p_mass = _alpha->at(pi);
- //index of cell particle belongs to
- int i = (_px->at(pi)-_offset[0])/_h[0];
- int j = (_py->at(pi)-_offset[1])/_h[1];
- int k = (_pz->at(pi)-_offset[2])/_h[2];
- //+1/-1 support
- for (int ii = i-1; ii <= i+1; ii++)
- for (int jj = j-1; jj <= j+1; jj++)
- for (int kk = k-1; kk <= k+1; kk++)
- {
- //target cell center
- float posii = ii * _h[0] + _offset[0] + 0.5f*_h[0];
- float posjj = jj * _h[1] + _offset[1] + 0.5f*_h[1];
- float poskk = kk * _h[2] + _offset[2] + 0.5f*_h[2];
- //tent kernel interpol
- float m_mass = 1.f*tent(px-posii,_h[0])*tent(py-posjj,_h[1])*tent(pz-poskk,_h[2]);
- //sum mass to target cell
- at(ii,jj,kk)._mass_sum += m_mass;
- }
- }
- for (int i = 0; i <_nx; i++) {
- for (int j = 0; j <_ny; j++) {
- for (int k = 0; k <_nz; k++) {
- //+1/-1 support
- for (int ii = i-1; ii <= i+1; ii++)
- for (int jj = j-1; jj <= j+1; jj++)
- for (int kk = k-1; kk <= k+1; kk++)
- {
- float mass_sum = at(ii,jj,kk)._mass_sum;
- //current cell center
- float posii = ii * _h[0] + _offset[0] + 0.5f*_h[0];
- float posjj = jj * _h[1] + _offset[1] + 0.5f*_h[1];
- float poskk = kk * _h[2] + _offset[2] + 0.5f*_h[2];
- float m_mass = at(ii,jj,kk)._mass;
- //interpol
- for (std::vector<int>::iterator it = at(ii,jj,kk)._particles.begin(); it != at(ii,jj,kk)._particles.end(); it++)
- {
- if (_deleted->at(*it)==1) continue;
- //pos from array
- float px = _px->at(*it);
- float py = _py->at(*it);
- float pz = _pz->at(*it);
- float p_mass = m_mass*tent(px-posii,_h[0])*tent(py-posjj,_h[1])*tent(pz-poskk,_h[2]);
- _alpha->at(*it) += p_mass;
- }
- }
- }
- }
- }
- //send corrected vector to gpu
- data->alpha->copy_all_data(*_alpha);
Add Comment
Please, Sign In to add comment