@@ -11,6 +11,30 @@ namespace PBD
1111 public:
1212 // -------------- Position Based Fluids -----------------------------------------------------
1313
14+ /* * Perform an SPH computation of the density of a fluid particle:
15+ * \f{equation*}{
16+ * \rho_i = \sum_j m_j W(\mathbf{x}_i-\mathbf{x}_j).
17+ * \f}
18+ * An additional term is added for neighboring boundary particles
19+ * according to \cite Akinci:2012 in order to perform boundary handling.\n\n
20+ * Remark: A neighboring particle with an index >= numberOfParticles is
21+ * handled as boundary particle.\n\n
22+ *
23+ * More information can be found in the following papers: \cite Macklin:2013:PBF, \cite BMOTM2014, \cite BMM2015
24+ *
25+ * @param particleIndex index of current fluid particle
26+ * @param numberOfParticles number of fluid particles
27+ * @param x array of all particle positions
28+ * @param mass array of all particle masses
29+ * @param boundaryX array of all boundary particles
30+ * @param boundaryPsi array of all boundary psi values (see \cite Akinci:2012)
31+ * @param numNeighbors number of neighbors
32+ * @param neighbors array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)
33+ * @param density0 rest density
34+ * @param boundaryHandling perform boundary handling (see \cite Akinci:2012)
35+ * @param density_err returns the clamped density error (can be used for enforcing a maximal global density error)
36+ * @param density return the density
37+ */
1438 static bool computePBFDensity (
1539 const unsigned int particleIndex, // current fluid particle
1640 const unsigned int numberOfParticles, // number of fluid particles
@@ -25,6 +49,40 @@ namespace PBD
2549 float &density_err, // returns the clamped density error (can be used for enforcing a maximal global density error)
2650 float &density); // return the density
2751
52+ /* *
53+ * Compute Lagrange multiplier \f$\lambda_i\f$ for a fluid particle which is required by
54+ * the solver step:
55+ * \f{equation*}{
56+ * \lambda_i = -\frac{C_i(\mathbf{x}_1,...,\mathbf{x}_n)}{\sum_k \|\nabla_{\mathbf{x}_k} C_i\|^2 + \varepsilon}
57+ * \f}
58+ * with the constraint gradient:
59+ * \f{equation*}{
60+ * \nabla_{\mathbf{x}_k}C_i = \frac{m_j}{\rho_0}
61+ * \begin{cases}
62+ * \sum\limits_j \nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = i \\
63+ * -\nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = j.
64+ * \end{cases}
65+ * \f}
66+ * \n
67+ * Remark: The computation of the gradient is extended for neighboring boundary particles
68+ * according to \cite Akinci:2012 to perform a boundary handling. A neighboring
69+ * particle with an index >= numberOfParticles is handled as boundary particle.\n\n
70+ *
71+ * More information can be found in the following papers: \cite Macklin:2013:PBF, \cite BMOTM2014, \cite BMM2015
72+ *
73+ * @param particleIndex index of current fluid particle
74+ * @param numberOfParticles number of fluid particles
75+ * @param x array of all particle positions
76+ * @param mass array of all particle masses
77+ * @param boundaryX array of all boundary particles
78+ * @param boundaryPsi array of all boundary psi values (see \cite Akinci:2012)
79+ * @param density density of current fluid particle
80+ * @param numNeighbors number of neighbors
81+ * @param neighbors array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)
82+ * @param density0 rest density
83+ * @param boundaryHandling perform boundary handling (see \cite Akinci:2012)
84+ * @param lambda returns the Lagrange multiplier
85+ */
2886 static bool computePBFLagrangeMultiplier (
2987 const unsigned int particleIndex, // current fluid particle
3088 const unsigned int numberOfParticles, // number of fluid particles
@@ -39,6 +97,32 @@ namespace PBD
3997 const bool boundaryHandling, // perform boundary handling (Akinci2012)
4098 float &lambda); // returns the Lagrange multiplier
4199
100+ /* * Perform a solver step for a fluid particle:
101+ *
102+ * \f{equation*}{
103+ * \Delta\mathbf{x}_{i} = \frac{m_j}{\rho_0}\sum\limits_j{\left(\lambda_i + \lambda_j\right)\nabla W(\mathbf{x}_i-\mathbf{x}_j, h)},
104+ * \f}
105+ * where \f$h\f$ is the smoothing length of the kernel function \f$W\f$.\n
106+ *\n
107+ * Remark: The computation of the position correction is extended for neighboring boundary particles
108+ * according to \cite Akinci:2012 to perform a boundary handling. A neighboring
109+ * particle with an index >= numberOfParticles is handled as boundary particle.\n\n
110+ *
111+ * More information can be found in the following papers: \cite Macklin:2013:PBF, \cite BMOTM2014, \cite BMM2015
112+ *
113+ * @param particleIndex index of current fluid particle
114+ * @param numberOfParticles number of fluid particles
115+ * @param x array of all particle positions
116+ * @param mass array of all particle masses
117+ * @param boundaryX array of all boundary particles
118+ * @param boundaryPsi array of all boundary psi values (see \cite Akinci:2012)
119+ * @param numNeighbors number of neighbors
120+ * @param neighbors array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)
121+ * @param density0 rest density
122+ * @param boundaryHandling perform boundary handling (see \cite Akinci:2012)
123+ * @param lambda Lagrange multipliers
124+ * @param corr returns the position correction for the current fluid particle
125+ */
42126 static bool solveDensityConstraint (
43127 const unsigned int particleIndex, // current fluid particle
44128 const unsigned int numberOfParticles, // number of fluid particles
0 commit comments