| 56 | #ifdef USE_AVX |
| 57 | |
| 58 | void TimeStep::computeDensities(const unsigned int fluidModelIndex) |
| 59 | { |
| 60 | Simulation *sim = Simulation::getCurrent(); |
| 61 | FluidModel *model = sim->getFluidModel(fluidModelIndex); |
| 62 | const Real density0 = model->getDensity0(); |
| 63 | const unsigned int numParticles = model->numActiveParticles(); |
| 64 | const unsigned int nFluids = sim->numberOfFluidModels(); |
| 65 | const unsigned int nBoundaries = sim->numberOfBoundaryModels(); |
| 66 | |
| 67 | #pragma omp parallel default(shared) |
| 68 | { |
| 69 | #pragma omp for schedule(static) |
| 70 | for (int i = 0; i < (int) numParticles; i++) |
| 71 | { |
| 72 | const Vector3r &xi = model->getPosition(i); |
| 73 | Real &density = model->getDensity(i); |
| 74 | density = model->getVolume(i) * CubicKernel_AVX::W_zero(); |
| 75 | |
| 76 | Scalarf8 density_avx(0.0f); |
| 77 | Vector3f8 xi_avx(xi); |
| 78 | |
| 79 | ////////////////////////////////////////////////////////////////////////// |
| 80 | // Fluid |
| 81 | ////////////////////////////////////////////////////////////////////////// |
| 82 | forall_fluid_neighbors_avx( |
| 83 | const Scalarf8 Vj_avx = convert_zero(fm_neighbor->getVolume(0), count); |
| 84 | density_avx += Vj_avx * CubicKernel_AVX::W(xi_avx - xj_avx); |
| 85 | ); |
| 86 | |
| 87 | ////////////////////////////////////////////////////////////////////////// |
| 88 | // Boundary |
| 89 | ////////////////////////////////////////////////////////////////////////// |
| 90 | if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Akinci2012) |
| 91 | { |
| 92 | forall_boundary_neighbors_avx( |
| 93 | const Scalarf8 V_avx = convert_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &bm_neighbor->getVolume(0), count); |
| 94 | density_avx += V_avx * CubicKernel_AVX::W(xi_avx - xj_avx); |
| 95 | ); |
| 96 | density += density_avx.reduce(); |
| 97 | } |
| 98 | else if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Koschier2017) |
| 99 | { |
| 100 | density += density_avx.reduce(); |
| 101 | forall_density_maps( |
| 102 | density += rho; |
| 103 | ); |
| 104 | } |
| 105 | else // Bender2019 |
| 106 | { |
| 107 | density += density_avx.reduce(); |
| 108 | forall_volume_maps( |
| 109 | density += Vj * sim->W(xi - xj); |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | density *= density0; |
| 114 | } |
| 115 | } |
nothing calls this directly
no test coverage detected