1 Introduction

Boundary handling is an important part of fluid simulation using smoothed particle hydrodynamics (SPH). There are several approaches to handle the interaction of SPH-based fluids with boundaries, i.e., particle-based [3], external boundary handling methods [18] or direct boundary integral methods [15].

In particle-based boundary handling, a particle’s density is usually calculated by taking all neighboring particles into account, i.e., fluid and boundary particles. Whereas including fluid particles in the neighborhood is a regular rule in SPH, including static boundary particles causes the wrong estimation of forces between fluid particles in the vicinity of boundaries, as we demonstrate in this paper. This yields distances between the fluid and the boundary that depend on the number of fluid particles and result in inconsistent fluid behavior and unintended fluid dynamics close to boundaries (see, for instance, Fig. 4).

In this paper, we first analyze the cause of the inconsistent fluid behavior close to boundaries, and we propose a new method for decoupled boundary density calculation, which divides the density calculation into the boundary-induced density and the fluid-induced density. While the first one takes only the neighboring boundary particles of a given fluid particle into account, the latter accounts for the interaction of a given fluid particle with its neighboring fluid particles.

We also propose a decoupled pressure calculation method, which alternates between the boundary-induced density and the fluid-induced density. This separation drastically reduces the overestimation of forces appearing in the standard coupled version and makes the fluid quantities more consistent across the complete fluid domain, e.g., it reduces residual oscillations caused by force overestimation.

In our experiments, we integrate our method with the IISPH solver [14] (in the variant by Band et al. [4]) using two types of boundary pressure estimators, i.e., pressure mirroring (PM) [3] and pressure boundaries (PB) [4]. Comparing the decoupled with the mixed methods, the decoupled approach demonstrates significant benefits in terms of residual oscillations, residual pressure and velocity, moreover, the decoupled method also brings more consistency across different pressure estimators.

We hypothesize that our decoupled approach can be combined with other schemes for estimating the density of the boundary particles, as well as to non-particle-based boundary handling schemes. This, however, requires further in-depth investigations.

2 Prior work

One of the first SPH approaches in fluid–boundary interaction is described by Monaghan [19], where the boundary is represented by particles and the interaction between fluid and boundary particles is ruled by the Lennard–Jones potential. Later, alternative methods of calculation of the forces between fluid and boundary particles have been proposed, such as direct forcing by Becker et al. [6] or pressure forces by Akinci et al. [3]. Modern approaches in boundary handling estimate pressure values for the boundary particles that yield forces and resulting accelerations for fluid particles that prevent penetration of fluid particles into the boundary [16, 17].

Several approaches to pressure calculation for boundary particles are used in computer graphics. The pressure mirroring (PM) method [3] estimates the pressure for a boundary particle by directly assigning the pressure of the currently interacting fluid particle. Other methods use a pressure extrapolation approach, where the boundary particles’ pressure is extrapolated based on the pressure and position of the neighboring fluid particles. Specifically, the pressure boundary (PB) method uses a separate pressure solver to estimate a unique pressure value for each boundary particle [4]. An alternative approach uses a moving least-squares pressure extrapolation to calculate the pressure at boundary particles, where the pressure values of the boundary particles correspond to the pressure values of the fluid particles in its vicinity [5].

Beyond particle-based boundary handling methods, other approaches have been proposed, such as direct forcing, directly applied to fluid particles that approach the boundary surface, superseding boundary particles [9], or direct reflection of the fluid particles from non-particle-based boundary [12]. Other approaches to non-particle-based boundary representation include the meshed-based method by Huber et al. [13], the distance function-based method by Harada et al. [11], the density maps by Bender et al. [8] and the semi-analytical boundary handling by Winchenbach et al. [23].

Almost all of these boundary handling methods perform density calculations to deduce pressure forces that prevent boundary penetration. These methods estimate the density using both, boundary- and fluid-induced densities simultaneously in a coupled way, leading to an overestimation of pressure and, hence, forces, and leads to the excess motion of the fluid particles; see detailed discussion in Sect 3.

