| 110 | |
| 111 | |
| 112 | void SPHVolumeSampling::step(Real& avg_density_err) |
| 113 | { |
| 114 | avg_density_err = 0.0; |
| 115 | |
| 116 | ////////////////////////////////////////////////////////////////////////// |
| 117 | // SPH optimization of sampling points |
| 118 | ////////////////////////////////////////////////////////////////////////// |
| 119 | |
| 120 | const int numParticles = (int)m_x.size(); |
| 121 | Real V0 = m_diameter * m_diameter * m_diameter; |
| 122 | |
| 123 | const Real diameter2 = m_diameter* m_diameter; |
| 124 | const Real supportRadius = m_radius* static_cast<Real>(4.0); |
| 125 | |
| 126 | START_TIMING("neighborhoodSearch"); |
| 127 | m_neighborhoodSearch->find_neighbors(); |
| 128 | STOP_TIMING_AVG |
| 129 | |
| 130 | computeDensities(m_densities, m_mass); |
| 131 | |
| 132 | // Compute cohesion => Becker 2007 |
| 133 | #pragma omp parallel default(shared) |
| 134 | { |
| 135 | #pragma omp for schedule(static) |
| 136 | for (int i = 0; i < numParticles; i++) |
| 137 | { |
| 138 | const Vector3r &xi = m_x[i]; |
| 139 | Vector3r &corr = m_corrs[i]; |
| 140 | corr.setZero(); |
| 141 | |
| 142 | for (unsigned int j = 0; j < numberOfNeighbors(0, i); j++) |
| 143 | { |
| 144 | const unsigned int neighborIndex = getNeighbor(0, i, j); |
| 145 | const Vector3r &xj = m_x[neighborIndex]; |
| 146 | |
| 147 | const Vector3r xixj = xi - xj; |
| 148 | const Real r2 = xixj.dot(xixj); |
| 149 | if (r2 > 1e-6) |
| 150 | { |
| 151 | const Real C = (xi - xj).norm() - m_diameter; |
| 152 | Vector3r xixj_n = xixj; |
| 153 | xixj_n.normalize(); |
| 154 | corr -= m_cohesion * m_mass/ m_densities[neighborIndex] * C * xixj_n * m_kernelFct(xi - xj); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if (m_adhesion != 0.0) |
| 159 | { |
| 160 | // Collision detection |
| 161 | Vector3r cp, normal; |
| 162 | const double dist = distance(xi, 0.0, normal, cp); |
| 163 | if (dist < supportRadius) |
| 164 | { |
| 165 | corr -= m_adhesion * m_mass / m_densities[i] * (xi - cp) * m_kernelFct(xi - cp); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
nothing calls this directly
no test coverage detected