| 839 | |
| 840 | |
| 841 | void precomputeValues() |
| 842 | { |
| 843 | const int numParticles = (int)activeParticles.size(); |
| 844 | unsigned int numVertices = mesh.numVertices(); |
| 845 | auto& meshX0 = mesh.getVertices(); |
| 846 | |
| 847 | #ifdef USE_AVX |
| 848 | precomputed_indices8.clear(); |
| 849 | precomp_V_gradW8.clear(); |
| 850 | precomputed_indices8.resize(numParticles); |
| 851 | #else |
| 852 | precomputed_indices.clear(); |
| 853 | precomp_V_gradW.clear(); |
| 854 | precomputed_indices.resize(numParticles); |
| 855 | #endif |
| 856 | |
| 857 | |
| 858 | unsigned int sumNeighborParticles = 0; |
| 859 | unsigned int sumNeighborParticles8 = 0; |
| 860 | for (int i = 0; i < numParticles; i++) |
| 861 | { |
| 862 | const unsigned int index = activeParticles[i]; |
| 863 | const size_t numNeighbors = initialNeighbors[index].size(); |
| 864 | |
| 865 | #ifdef USE_AVX |
| 866 | precomputed_indices8[i] = sumNeighborParticles8; |
| 867 | |
| 868 | // steps of 8 values due to avx |
| 869 | sumNeighborParticles8 += (unsigned int) numNeighbors / 8u; |
| 870 | if (numNeighbors % 8 != 0) |
| 871 | sumNeighborParticles8++; |
| 872 | #else |
| 873 | precomputed_indices[i] = sumNeighborParticles; |
| 874 | sumNeighborParticles += (int) numNeighbors; |
| 875 | #endif |
| 876 | } |
| 877 | |
| 878 | #ifdef USE_AVX |
| 879 | precomp_V_gradW8.resize(sumNeighborParticles8); |
| 880 | #else |
| 881 | precomp_V_gradW.resize(sumNeighborParticles); |
| 882 | #endif |
| 883 | |
| 884 | #pragma omp parallel default(shared) |
| 885 | { |
| 886 | #pragma omp for schedule(static) |
| 887 | for (int i = 0; i < (int)numParticles; i++) |
| 888 | { |
| 889 | const unsigned int index = activeParticles[i]; |
| 890 | const Vector3r& xi0 = x0[index]; |
| 891 | const unsigned int numNeighbors = (unsigned int)initialNeighbors[index].size(); |
| 892 | |
| 893 | #ifdef USE_AVX |
| 894 | const Vector3f8 xi0_avx(xi0); |
| 895 | unsigned int base8 = precomputed_indices8[i]; |
| 896 | unsigned int idx = 0; |
| 897 | Matrix3f8 L_avx(L[index]); |
| 898 | for (unsigned int j = 0; j < numNeighbors; j += 8) |
no test coverage detected