Our approach of decoupled density estimation borrows from a similar concept proposed by Gissler et al. [10] applied in the context of boundary–boundary interactions, i.e., for rigid bodies collision reaction. For the calculation of regular SPH quantities, Gissler et al. [10] use standard “coupled” density estimation, while they exclude fluid particles when estimating forces between rigid objects.

3 Method

3.1 Problem statement

The main challenge regarding boundary handling in SPH is the calculation of forces induced by the boundary on the fluid particles. The boundary must have at least the property of impenetrability, i.e., the forces induced by the boundary must be large enough to push the approaching fluid particles back to prevent penetration.

Figure 1 depicts the interaction of a single fluid particle (highlighted with a dark blue outline) with neighboring fluid (blue) and boundary (yellow) particles, where blue and orange arrows represent interactions with fluid and boundary neighbors, respectively. Both types of interaction serve different goals, that is, the interaction with the boundary particles in the fluid particle’s neighborhood provides impenetrability, while the interaction with the neighboring fluid particles enables fluid dynamics.

Commonly in SPH, the calculation of the density and the pressure forces for the given fluid particle considers all neighboring fluid and boundary particles in a coupled fashion (see Fig. 1 left flowchart). However, this coupling of boundary and fluid interaction causes an overestimation of SPH quantities for both interactions. More precisely, the density and, subsequently, the repulsive pressure force between the given fluid particle and the boundary depend on the number of fluid neighbors in its proximity. Thus, an individual fluid particle without any fluid neighbors will have less density and will receive less repulsive pressure force than a fluid particle with some fluid neighborhood. In practice, this yields a varying distance between fluid particles and the boundary, where fluid particles with many fluid particle neighbors have a larger distance to the boundary surface than a fluid particle with few or no fluid particle neighbors (see Fig. 2). Likewise, the calculation of fluid–fluid pressure or other forces, e.g., surface tension and artificial viscosity, within the boundary interaction radius is affected by the overestimation of the fluid particle’s density due to boundary interaction, resulting in higher inter-fluid particle forces, and, hence, in unintended fluid dynamics.

Fig. 1
figure 1

Depiction of the fluid and boundary neighbors of the selected (bold blue line) fluid particle. Arrows represent an interaction between the selected fluid particle and its neighboring fluid particles (blue) and boundary particles (yellow). Blue lines represent interaction with fluid neighbors, and yellow arrows represent interaction with boundary particles. The left flowchart is the classical approach in density and pressure calculation, and the right flowchart depicts our decoupled approach

Fig. 2
figure 2

Comparison of the fluid–boundary distance for a single fluid particle (left) and a fluid sheet with several fluid neighbors using OpenMalstrom from [22]. The boundary particles and fluid particles are colored yellow and blue-purple, respectively. The lighter a fluid particle is, the higher the residual velocity of the particle. The top gray line shows the height of the fluid on the right

Algorithm 1
figure c

The decoupling algorithm

3.2 Decoupled boundary handling

In the following, we build upon the concept of artificial density introduced by Akinci et al. [2], which was later improved by Band et al. [4]. The concept of artificial density is additionally used to the regular density. Artificial density is dimensionless and represents the ratio between the current regular density \(\rho \) and the rest density \(\rho _0\), i.e., \(\rho _i^a=\rho /\rho _0\). Artificial density values \(\ge 1\), for example, result in an overcompression, yielding corresponding pressure forces.

First, we reformulate the artificial density calculation by separating it into three components:

$$\begin{aligned} \rho _i = \sum _j V_j \cdot W_{ij} = V_i \cdot W_{ii} + \sum _f V_f \cdot W_{if} + \sum _b V_b \cdot W_{ib} \end{aligned}$$
(1)

where i is the index of the current fluid particle, j is the index for all neighboring particles, f is the index for neighboring fluid particles, and b is the index for neighboring boundary particles. \(V_{i,j,f,b,}\) denote the rest volumes of the particles (similar to Band et al. [4]), and \(W_{ij}\) is the kernel value between particles i and j (likewise for indices fb). The first component in Eq. (1) is the “self-contribution” of the particle, the second component is a fluid neighbors’ contribution, and the third component is a boundary neighbors’ contribution.

