Compute normals of fluid particles using a color field. */
| 1288 | /** Compute normals of fluid particles using a color field. |
| 1289 | */ |
| 1290 | void computeNormals() |
| 1291 | { |
| 1292 | normals.resize(x0.size()); |
| 1293 | |
| 1294 | // Compute normals |
| 1295 | #pragma omp parallel default(shared) |
| 1296 | { |
| 1297 | #pragma omp for schedule(static) |
| 1298 | for (int i = 0; i < (int)x0.size(); i++) |
| 1299 | { |
| 1300 | const Vector3r &xi = x0[i]; |
| 1301 | Vector3r &ni = normals[i]; |
| 1302 | ni.setZero(); |
| 1303 | |
| 1304 | // We are only interested in surface particles |
| 1305 | if (numberOfNeighbors(0, i) > 20) |
| 1306 | continue; |
| 1307 | |
| 1308 | ////////////////////////////////////////////////////////////////////////// |
| 1309 | // Fluid |
| 1310 | ////////////////////////////////////////////////////////////////////////// |
| 1311 | for (unsigned int j = 0; j < numberOfNeighbors(0, i); j++) |
| 1312 | { |
| 1313 | const unsigned int neighborIndex = getNeighbor(0, i, j); |
| 1314 | const Vector3r &xj = x0[neighborIndex]; |
| 1315 | const Real density_j = densities[neighborIndex]; |
| 1316 | ni -= mass / density_j * CubicKernel::gradW(xi - xj); |
| 1317 | } |
| 1318 | ni.normalize(); |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | } |
| 1323 | |
| 1324 | /** Compute densities of the fluid particles. |
| 1325 | */ |
no test coverage detected