Skip to content

Commit

Permalink
- bugfix: in emitter scenes now all particles are reset correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
janbender committed Nov 20, 2023
1 parent b7f8321 commit 51706dd
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.12.5
- bugfix: in emitter scenes now all particles are reset correctly
- updated PositionBasedDynamics
- updated GenericParameters

Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/DFSPH/SimulationDataDFSPH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void SimulationDataDFSPH::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_density_adv[i][j] = 0.0;
m_pressure_rho2[i][j] = 0.0;
Expand Down
18 changes: 2 additions & 16 deletions SPlisHSPlasH/FluidModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,8 @@ void FluidModel::reset()
setNumActiveParticles(m_numActiveParticles0);
const unsigned int nPoints = numActiveParticles();

struct Comparator {
Comparator(FluidModel* _this) : m_this(_this) {};
bool operator()(unsigned int a, unsigned int b)
{
return m_this->getParticleId(a) < m_this->getParticleId(b);
}
FluidModel* m_this;
};

// Fluid
for (unsigned int i = 0; i < nPoints; i++)
// use numParticles since numActiveParticles is already reset
for (unsigned int i = 0; i < numParticles(); i++)
{
const Vector3r& x0 = getPosition0(i);
getPosition(i) = x0;
Expand All @@ -223,11 +214,6 @@ void FluidModel::reset()
m_particleId[i] = i;
m_particleState[i] = ParticleState::Active;
}
// emitted particles
for (unsigned int i = nPoints; i < (unsigned int)m_particleId.size(); i++)
{
m_particleId[i] = i;
}

NeighborhoodSearch *neighborhoodSearch = Simulation::getCurrent()->getNeighborhoodSearch();
if (neighborhoodSearch->point_set(m_pointSetIndex).n_points() != nPoints)
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/ICSPH/SimulationDataICSPH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void SimulationDataICSPH::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_pressure[i][j] = 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/IISPH/SimulationDataIISPH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void SimulationDataIISPH::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_lastPressure[i][j] = 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/PBF/SimulationDataPBF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void SimulationDataPBF::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_deltaX[i][j].setZero();
m_lambda[i][j] = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/PF/SimulationDataPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void SimulationDataPF::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_num_fluid_neighbors[i][j] = 0;
m_old_position[i][j].setZero();
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/Utilities/DebugTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void DebugTools::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel* fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_threadIds[i][j] = 0;
m_numNeighbors[i][j] = 0;
Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/Vorticity/MicropolarModel_Bender2017.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void MicropolarModel_Bender2017::step()

void MicropolarModel_Bender2017::reset()
{
for (unsigned int i = 0; i < m_model->numActiveParticles(); i++)
for (unsigned int i = 0; i < m_model->numParticles(); i++)
m_omega[i].setZero();
}

Expand Down
2 changes: 1 addition & 1 deletion SPlisHSPlasH/WCSPH/SimulationDataWCSPH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void SimulationDataWCSPH::reset()
for (unsigned int i = 0; i < nModels; i++)
{
FluidModel *fm = sim->getFluidModel(i);
for (unsigned int j = 0; j < fm->numActiveParticles(); j++)
for (unsigned int j = 0; j < fm->numParticles(); j++)
{
m_pressure[i][j] = 0.0;
m_pressureAccel[i][j].setZero();
Expand Down
2 changes: 2 additions & 0 deletions pySPlisHSPlasH/examples/complex_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def main():
scene.animatedFields[0].translation=[-1,0,0]

# init the simulation
# This creates the fluid models, timeStep, ...
# Call base.initSimulation() before sim.getTimeStep() or sim.getFluidModel()
base.initSimulation()

# Simulation
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.12.4
2.12.5

0 comments on commit 51706dd

Please sign in to comment.