For our method, we derive two densities. The fluid-induced density for the fluid particle i is calculated by omitting the boundary neighbor contribution

$$\begin{aligned} \rho ^f_i = V_i \cdot W_{ii} + \sum _f V_f \cdot W_{if}, \end{aligned}$$
(2)

and the boundary-induced density for the fluid particle i is calculated by omitting the fluid neighbors contribution component

$$\begin{aligned} \rho ^b_i = V_i \cdot W_{ii} + \sum _b V_b \cdot W_{ib}. \end{aligned}$$
(3)

Note that \(\rho _i \ne \rho ^f_i + \rho ^b_i\). The main idea of this separation is that \(\rho ^f_i\) represents the pure fluid–fluid interaction which is not affected by neighboring boundary particles, whereas \(\rho ^b_i\) represents the pure fluid–boundary interaction not affected by neighboring fluid particles.

Analogous to Band et al. [4], we use a constant boundary density \(\gamma \). However, as we use \(\gamma \) only for the boundary-induced density without considering fluid particles, we use a slightly reduced boundary density of \(\gamma =0.6\) instead of \(\gamma =0.7\) as proposed by Band et al. [4]. This adaptation is needed, as [4] defines the particle volume via the circumscribed cube, while we use the volume of the sphere. Moreover, we sample the boundary with less inter-particle distance.

Finally, the given iterative pressure solver is split into two stages, which are executed alternately, as shown in Alg. 1. The first stage comprises the calculation of the boundary pressure induced by fluid–boundary interaction using \(\rho ^b_i\), while the second stage calculates the fluid pressure induced by fluid–fluid interaction using \(\rho ^f_i\). For both stages, the error thresholds, lim\(_b\) and lim\(_f\), and the maximum number of iterations iter\(_{max}\) are used to control convergence. These calculations are alternatively executed until both of the errors, err\(_b\) and err\(_f\), are less than their thresholds or the number of global iterations \(iter_g\) is more than iter\(_{max}\). Note that the calculation of the current boundary pressure \(p_i^b\) requires the fluid-induced acceleration \(a_i^f\), and, correspondingly, the calculation of the current fluid pressure \(p_i^f\) requires the boundary induced acceleration \(a_i^f\). The initial fluid acceleration is taken from the non-pressure forces.

Fig. 3
figure 3

Resting fluid sheet experiment. The average height values over time (top) and the average velocity amplitude (bottom) are shown. The experiment is done for different sampling distances. The first 10 s are shown after the relaxation criteria have been reached

4 Results and evaluation

For the simulation, we use GPU-based open-source SPH framework openMaelstrom [22]. The radius of the fluid and boundary particles is set to 0.05 m which corresponds to approximately 0.1 m smoothing length. The constant \(\gamma \) for the density of the boundary particles is set to 0.6. For stabilization of fluid–fluid interaction, we use the artificial viscosity by Monaghan [20], with viscosity coefficient \(\alpha =0.05\). We, furthermore, use the surface tension model by Akinci [2], with a tension coefficient of \(\kappa =0.15\). For the discretization and simulation, we use Cubic spline kernel [20] and Spiky kernel gradient [21] for values and gradients, respectively. The gravity is set to \((0, 0, -9.8)^\top ~\text {m/s}^\text {2}\). In the experiments with resting fluids in Sects. 4.1, 4.2 and 4.5, we use regular rectangular samplings with varying spacing between boundary particles, while in experiments with fluid dynamics in Sects. 4.3, 4.4 and 4.6, we randomly sample the boundary and optimize the boundary particle positions using the method from Bell et al. [7] (with parameters: 100 impulse iterations, 0.01 impulse scale, 2 density). The rest density of the fluid is set to 1, 000 \(\text {kg/m}^\text {3}\). We use a fixed time step of 1 ms, which satisfies the CFL condition in all performed experiments. As the stopping limit for the fluid solvers, we use an average density error of \(0.0001\%\). For evaluation, we implemented the pressure mirroring (PM) [3] and the pressure boundary (PB) [4] methods, and we combined them with the IISPH solver in Band’s modification [4]. To initialize the experiments, we relax the fluid using the relaxation stopping criterion by Akhunov et al. [1]. All evaluations have been performed on an AMD Ryzen Threadripper 3970X CPU with 64 GB of RAM and an NVIDIA GeForce RTX 4090 GPU with 24 GB of VRAM.

