#ifndef __TimeStepDFSPH_h__ #define __TimeStepDFSPH_h__ #include "SPlisHSPlasH/Common.h" #include "SPlisHSPlasH/TimeStep.h" #include "SimulationDataDFSPH.h" #include "SPlisHSPlasH/SPHKernels.h" #define USE_WARMSTART #define USE_WARMSTART_V namespace SPH { class SimulationDataDFSPH; /** \brief This class implements the Divergence-free Smoothed Particle Hydrodynamics approach introduced * by Bender and Koschier [BK15,BK17,KBST19]. * * References: * - [BK15] Jan Bender and Dan Koschier. Divergence-free smoothed particle hydrodynamics. In ACM SIGGRAPH / Eurographics Symposium on Computer Animation, SCA '15, 147-155. New York, NY, USA, 2015. ACM. URL: http://doi.acm.org/10.1145/2786784.2786796 * - [BK17] Jan Bender and Dan Koschier. Divergence-free SPH for incompressible and viscous fluids. IEEE Transactions on Visualization and Computer Graphics, 23(3):1193-1206, 2017. URL: http://dx.doi.org/10.1109/TVCG.2016.2578335 * - [KBST19] Dan Koschier, Jan Bender, Barbara Solenthaler, and Matthias Teschner. Smoothed particle hydrodynamics for physically-based simulation of fluids and solids. In Eurographics 2019 - Tutorials. Eurographics Association, 2019. URL: https://interactivecomputergraphics.github.io/SPH-Tutorial */ class TimeStepDFSPH : public TimeStep { protected: SimulationDataDFSPH m_simulationData; const Real m_eps = static_cast(1.0e-5); unsigned int m_iterations; Real m_maxError; unsigned int m_minIterations; unsigned int m_maxIterations; bool m_enableDivergenceSolver; unsigned int m_iterationsV; Real m_maxErrorV; unsigned int m_maxIterationsV; void computeDFSPHFactor(const unsigned int fluidModelIndex); void pressureSolve(); void pressureSolveIteration(const unsigned int fluidModelIndex, Real &avg_density_err); void divergenceSolve(); void divergenceSolveIteration(const unsigned int fluidModelIndex, Real &avg_density_err); void computeDensityAdv(const unsigned int fluidModelIndex, const unsigned int index, const Real h, const Real density0); void computeDensityChange(const unsigned int fluidModelIndex, const unsigned int index, const Real h); void computePressureAccel(const unsigned int fluidModelIndex, const unsigned int i, const Real density0, std::vector>& pressure_rho2, const bool applyBoundaryForces = false); Real compute_aij_pj(const unsigned int fluidModelIndex, const unsigned int i); virtual void performNeighborhoodSearchSort(); virtual void emittedParticles(FluidModel *model, const unsigned int startIndex); /** Init all generic parameters */ virtual void initParameters(); public: static std::string METHOD_NAME; static int SOLVER_ITERATIONS; static int MIN_ITERATIONS; static int MAX_ITERATIONS; static int MAX_ERROR; static int SOLVER_ITERATIONS_V; static int MAX_ITERATIONS_V; static int MAX_ERROR_V; static int USE_DIVERGENCE_SOLVER; TimeStepDFSPH(); virtual ~TimeStepDFSPH(void); /** perform a simulation step */ virtual void step(); virtual void reset(); virtual void resize(); virtual std::string getMethodName() { return METHOD_NAME; } virtual int getNumIterations() { return m_iterations; } }; } #endif