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

Method step

SPlisHSPlasH/XSPH.cpp:46–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44#ifdef USE_AVX
45
46void 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 {

Callers 8

emitParticlesMethod · 0.45
animateParticlesMethod · 0.45
computeSurfaceTensionMethod · 0.45
computeViscosityMethod · 0.45
computeVorticityMethod · 0.45
computeDragForceMethod · 0.45
computeElasticityMethod · 0.45
computeXSPHMethod · 0.45

Calls 15

convertVec_zeroFunction · 0.85
convert_zeroFunction · 0.85
convert_oneFunction · 0.85
numberOfFluidModelsMethod · 0.80
numActiveParticlesMethod · 0.80
getVelocityMethod · 0.80
getNeighborListMethod · 0.80
getVolumeMethod · 0.80
getPointVelocityMethod · 0.80
getPointSetIndexMethod · 0.45

Tested by

no test coverage detected