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

Method computeDensities

SPlisHSPlasH/TimeStep.cpp:58–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56#ifdef USE_AVX
57
58void 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 }

Callers

nothing calls this directly

Calls 15

convert_zeroFunction · 0.85
forall_density_mapsFunction · 0.85
forall_volume_mapsFunction · 0.85
getFluidModelMethod · 0.80
getDensity0Method · 0.80
numActiveParticlesMethod · 0.80
numberOfFluidModelsMethod · 0.80
getVolumeMethod · 0.80
getNeighborListMethod · 0.80

Tested by

no test coverage detected