| 44 | #ifdef USE_AVX |
| 45 | |
| 46 | void XSPH::step() |
| 47 | { |
| 48 | if ((m_fluidCoefficient == 0.0) && (m_boundaryCoefficient == 0.0)) |
| 49 | return; |
| 50 | |
| 51 | Simulation *sim = Simulation::getCurrent(); |
| 52 | const unsigned int nFluids = sim->numberOfFluidModels(); |
| 53 | const unsigned int nBoundaries = sim->numberOfBoundaryModels(); |
| 54 | const unsigned int fluidModelIndex = m_model->getPointSetIndex(); |
| 55 | const unsigned int numParticles = m_model->numActiveParticles(); |
| 56 | const Real density0 = m_model->getValue<Real>(FluidModel::DENSITY0); |
| 57 | |
| 58 | const Real h = TimeManager::getCurrent()->getTimeStepSize(); |
| 59 | const Real invH = (static_cast<Real>(1.0) / h); |
| 60 | |
| 61 | // Compute viscosity forces (XSPH) |
| 62 | #pragma omp parallel default(shared) |
| 63 | { |
| 64 | #pragma omp for schedule(static) |
| 65 | for (int i = 0; i < (int)numParticles; i++) |
| 66 | { |
| 67 | const Vector3r &xi = m_model->getPosition(i); |
| 68 | const Vector3r &vi = m_model->getVelocity(i); |
| 69 | Vector3r &ai = m_model->getAcceleration(i); |
| 70 | const Real density_i = m_model->getDensity(i); |
| 71 | |
| 72 | const Vector3f8 xi_avx(xi); |
| 73 | const Vector3f8 vi_avx(vi); |
| 74 | const Scalarf8 mi_avx(m_model->getMass(i)); |
| 75 | const Scalarf8 density_i_avx(density_i); |
| 76 | Vector3f8 delta_ai; |
| 77 | delta_ai.setZero(); |
| 78 | const Scalarf8 dvisc(invH * m_fluidCoefficient); |
| 79 | |
| 80 | ////////////////////////////////////////////////////////////////////////// |
| 81 | // Fluid |
| 82 | //////////////////////////////////////////////////////////////////////// |
| 83 | if (m_fluidCoefficient != 0.0) |
| 84 | { |
| 85 | forall_fluid_neighbors_avx( |
| 86 | const Vector3f8 vj_avx = convertVec_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &fm_neighbor->getVelocity(0), count); |
| 87 | const Scalarf8 mj_avx = convert_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &fm_neighbor->getMass(0), count); |
| 88 | |
| 89 | // Viscosity |
| 90 | const Scalarf8 density_j_avx = convert_one(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &fm_neighbor->getDensity(0), count); |
| 91 | const Vector3f8 xixj = xi_avx - xj_avx; |
| 92 | delta_ai -= (vi_avx - vj_avx) * dvisc * (mj_avx / density_j_avx) * CubicKernel_AVX::W(xixj); |
| 93 | ); |
| 94 | ai += delta_ai.reduce(); |
| 95 | } |
| 96 | |
| 97 | ////////////////////////////////////////////////////////////////////////// |
| 98 | // Boundary |
| 99 | ////////////////////////////////////////////////////////////////////////// |
| 100 | if (m_boundaryCoefficient != 0.0) |
| 101 | { |
| 102 | if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Akinci2012) |
| 103 | { |
no test coverage detected