-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Official implementation of the TOG paper "Implicit Surface Tension fo…
…r SPH Fluid Simulation" (#291) * start porting surface tension add scenes * add python bindings * bump version and fix other surface tension scenes * fix non-avx surface tension model * bump to next major version
- Loading branch information
1 parent
51706dd
commit dd82d48
Showing
17 changed files
with
2,029 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,329 changes: 1,329 additions & 0 deletions
1,329
SPlisHSPlasH/SurfaceTension/SurfaceTension_Jeske2023.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#ifndef __SurfaceTension_Jeske2023_Surface_Tension_h__ | ||
#define __SurfaceTension_Jeske2023_Surface_Tension_h__ | ||
|
||
#include "SPlisHSPlasH/Common.h" | ||
#include "SPlisHSPlasH/FluidModel.h" | ||
#include "SurfaceTensionBase.h" | ||
#include "SPlisHSPlasH/Utilities/MatrixFreeSolver.h" | ||
#include "Utilities/Logger.h" | ||
|
||
namespace SPH | ||
{ | ||
/** \brief This class implements the implicit surface tension method | ||
* by Jeske et al. 2023 [JWL+23]. | ||
* | ||
* References: | ||
* - [JWL+23] Jeske, Stefan Rhys, Lukas Westhofen, Fabian Löschner, José Antonio Fernández-Fernández, and Jan Bender. “Implicit Surface Tension for SPH Fluid Simulation.” ACM Transactions on Graphics, November 7, 2023. URL: https://doi.org/10.1145/3631936. | ||
*/ | ||
class SurfaceTension_Jeske2023 : public SurfaceTensionBase | ||
{ | ||
protected: | ||
Real m_viscosity; | ||
Real m_boundaryViscosity; | ||
|
||
unsigned int m_maxIter; | ||
Real m_maxError; | ||
unsigned int m_iterations; | ||
std::vector<Vector3r> m_vDiff; | ||
std::vector<Real> m_gradRho; | ||
std::vector<Real> m_surfaceEnergy; | ||
std::vector<Real> m_color; | ||
std::vector<Vector3r> m_colorGrad; | ||
std::vector<Vector3r> m_nonlinearAcc; | ||
std::vector<Vector3r> m_nonlinearRes; | ||
std::vector<Vector3r> m_nonlinearGrad; | ||
|
||
Real m_tangentialDistanceFactor; | ||
bool m_weakPhaseCoupling; | ||
Real m_xsph; | ||
|
||
typedef Eigen::ConjugateGradient<MatrixReplacement, Eigen::Lower | Eigen::Upper, Eigen::IdentityPreconditioner> Solver; | ||
|
||
Solver m_solver; | ||
|
||
|
||
virtual void initParameters(); | ||
|
||
public: | ||
static int ITERATIONS; | ||
static int MAX_ITERATIONS; | ||
static int MAX_ERROR; | ||
static int VISCOSITY_COEFFICIENT; | ||
static int VISCOSITY_COEFFICIENT_BOUNDARY; | ||
static int XSPH; | ||
|
||
SurfaceTension_Jeske2023(FluidModel *model); | ||
virtual ~SurfaceTension_Jeske2023(void); | ||
|
||
static NonPressureForceBase* creator(FluidModel* model) { return new SurfaceTension_Jeske2023(model); } | ||
|
||
virtual void step(); | ||
virtual void reset(); | ||
|
||
virtual void performNeighborhoodSearchSort(); | ||
|
||
static void matrixVecProd(const Real* vec, Real *result, void *userData); | ||
|
||
FORCE_INLINE const Vector3r& getVDiff(const unsigned int i) const | ||
{ | ||
return m_vDiff[i]; | ||
} | ||
|
||
FORCE_INLINE Vector3r& getVDiff(const unsigned int i) | ||
{ | ||
return m_vDiff[i]; | ||
} | ||
|
||
FORCE_INLINE void setVDiff(const unsigned int i, const Vector3r& val) | ||
{ | ||
m_vDiff[i] = val; | ||
} | ||
|
||
FORCE_INLINE const Real& getDensityGrad(const unsigned int i) const | ||
{ | ||
return m_gradRho[i]; | ||
} | ||
|
||
FORCE_INLINE Real& getDensityGrad(const unsigned int i) | ||
{ | ||
return m_gradRho[i]; | ||
} | ||
|
||
FORCE_INLINE void setDensityGrad(const unsigned int i, const Real& val) | ||
{ | ||
m_gradRho[i] = val; | ||
} | ||
|
||
void computeRHS(VectorXr &b, VectorXr &g); | ||
|
||
void applyForces(const VectorXr &x); | ||
|
||
Real getMaxSolverError(){ return m_maxError; } | ||
void setMaxSolverError(Real error){ m_maxError = error; } | ||
|
||
bool getWeakCoupling(){ return m_weakPhaseCoupling; } | ||
void setWeakCoupling(bool val){ m_weakPhaseCoupling = val; } | ||
|
||
bool getViscosity(){ return m_viscosity; } | ||
void setViscosity(Real val){ m_viscosity = val; } | ||
|
||
void computeDensityGradient(); | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.