| 638 | |
| 639 | |
| 640 | void computeMatrixL() |
| 641 | { |
| 642 | const int numParticles = (int) x0.size(); |
| 643 | |
| 644 | #pragma omp parallel default(shared) |
| 645 | { |
| 646 | #pragma omp for schedule(static) |
| 647 | for (int i = 0; i < numParticles; i++) |
| 648 | { |
| 649 | const Vector3r &xi0 = x0[i]; |
| 650 | Matrix3r L_; |
| 651 | L_.setZero(); |
| 652 | |
| 653 | const size_t numNeighbors = initialNeighbors[i].size(); |
| 654 | |
| 655 | ////////////////////////////////////////////////////////////////////////// |
| 656 | // Fluid |
| 657 | ////////////////////////////////////////////////////////////////////////// |
| 658 | for (unsigned int j = 0; j < numNeighbors; j++) |
| 659 | { |
| 660 | const unsigned int neighborIndex = initialNeighbors[i][j]; |
| 661 | |
| 662 | const Vector3r &xj0 = x0[neighborIndex]; |
| 663 | const Vector3r xj_xi_0 = xj0 - xi0; |
| 664 | const Vector3r gradW = gradKernelFct(xj_xi_0); |
| 665 | |
| 666 | // minus because gradW(xij0) == -gradW(xji0) |
| 667 | L_ -= restVolumes[neighborIndex] * gradW * xj_xi_0.transpose(); |
| 668 | } |
| 669 | |
| 670 | //// add 1 to z-component. otherwise we get a singular matrix in 2D |
| 671 | //if (sim->is2DSimulation()) |
| 672 | // L(2, 2) = 1.0; |
| 673 | |
| 674 | bool invertible = false; |
| 675 | L_.computeInverseWithCheck(L[i], invertible, 1e-9); |
| 676 | if (!invertible) |
| 677 | { |
| 678 | //MathFunctions::pseudoInverse(L, m_L[i]); |
| 679 | L[i] = Matrix3r::Identity(); |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | #ifdef USE_AVX |
| 686 |
no test coverage detected