In all experiments, we denote the standard and decoupled versions of PB and PM as PBS, PBD, PMS and PMD, respectively.

4.1 Resting fluid sheet

In this experiment, we compare standard and decoupled versions of the PB and PM boundary handling methods, where the fluid sheet stays relaxed. The fluid sheet consists of 508 fluid particles lying on the regularly sampled boundary surface. The results of the experiment are presented in Fig. 3 and Table 1. The stopping limit for the fluid solvers is mentioned above and used for all experiments below. We additionally vary the sampling distance between the boundary particles to investigate its influence on the particle height and stability. We use the term “sampling distance” as a ratio between the absolute distance between the neighboring boundary particles and the boundary particle diameter. We choose the sampling distances of 0.5, 0.6 and 0.7. For each distance, we measure the average height of the fluid over time and the average amplitude of velocity over time.

As can be seen from Fig. 3, the varying sampling distance changes both fluid height and fluid velocity for all methods. The larger the distance between boundary particles, the lower the height of the fluid. The decoupled versions of the methods, however, show a consistent height value for the PM and PB methods, while standard versions differ from each other significantly. Consequently, the standard coupled versions lead to different fluid heights and, hence, different fluid appearances and behavior. Moreover, the decoupled versions of the methods exhibit a noticeable reduction of the residual oscillations in average velocity for medium and coarser sampling distances.

The cost for less noise and consistent fluid–boundary distance is the number of iterations; see Table 1. For all sampling distances, the decoupled versions require more iterations than the standard, coupled versions, although the difference between the standard PM and the decoupled one is minimal.

Table 1 No motion fluid sheet experiment. Number of solver’s iterations before reaching the stopping limit

4.2 Resting fluid bulk

This experiment is similar to the prior experiment, but instead of the sheet, a bulk fluid in a container is simulated. The fluid bulk consists of 4684 fluid particles staying in the regularly sampled rigid container of sizes \(2\times 2\times 8\) m. The results of the experiment are presented in Fig. 4, Fig. 5 and Table 2, where the 2D histograms show the color-coded pressure and velocity distributions over time proposed by [1].

Figure 4 visualizes the residual velocity, which clearly indicates a high level of unwanted fluid dynamics. This is also underlined in the 2D histograms in Fig. 5, which indicates a significantly more homogeneous pressure and velocity distribution for the decoupled versions of the boundary handling methods. There is a significant decrease in the residual pressure and the residual velocity for both, particles at the boundary and in bulk. There is a significant difference in both, the pressure and the velocity distributions for PM, whose standard version is known to be very noisy [4]. The decoupled version of PM is less noisy compared to the standard one and even less noisy than the decoupled version of PB.

Fig. 4
figure 4

Resting fluid bulk experiment. Comparison of the pressure boundaries (PB\(*\)) and pressure mirroring (PM\(*\)) methods in their standard (\(*\)S) with the proposed decoupled (\(*\)D) implementations. The colormap encodes the velocity amplitude between 0 \(\text {m/s}\) (yellow) and 0.1 \(\text {m/s}\) (dark blue) 8 s after the fluid’s relaxation is completed

Fig. 5
figure 5

Resting fluid bulk experiment. The pressure and velocity histograms over time are presented. The measure of pressure and velocity is done for particles in bulk and for particles interacting with the boundary separately

Figure 4 visualizes the residual velocity amplitude for the fluid bulk experiment. It can be observed that the decoupling significantly reduces the residual velocity of the fluid particles close to the boundary and the free surface of the fluid.

As for the fluid sheet experiment in Sect. 4.1, the number of iterations and the average computation time for one frame for this experiment are higher for the decoupled versions, as depicted in Table 2. For PM, the difference in iterations is small, similar to the prior experiment.

