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

Method step

SPlisHSPlasH/PBF/TimeStepPBF.cpp:92–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void TimeStepPBF::step()
93{
94 Simulation *sim = Simulation::getCurrent();
95 const unsigned int nModels = sim->numberOfFluidModels();
96 TimeManager *tm = TimeManager::getCurrent ();
97 const Real h = tm->getTimeStepSize();
98
99 for (unsigned int fluidModelIndex = 0; fluidModelIndex < nModels; fluidModelIndex++)
100 {
101 FluidModel *model = sim->getFluidModel(fluidModelIndex);
102 clearAccelerations(fluidModelIndex);
103
104 // Time integration
105 #pragma omp parallel default(shared)
106 {
107 #pragma omp for schedule(static)
108 for (int i = 0; i < (int) model->numActiveParticles(); i++)
109 {
110 m_simulationData.getLastPosition(fluidModelIndex, i) = m_simulationData.getOldPosition(fluidModelIndex, i);
111 m_simulationData.getOldPosition(fluidModelIndex, i) = model->getPosition(i);
112 if (model->getParticleState(i) == ParticleState::Active)
113 TimeIntegration::semiImplicitEuler(h, model->getMass(i), model->getPosition(i), model->getVelocity(i), model->getAcceleration(i));
114 }
115 }
116 }
117
118 // Perform neighborhood search
119 sim->performNeighborhoodSearch();
120
121#ifdef USE_PERFORMANCE_OPTIMIZATION
122 precomputeValues();
123#endif
124
125 // Solve density constraint
126 START_TIMING("pressureSolve");
127 pressureSolve();
128 STOP_TIMING_AVG;
129
130 // Update velocities
131 for (unsigned int fluidModelIndex = 0; fluidModelIndex < nModels; fluidModelIndex++)
132 {
133 FluidModel *model = sim->getFluidModel(fluidModelIndex);
134 if (m_velocityUpdateMethod == ENUM_PBF_FIRST_ORDER)
135 {
136 #pragma omp parallel default(shared)
137 {
138 #pragma omp for schedule(static)
139 for (int i = 0; i < (int)model->numActiveParticles(); i++)
140 {
141 if (model->getParticleState(i) == ParticleState::Active)
142 TimeIntegration::velocityUpdateFirstOrder(h, model->getMass(i), model->getPosition(i), m_simulationData.getOldPosition(fluidModelIndex, i), model->getVelocity(i));
143 model->getAcceleration(i).setZero();
144 }
145 }
146 }
147 else
148 {
149 #pragma omp parallel default(shared)

Callers

nothing calls this directly

Calls 15

precomputeValuesFunction · 0.85
computeDensitiesFunction · 0.85
numberOfFluidModelsMethod · 0.80
getFluidModelMethod · 0.80
numActiveParticlesMethod · 0.80
getOldPositionMethod · 0.80
getVelocityMethod · 0.80
updateTimeStepSizeMethod · 0.80
animateParticlesMethod · 0.80
getTimeMethod · 0.80

Tested by

no test coverage detected