Class PositionBasedFluids

Class Documentation

class PositionBasedFluids

Public Static Functions

static bool computePBFDensity(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, Real &density_err, Real &density)

Perform an SPH computation of the density of a fluid particle:

\[\begin{equation*} \rho_i = \sum_j m_j W(\mathbf{x}_i-\mathbf{x}_j). \end{equation*}\]
An additional term is added for neighboring boundary particles according to [1]

in order to perform boundary handling.

Remark: A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers: [9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • density_err – returns the clamped density error (can be used for enforcing a maximal global density error)

  • density – return the density

static bool computePBFLagrangeMultiplier(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const Real density, const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, Real &lambda)

Compute Lagrange multiplier \(\lambda_i\) for a fluid particle which is required by the solver step:

\[\begin{equation*} \lambda_i = -\frac{C_i(\mathbf{x}_1,...,\mathbf{x}_n)}{\sum_k \|\nabla_{\mathbf{x}_k} C_i\|^2 + \varepsilon} \end{equation*}\]
with the constraint gradient:
\[\begin{split}\begin{equation*} \nabla_{\mathbf{x}_k}C_i = \frac{m_j}{\rho_0} \begin{cases} \sum\limits_j \nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = i \\ -\nabla_{\mathbf{x}_k} W(\mathbf{x}_i-\mathbf{x}_j, h) & \text{if } k = j. \end{cases} \end{equation*}\end{split}\]
Remark: The computation of the gradient is extended for neighboring boundary particles according to [1]

to perform a boundary handling. A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers:

[9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • density – density of current fluid particle

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • lambda – returns the Lagrange multiplier

static bool solveDensityConstraint(const unsigned int particleIndex, const unsigned int numberOfParticles, const Vector3r x[], const Real mass[], const Vector3r boundaryX[], const Real boundaryPsi[], const unsigned int numNeighbors, const unsigned int neighbors[], const Real density0, const bool boundaryHandling, const Real lambda[], Vector3r &corr)

Perform a solver step for a fluid particle:

\[\begin{equation*} \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)}, \end{equation*}\]
where \(h\) is the smoothing length of the kernel function \(W\)

.

Remark: The computation of the position correction is extended for neighboring boundary particles according to

[1]

to perform a boundary handling. A neighboring particle with an index >= numberOfParticles is handled as boundary particle.

More information can be found in the following papers:

[9], [5], [6]

Parameters
  • particleIndex – index of current fluid particle

  • numberOfParticles – number of fluid particles

  • x – array of all particle positions

  • mass – array of all particle masses

  • boundaryX – array of all boundary particles

  • boundaryPsi – array of all boundary psi values (see [1])

  • numNeighbors – number of neighbors

  • neighbors – array with indices of all neighbors (indices larger than numberOfParticles are boundary particles)

  • density0 – rest density

  • boundaryHandling – perform boundary handling (see [1])

  • lambda – Lagrange multipliers

  • corr – returns the position correction for the current fluid particle