Fig. 6
figure 6

Fluid sheet with tangential motion. The height values and the average velocity of the fluid particles during 8 s of sliding after the acceleration are shown

4.3 Fluid sheet with tangential motion

In the next experiment, we compare the standard and the decoupled methods for a fluid sheet in tangential motion over the boundary surface. We sample the boundary surface randomly and then optimize the location of the boundary particles using the method by Bell et al. [7]. The fluid sheet is relaxed according to Akhunov et al. [1], then accelerated in x-direction up to 1 \(\text {m/s}\), and, finally, it slides freely without external acceleration besides gravity. In Fig. 6, we present the first 10 s of the sliding sheet. Similar to the experiment of the resting fluid sheet in Sect. 4.1, the fluid height depends on the boundary handling method in the case of the standard version, while the height of decoupled versions is very similar. Over the time of 10 s, the average velocity decreases more quickly for the decoupled versions than for standard ones. This happens because of the reduced height of the fluid for the decoupled versions, i.e., the fluid lies closer to the boundary, and, hence, the boundary particle “features” cause more collisions with the fluid particles. These collisions dissipate the kinetic energy of the fluid particles.

Table 2 No motion bulk experiment. Number of solver’s iterations and average computation time for one frame

4.4 Released cylinder

Similar to the previous experiment in Sect. 4.3, this experiment investigates the influence of the decoupling on a fluid’s tangential motion. In this case, a fluid bulk is in a cylindrical container and after relaxation it is released, yielding more complex motion than in a single fluid sheet. The ground surface is sampled randomly and optimized with the method by Bell et al. [7]. The number of fluid particles is 103, 166. Due to the varying fluid–boundary distance, the height of the relaxed fluid depends on the boundary handling method and on the coupling/decoupling scheme applied; see Table 3, top row. Therefore, we enlarged the initial cylinder of 1 m radius to 3 m to achieve similar fluid heights, which leads to comparable potential energy in the system. In this case, the difference between heights is small, as it is shown in Table 3, bottom row.

Figure 7 depicts the top view of the scene 1 s after the fluid was released. It can be observed, that the advancing fluid front reaches slightly larger distances for the standard versions of the boundary handling methods than the distance reached by the decoupled version. This is due to the higher number of collisions with the boundary “features” as described in Sect. 4.3. Moreover, the advancing front of the fluid is slightly more jagged for the decoupled version, which reflects the more accurate interaction of the fluid with the boundary surface structure.

Table 3 Cylinder experiment. The height of the relaxed fluid bulk in a cylinder with a radius of 1 m and 3 m

4.5 Water jet passing a grid

Fig. 7
figure 7

Cylinder experiment. Top-down view of the distribution of the particles 1 s after cylinder release

Fig. 8
figure 8

Water jet passing a grid. The close-up of the jet interacting with the grid viewed from above (top row) and below (bottom row)

Fig. 9
figure 9

Water jet passing a grid with different resolutions. The same experiment as in Fig. 8, but comparing the initial particle sampling (top) with a double sampling (bottom)

In this experiment, a water jet is ejected on a grid with regular quadratic holes. The size of the holes is \(2\times 2\) particle diameter, and the rod width between the holes is also 2 particle diameter. We repeat the experiment with the same setup, but with a particle radius of 50% of the radius we used throughout the paper. The results are presented in Fig. 8 and Fig. 9.

The results show that both standard coupled approaches, PMS and PBS, allow only a limited amount of water to pass through the grid, while most of the fluid volume gets blocked and gathers on top of the grid. The decoupled versions, PMD and PBD, let the whole amount of liquid pass the grid and no fluid gathers on the grid. This different behavior results from the erroneous coupled density calculation, yielding an overestimated density force in the vicinity of fine boundary structures such as grid holes. Our decoupled density estimation method results in a proper passing of the water jet through the grid due to the consistent fluid–boundary distance.

