MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / computeNormals

Function computeNormals

Tools/FoamGenerator/main.cpp:1290–1322  ·  view source on GitHub ↗

Compute normals of fluid particles using a color field. */

Source from the content-addressed store, hash-verified

1288/** Compute normals of fluid particles using a color field.
1289*/
1290void 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*/

Callers 4

stepMethod · 0.85
determineValuesFunction · 0.85
generateFoamFunction · 0.85
stepMethod · 0.85

Calls 6

numberOfNeighborsFunction · 0.70
getNeighborFunction · 0.70
resizeMethod · 0.45
sizeMethod · 0.45
setZeroMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected