Skip to content

Commit 3c2217e

Browse files
committed
- added documentation for position based fluids
1 parent 8d74845 commit 3c2217e

File tree

4 files changed

+111
-5
lines changed

4 files changed

+111
-5
lines changed

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- added documentation for position based fluids
2+
13
1.3.0
24
- added some documentation
35
- cleaned up project

PositionBasedDynamics/PositionBasedFluids.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

PositionBasedDynamics/PositionBasedRigidBodyDynamics.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace PBD
167167
* @param x1 center of mass of second body
168168
* @param inertiaInverseW1 inverse inertia tensor in world coordinates of second body
169169
* @param q1 rotation of second body
170-
* @param ballJointInfo Ball joint information which is required by the solver. This
170+
* @param jointInfo Ball joint information which is required by the solver. This
171171
* information must be generated in the beginning by calling initRigidBodyBallJointInfo()
172172
* and updated each time the bodies change their state by updateRigidBodyBallJointInfo().
173173
* @param corr_x0 position correction of center of mass of first body
@@ -187,8 +187,7 @@ namespace PBD
187187
const Eigen::Matrix<float, 3, 10> &jointInfo, // precomputed joint info
188188
Eigen::Vector3f &corr_x0, Eigen::Quaternionf &corr_q0,
189189
Eigen::Vector3f &corr_x1, Eigen::Quaternionf &corr_q1);
190-
191-
190+
192191
/** Initialize hinge joint and return info which is required by the solver step.
193192
*
194193
* @param x0 center of mass of first body

doc/bibliography.bib

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ @ARTICLE{Bender2013
5252
url = {http://www.sciencedirect.com/science/article/pii/S0097849313001283}
5353
}
5454

55-
@article{Macklin:2013:PBF:2461912.2461984,
55+
@article{Macklin:2013:PBF,
5656
author = {Macklin, Miles and M\"{u}ller, Matthias},
5757
title = {Position based fluids},
5858
journal = {ACM Trans. Graph.},
@@ -134,4 +134,25 @@ @inproceedings{BMM2015
134134
booktitle = "EUROGRAPHICS 2015 Tutorials",
135135
publisher = "Eurographics Association",
136136
location = "Zurich, Switzerland"
137-
}
137+
}
138+
139+
@article{Akinci:2012,
140+
author = {Akinci, Nadir and Ihmsen, Markus and Akinci, Gizem and Solenthaler, Barbara and Teschner, Matthias},
141+
title = {Versatile Rigid-fluid Coupling for Incompressible SPH},
142+
journal = {ACM Trans. Graph.},
143+
issue_date = {July 2012},
144+
volume = {31},
145+
number = {4},
146+
month = jul,
147+
year = {2012},
148+
issn = {0730-0301},
149+
pages = {62:1--62:8},
150+
articleno = {62},
151+
numpages = {8},
152+
url = {http://doi.acm.org/10.1145/2185520.2185558},
153+
doi = {10.1145/2185520.2185558},
154+
acmid = {2185558},
155+
publisher = {ACM},
156+
address = {New York, NY, USA},
157+
keywords = {fluid simulation, fluid-solid coupling, physically-based animation, smoothed particle hydrodynamics},
158+
}

0 commit comments

Comments
 (0)