Comparing the proposed method and the standard method for two different resolutions, as shown in Fig. 9, demonstrates the improved consistency of our approach. The results of our methods are as expected, i.e., specifically for PB, increasing the resolution retains the fluid structure and volume of the coarse resolution and adds fluid details. The standard methods exhibit a clearly increased fluid volume passing through the grid.

Note, we deliberately use a sphere rendering, as the variation of the particle resolution would require an adaptation of the iso-surface rendering parameters to achieve comparable fluid volumes.

Fig. 10
figure 10

Dragon dam break experiment. The state of the scene at 2s simulation time. The left bottom corner is a close-up of the dragon’s tail, and the right bottom corner is a close-up of the dragon’s front claw. Note both close-ups use different camera positions than the main view

4.6 Dragon dam break

The last experiment consists of a fluid volume of 745k fluid particles hitting a rigid dragon. The dragon is randomly sampled with 47k boundary particles and optimized with the method by Bell et al. [7]. The results of the experiment are presented in Fig. 10.

The main difference between the coupled and decoupled methods in Fig. 10 is that the coupled methods show much more splashy fluid behavior, which can be explained by unintended fluid motion near the boundary discussed in the “Resting Fluid Bulk” experiment in Sect. 4.2. The overestimation of the fluid–boundary forces leads to the overestimation of fluid particles’ velocity in the vicinity of the boundary and as a result brings an excess fluid motion, which in this case is a splashy fluid flow.

Some more subtle differences between the coupled and the decoupled method get visible around the fine details of the dragon. Some examples are shown in the insets in Fig. 10, showing close-ups of the dragon’s tail (bottom left) and dragon’s front claw (bottom right). These close-ups show that the decoupled density estimation yields a fluid flow that is significantly closer to the dragon in small cavities and that the flow bypasses the dragon’s volume more smoothly.

5 Discussion and limitations

Implementation The implementation of our method is straightforward and does not need any parameter tweaking and requires only the following steps: (1) separate calculation of boundary and fluid densities; (2) alternating calculation of the pressure forces based with respect to boundary density and fluid density, keeping the other quantity fixed. Note that such division of the pressure solver causes an increase in computational complexity and puts one on a trade-off between performance and stability.

Generalizability While we demonstrated our decoupled boundary handling for particle-based boundary representations only, our decoupling method can be applied to boundary handling approach for which the density estimations can be separated to achieve fluid and boundary contributions. In the case of boundary integrals, for example, the iteration over the boundary particles for the density estimation can be replaced by the boundary integral calculation. Based on this density, the boundary pressure can be calculated using the boundary integral. In principle, the decoupling algorithm remains unchanged.

Performance Table 1 states that our method demands more iteration to converge than the regular methods. For the PB method, the difference is quite significant; however, for the PM method the difference is tolerable and only mildly affects the overall simulation time and performance. Depending on the application, our method may demand a trade-off between computation time and consistent fluid behavior.

Convergence Although our method converges to the same value of the average density error, the residual fluid velocity in the vicinity of the boundary is much smaller, which makes the fluid behavior much more consistent between bulk regions and the regions near the boundary.

Fluid–boundary coupling So far, our method supports only one-way coupling between fluid and boundary, and further investigations are required to combine our decoupling approach with methods like the Akinci et al. [3] or Gissler et al. [10] to achieve two-way coupling.

6 Conclusion

In this paper, we propose a new method that decouples forces induced by fluid–fluid interactions and fluid–boundary interactions for SPH-based fluid simulations. The decoupling is realized by separately estimating the density and calculating pressure for fluid–fluid and fluid–boundary interactions. This method prevents the overestimation of fluid density near the boundary and prevents too large distances between the fluid particles close to the boundary and between fluid and boundary particles. Preventing density overestimation makes the fluid flow more accurate and consistent with the bulk flow close to the boundary and at narrow and detailed boundary features. For example, the flow through small holes can be simulated accurately, while for standard methods small holes become almost impenetrable. Moreover, the decoupling reduces the amplitude of residual pressure and velocity, and it yields fewer oscillations at free surfaces. As a drawback, our method requires a larger number of iterations to converge and requires more investigation toward two-way coupling between fluid and boundary.