Implicit Incompressible SPH (IISPH) as introduced by [Ihmsen et al. (2013)](@cite Ihmsen2013) is a method that achieves incompressibility by solving the pressure Poisson equation. The resulting linear system is iteratively solved with the relaxed Jacobi method. Unlike the [weakly compressible SPH method](@ref wcsph), incompressible methods determine pressure by enforcing the incompressibility constraint rather than using an equation of state.
Modules = [TrixiParticles]
Pages = [joinpath("schemes", "fluid", "implicit_incompressible_sph", "system.jl")]
To derive the linear system of the pressure Poisson equation, we start by discretizing the continuity equation
For a particle i, discretizing the left-hand side of the equation with a forward
difference yields
The divergence in the right-hand side is discretized with the SPH discretization for
particle i as
where \bm{v}_{ij} = \bm{v}_i - \bm{v}_j.
Together, the following discretized version of the continuity equation for a particle i
is achieved:
The right-hand side contains the unknown velocities \bm{v}_{ij}(t + \Delta t) at the
next time step, making it an implicit formulation.
Using the semi-implicit Euler method, we can obtain the velocity in the next time step as
where \bm{F}_i^{\text{adv}} denotes all non-pressure forces such as gravity, viscosity, surface
tension and more, while \bm{F}_i^pdenotes the unknown pressure forces, which we
want to solve for.
Note that the IISPH is an incompressible method, which means that the density of the
fluid remain constant over time. By assuming a fixed reference density \rho_0 for all
fluid particle over the whole time of the simulation, the density value at the next time
step \rho_i(t + \Delta t) also has to be this rest density. So \rho_0 can be plugged in
for \rho_i(t + \Delta t) in the formula above.
The goal is to compute the pressure values required to obtain the pressure acceleration that
ensures each particle reaches the rest density in the next time step. At the moment these
pressure values are unknown in t, but all the non-pressure forces are already known.
Therefore a predicted velocity can be calculated, which depends only on the non-pressure
forces \bm{F}_i^{\text{adv}}:
Using this predicted velocity and the continuity equation, a predicted density can be defined in a similar way as
To achieve the rest density, the unknown pressure forces must counteract the compression caused by the non-pressure forces. In other words, they must resolve the deviation between the predicted density and the reference density.
Therefore, the following equation needs to be fulfilled:
This expression is derived by substituting the reference density \rho_0 for
\rho_i(t+\Delta t) in the discretized continuity equation and inserting the definitions of
the predicted velocity \bm{v}_{ij}(t+\Delta t) and predicted density \rho_i^{\text{adv}}.
The pressure force is defined as:
Substituting this definition into the equation yields a linear system \bm{A}(t) \bm{p}(t) = \bm{b}(t)
with one equation and one unknown pressure value for each particle.
For n particles, this is a linear system with n equations and n unknowns:
To solve for the pressure values, a relaxed Jacobi scheme is used.
This is an iterative numerical method to solve a linear system Ap=b. In each iteration, the
new values of p are obtained as computed as
Substituting the right-hand side, we obtain
Therefore the diagonal elements a_{ii} and the sum \sum_{j \neq i} a_{ij}p_j^l need to
be determined.
This can be done efficiently by separating the pressure force acceleration into two
components: One that describes the influence of particle i's own pressure on its
displacement, and one that describes the displacement due to the pressure values of the
neighboring particles j.
The pressure acceleration is given by:
The d_{ii}p_i value describes the displacement of particle i because of the particle i
and d_{ij}p_j describes the influence from the neighboring particles j.
Using this new values the linear system can be rewritten as
where the first sum over k loops over all neighbor particles of i and
the second sum over k loops over the neighbor particles of j
(which is a neighbor of i).
So the sum over the neighboring pressure values p_j also includes the pressure values
p_i, since i is a neighbor of j.
To separate this sum, it can be written as
With this separation, the equation for the linear system can again be rewritten as
In this formulation all coefficients that are getting multiplied with the pressure value p_i
are separated from the other. The diagonal elements a_{ii} can therefore be defined as:
The remaining part of the equation represents the influence of the other pressure values p_j.
Hence, the final relaxed Jacobi iteration takes the form:
Because interactions are local, limited to particles within the kernel support defined by
the smoothing length, each particle's pressure p_i depends only on its own value and
nearby particles.
Consequently, the matrix A is sparse (most entries are zero).
The diagonal elements a_{ii} get computed and stored at the beginning of the simulation step
and remain unchanged throughout the relaxed Jacobi iterations. The same applies for the
d_{ii}. The coefficients d_{ij} are computed, but not stored, as part of the calculation
of a_{ii}.
During the Jacobi iterations, two loops over all particles are performed:
The first updates the values of \sum_j d_{ij} and the second computes the updated
pressure values p_i^{l+1}.
The final pressure update follows the equation of the relaxed Jacobi scheme as stated above, with two exceptions:
To avoid negative pressure values, one can enable pressure clamping. In this case, the pressure update is given by
If the diagonal element a_{ii} becomes too small or even zero, the simulation may become
unstable. This can occur, for example, if a particle is isolated and receives little or no
influence from neighboring particles, or due to numerical cancellations. In such cases, the
updated pressure value is set to zero.
There are also other options, like setting a_{ii} to the threshold value if it is beneath
and then update with the usual equation, or just don't update the pressure value at all, and
continue with the old value. The numerical error introduced by this technique remains small,
as only isolated or almost isolated particles are affected.
The previously introduced formulation only considered interactions between fluid particles and neglected interactions between fluid and boundary particles. To account for boundary interactions, a few modifications to the previous equations are required.
First, the discretized form of the continuity equation must be adapted for the case in which
a neighboring particle is a boundary particle. From now on, we distinguish between
neighboring fluid particles (indexed by j) and neighboring boundary particles (indexed by
b).
The updated discretized continuity equation becomes:
Since boundary particles have zero velocity, the difference between the fluid
particle's velocity and the boundary particle's velocity simplifies to just the fluid
particle's velocity \bm{v}_{ib}(t+\Delta t) = \bm{v}_{i}(t+\Delta t).
Accordingly, the predicted density \rho^{\text{adv}} becomes:
This leads to the following updated formulation of the linear system:
Note that, since boundary particles are fixed, the force F_b^p is zero and does not appear in this equation.
The pressure force acting on a fluid particle is computed as:
This also leads to an updated version of the equation for the diagonal elements:
From this point forward, the computation of the coefficients required for the Jacobi scheme
(such as d_{ii}, d_{ij} etc.) depends on the specific boundary density evaluation method
used in the chosen boundary model.
When using pressure mirroring, the pressure value p_b of a boundary particle in the equation
above is defined to be equal to the pressure of the corresponding fluid particle p_i.
In other words, the boundary particle "mirrors" the pressure of the fluid particle interacting
with it. As a result, the coefficient that describes the influence of a particle's own
pressure value p_i must also include contributions from boundary particles. Therefore,
the equation for calculating the coefficient d_{ii} must be adjusted as follows:
The corresponding relaxed Jacobi iteration for pressure mirroring then becomes:
If pressure zeroing is used instead, the pressure value of a boundary particle p_b
is assumed to be zero. Consequently, boundary particles do not contribute to the pressure
forces acting on fluid particles.
In this case, the computation of the coefficient d_{ii} remains unchanged and is given by:
The equation for the relaxed Jacobi iteration remains the same as in the pressure mirroring approach. However, the contribution from boundary particles vanishes due to their zero pressure: