Previous Article in Journal
Towards Secure and Adaptive AI Hardware: A Framework for Optimizing LLM-Oriented Architectures
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Position-Based Fluid Method with Dynamic Smoothing Length

School of Information and Software Engineering, East China Jiaotong University, Nanchang 330013, China
*
Author to whom correspondence should be addressed.
Computers 2026, 15(1), 11; https://doi.org/10.3390/computers15010011
Submission received: 20 November 2025 / Revised: 19 December 2025 / Accepted: 24 December 2025 / Published: 30 December 2025

Abstract

Traditional position-based fluid (PBF) methods often suffer from interpolation inaccuracies and limited computational efficiency due to their fixed smoothing length. To address these limitations, this paper proposes an adaptive smoothing length model and implements full-pipeline parallel acceleration on GPUs. By incorporating both local neighbor count and density variation, the model dynamically adjusts particle smoothing length. This adaptation effectively mitigates two issues: surface distortion due to insufficient interpolation in sparse regions, and performance degradation caused by computational redundancy in dense regions. To resolve neighbor search asymmetry introduced by dynamic smoothing lengths, we designed a symmetry handling technique based on maximum smoothing length and an efficient spatial hashing search algorithm. Experimental results across multiple scenarios (including dam break and droplet impact) demonstrate that our method maintains simulation stability comparable to the fixed smoothing length approach while improving computational efficiency and enhancing local particle distribution uniformity. The improved uniformity is evidenced by a significant reduction in the variance of neighbor particle counts. Visually, the method yields more natural results for dynamic details such as splashing and fragmentation, thereby ensuring the visual realism of the simulations.

1. Introduction

Fluid simulation methods can be broadly categorized into physically based and non-physically based approaches at a macroscopic level. Non-physically based methods rely on mathematical modeling and observational data without incorporating governing physical equations, which can lead to non-conservation of momentum and energy, thereby limiting their application in high-fidelity simulations.
Physically based methods discretize and solve the fluid governing equations [1], enabling a more accurate description of fluid behaviors. These are further divided into Eulerian and Lagrangian approaches. The Eulerian method, represented by fixed grids and finite difference schemes [2], characterizes fluid motion indirectly by describing field variations in spatial domains, avoiding the computational complexity associated with direct trajectory tracking. In contrast, Lagrangian particle methods discretize the fluid into particles carrying physical attributes, compute external and interaction forces, and solve for motion states and position updates according to Newton’s second law. Predominant methods include smoothed particle hydrodynamics (SPH) [3] and position-based fluids (PBF) [4], with this paper focusing primarily on the position-based fluid (PBF) method.
To enforce incompressibility, standard SPH and its weakly compressible variant WCSPH [5] typically employ stiff equations of state, which can induce excessive stress accumulation and exhibit high sensitivity to time steps [6,7]. To address this issue, Solenthaler and Pajarola [8] proposed predictive–corrective SPH (PCISPH), which progressively refines pressure estimates through Jacobi iterations, maintaining incompressibility while reducing time step dependency.
Bodin et al. [9] modeled incompressibility as a density constraint, formulating a linear complementarity problem solved via Gauss–Seidel iteration to achieve uniform density fluid simulation, though limited to linear systems. In comparison, position-based dynamics (PBD) methods can directly handle nonlinear constraints. PBD evaluates constraint errors and their gradients at the particle level through Jacobi iterations, correcting particle motion states to achieve stable solutions for nonlinear systems [10].
Müller et al. [11] introduced PBD to game physics simulations. This method utilizes Verlet integration, directly updates particle positions, and employs Gauss–Seidel iterations to solve nonlinear constraint systems, thereby avoiding numerical instabilities associated with force-based approaches. PBD offers controllable position corrections, effectively mitigating motion anomalies caused by excessive particle forces. Furthermore, it demonstrates superior adaptability to time steps compared to traditional SPH methods, maintaining simulation stability even with larger time increments.
However, the fixed smoothing length employed in conventional PBF methods exhibits inherent limitations under non-uniform particle distributions. Insufficient interpolation samples in sparse regions lead to surface distortion and density errors, while dense regions suffer from computational redundancy due to excessive neighboring particles, increasing simulation overhead, and losing flow details through kernel over-smoothing.
In adaptive smoothing length research, Zhu et al. (2020) proposed the ASLSPH method [12], which dynamically adjusts smoothing lengths to enhance time steps and simulation efficiency in SPH while maintaining numerical stability. Subsequently, Zeng et al. (2021) developed an adaptive SPH strategy based on density-weighted averaging of neighboring particles [13], effectively improving spatial distribution uniformity and achieving more homogeneous density fields. However, the application of adaptive smoothing length within the PBF framework remains underexplored. To address this gap, this paper proposes an adaptive smoothing length strategy successfully implemented in the PBF framework, significantly improving computational stability and simulation efficiency.
Regarding computational architecture, traditional CPU-based implementations face significant bottlenecks. The sequential processing nature of CPUs struggles to efficiently handle highly parallel tasks in large-scale particle systems, such as neighbor search and constraint solving. Particularly with increasing particle counts, the computational complexity of neighbor search grows dramatically, becoming a primary performance bottleneck [14]. Moreover, global dependencies during constraint solving require complex synchronization mechanisms on CPUs, further limiting real-time performance and scalability.
With advancements in Graphics Processing Unit (GPU) parallel computing capabilities, particle-based fluid simulation methods have achieved significant performance improvements [15]. The massively parallel architecture of GPUs is particularly suitable for handling computationally independent tasks among particles, such as neighbor search [16], constraint solving, and position updates.
The aforementioned challenges, this paper proposes a dynamic smoothing length model for PBF fluid simulation and implements full-pipeline parallel acceleration on GPUs. Our method adaptively adjusts particle smoothing lengths by integrating two key metrics: local neighbor particle count and density variation. This enhances interpolation accuracy in sparse regions while reducing computational redundancy in dense areas. To resolve neighbor relation asymmetry introduced by dynamic smoothing lengths, we design a symmetry handling mechanism based on maximum smoothing length and an efficient spatial hashing neighbor search algorithm. Experimental results demonstrate that our method maintains numerical stability across various scenarios (including dam breaks and falling droplets) while improving computational efficiency and achieving enhanced physical realism in dynamic fluid details.

2. Fluid Simulation Using the Position-Based Fluid (PBF) Method

2.1. Introduction to the Position-Based Fluid (PBF) Method

We adopt the following notation throughout this paper: h denotes the smoothing length, ρ is the density, ρ 0 is the rest density, d is the dimensionality ( d = 2 for 2D and d = 3 for 3D simulations), m is the particle mass (identical for all particles), Δ t is the time step, λi is the constraint scaling factor, and Δ p i is the position correction. Building upon the core principles of position-based dynamics (PBD), the position-based fluid (PBF) method primarily focuses on maintaining fluid incompressibility through a density constraint. This constraint ensures that the density of each particle stabilizes near the rest density ρ 0 . The density constraint function is jointly determined by the position of the particle itself and the positions of its neighboring particles. According to the definition in [9], the density constraint for the i-th particle can be expressed as
C i ( p 1 , , p n ) = ρ i ρ 0 1
where ρ 0 is the rest density, and ρ i is the density estimate derived from standard smoothed particle hydrodynamics (SPH). Specifically,
ρ i = m j W ( p i p j , h )
During simulation, all fluid particles are assumed to have identical mass. For smooth kernel calculations, the Poly6 kernel is employed for density estimation, while the Spiky kernel is utilized for density gradient estimation.
The objective of position-based dynamics (PBD) is to determine the position correction Δ p for particles. To achieve this, the density constraint is concretely formulated as follows:
C ( p + Δ p ) = 0
Since the gradient direction indicates the maximum rate of change in particle information, the particle position can be estimated along this direction. Using the Newton–Raphson method, the following formula is derived:
Δ p C ( p ) λ
C ( p + Δ p ) C ( p ) + C T Δ p C ( p ) + C T C λ = 0
In smoothed particle hydrodynamics (SPH), a kernel function for gradient operations is defined. When applied to each particle k, the gradient constraint function can be expressed as follows:
p k C i = 1 ρ 0 j p k W ( p i p j , h )
Depending on whether k is a neighboring particle, two distinct cases arise:
p k C i = 1 ρ 0 j p i W ( p i p j , h ) if   k = i p k W ( p i p j , h ) if   k = j
Substituting into Equation (6) yields the scaling factor λ for the constraint solution:
λ i = C i ( p 1 , , p n ) k p k C i 2
Under identical conditions, particles with identical properties exhibit consistent constraint behavior. Therefore, the constraint solution for each particle can be derived using Equation (8). However, due to the nonlinear characteristics of the density constraint function (1), vanishing gradients occur at the kernel boundary, leading to dispersed particle distribution in these regions. This causes the denominator (gradient) in Equation (8) to approach zero, resulting in the λ value tending toward infinity and consequently compromising simulation stability.
To address this issue, the predictive–corrective incompressible SPH (PCI-SPH) method introduces a correction factor related to neighbor particle count. The constraint force mixing (CFM) method adjusts constraints by incorporating additional constraint forces, specifically through augmenting the constraint function. Similarly, the position-based dynamics (PBD) method employs an analogous approach to mitigate particle instability at kernel boundaries. The formulation is as follows:
C ( p + Δ p ) C ( p ) + C T C λ + ε λ = 0
where ε is a constant, user-defined positive relaxation parameter, the formula for the modified scaling factor can be derived by substituting the gradient in Equation (7) and solving for λ:
λ i = C i ( p 1 , , p n ) k p k C i 2 + ε
The addition of a small positive ε to the denominator in Equation (10), compared to (8), serves to prevent numerical instability. This instability would otherwise arise from a zero denominator when particles approach separation, and the sum of the squared gradients becomes very small. Subsequently, the position correction λ i is updated based on its own density constraint Δ p i and the density constraints of its neighboring particles:
Δ p i = 1 ρ 0 j ( λ i + λ j ) W ( p i p j , h )
During SPH simulations, particles are prone to clustering phenomena. This occurs when a particle lacks sufficient neighboring particles to satisfy the density constraint, resulting in negative pressure that promotes particle clustering. To address this issue, a common approach is to introduce a non-negative force to counteract the negative pressure; however, this may weaken inter-particle cohesion and lead to particle dispersion. In 2011, Alduan and Otaduy proposed employing the discrete element method (DEM) to maintain inter-particle distances at half the kernel radius. Schechter and Bridson [17] suggested generating phantom forces on the free surfaces of particles. The PBF method adopts the approach introduced by Monaghan [18], which adds an attractive force within the smooth kernel range to pull all dispersed particles toward the kernel center. The surface tension calculation formula is expressed as follows:
s corr = k W ( p i p j , h ) W ( Δ q , h ) n
Within the surface tension correction logic of PBF fluid simulation, the parameter Δ q represents the fixed distance between particles within the smoothing kernel range and the kernel center, while   q   is a positive constant regulating correction intensity. Through multiple simulation experiments, it has been verified that optimal simulation results are achieved when: the particle-to-kernel-center distance falls within the 0.1 h to 0.3 h range, the positive constant k is set to 0.1, and the exponent n in the formula equals 4. This configuration effectively suppresses particle dispersion at kernel boundaries while avoiding fluid distortion caused by over-correction. By substituting the surface tension correction formula (i.e., the scorr calculation formula) into Equation (13), the modified constraint solution equation is obtained as follows:
Δ p i = 1 ρ 0 j ( λ i + λ j + s corr ) W ( p i p j , h )
During fluid simulation, to better approximate the physical characteristics of real fluids, the inherent viscosity of the fluid must be accounted for, as it affects momentum transfer between particles. Therefore, we employ the XSPH viscosity model to correct and update particle velocities. The specific calculation formula for XSPH is presented below, with the parameter c typically taking a value of 0.01.
v i new = v i + c j v i j W ( p i p j , h )

2.2. Framework of the Position-Based Fluid (PBF) Algorithm

The complete simulation pipeline of the standard PBF method is summarized in Algorithm 1. This algorithm outlines the core iterative procedure, which primarily consists of four stages: (1) force application and position prediction, (2) neighbor search, (3) iterative constraint solving (density correction), and (4) velocity update and final position integration. The following pseudo-code provides a detailed breakdown of these steps.
Algorithm 1. Position-Based Fluid (PBF) Simulation Procedure
For each particle i  do:
   | apply forces v i v i + Δ t f ext ( x i )  
   | predict position x i * x i + Δ t v i
End
For each particle i  do:
   | find neighboring particles N i ( x i * )
End
while (iter < solverIterations) do:
   | For each particle i  do:
   | calculate λ i
End
   | For each particle i  do:
      | calculate Δ p i
      | perform collision detection and response
   End
   For each particle i  do:
      | update position x i * x i * + Δ p i
   End
End while
For each particle i  do:
   | update velocity v i 1 Δ t ( x i * x i )
   | apply vorticity confinement and XSPH viscosity
   | update position x i x i *
End

3. Research on Dynamic Smoothing Length

3.1. Dynamic Smoothing Length Method

Both position-based fluids (PBF) and traditional smoothed particle hydrodynamics (SPH) methods typically employ a fixed smoothing length for neighbor search operations. However, non-uniform particle distribution introduces significant challenges: in sparse regions, insufficient neighboring particles lead to substantial interpolation errors, manifesting as anomalous droplet behavior and surface roughness in free-surface simulations; conversely, dense regions suffer from increased computational overhead due to excessive neighbors, which slows simulation speed. Furthermore, an oversized kernel weighting range tends to smooth out physical detail variations, compromising result fidelity.
To address these limitations, this paper implements three dynamic smoothing length update mechanisms:
The first approach utilizes neighbor particle count for dynamic adjustment, as this count effectively reflects local particle density. A low neighbor count indicates sparse regions (e.g., splashing droplets, surfaces, or boundaries), necessitating radius expansion, whereas excessive neighbors suggest high-density regions (e.g., fluid interior), requiring radius reduction.
The specific calculation method for the dynamic smoothing length in this strategy is given by Equation (15), where h 0 is the initially set smoothing length, d represents the dimensionality ( d = 2 for two-dimensional fluid simulation, d = 3 for three-dimensional fluid simulation), N i is the neighbor particle count of particle i , and N a v g is the arithmetic mean of the neighbor counts across all particles.
h i = h 0 N i N avg 1 d
N a v g = 1 N i = 1 N { j x i x j h , j i }
where N a v g is the arithmetic mean of the neighbor counts across all particles. This parameter exhibits sensitivity to both sparse and dense regions, enabling improved simulation efficiency while maintaining computational accuracy.
The second strategy dynamically adjusts the neighbor search radius based on the relationship between particle density and initial rest density. In the PBF method, the ratio of each particle’s density to its initial rest density (i.e., the density ratio) serves as a crucial indicator of local fluid state. Deviations from unity indicate compression or expansion of the fluid. When the ratio exceeds unity (indicating compression), the kernel radius is increased to encompass more particles, thereby improving the accuracy of density and pressure estimates. Conversely, when the ratio falls below unity (indicating expansion), the kernel radius is reduced to avoid incorporating distant particles, thus better capturing free surface effects.
The specific formula governing the particle smoothing length variation in this strategy is as follows:
h i = h 0 ρ i ρ 0 1 d
where ρ 0 is the rest density, and ρ i is derived from Equation (2).
The third strategy combines the previous two approaches, integrating both neighbor particle count and density ratio to dynamically adjust the smoothing length. This hybrid strategy enables finer adaptation to local fluid variations while ensuring numerical stability and physical accuracy. The smoothing length calculation formula is given below, where h 1 is obtained from Equation (15) and h 2 is derived from Equation (17):
h i = 2 h 1 h 2 / ( h 1 + h 2 )
This study employs dynamic smoothing lengths to dynamically adjust the interaction range, ensuring the number of neighboring particles per particle remains within a stable range, thereby enhancing the interpolation kernel approximation accuracy for each particle. However, the use of dynamic smoothing lengths may lead to the scenario depicted in Figure 1: particle i 1 possesses a smaller smoothing length, causing its support domain to exclude particle i 1 , while particle i 2 has a larger smoothing length, enabling its support domain to include particle i 1 . Without specialized treatment, direct computation under such conditions would violate Newton’s third law, resulting in erroneous force calculations. To address this, we design a corresponding neighbor search scheme and modified kernel functions to ensure algorithmic stability.

3.2. Neighbor Search Method for Dynamic Smoothing Length

In fluid simulations with dynamic smoothing lengths, particles with different smoothing lengths may encounter the neighbor asymmetry problem illustrated in Figure 2. Two primary methods exist to resolve this problem: The first approach utilizes the arithmetic mean of both particles’ smoothing lengths, where two particles are considered mutual neighbors when they satisfy d i j < ( h 1 + h 2 ) / 2 . The second method adopts the maximum smoothing length between particles, establishing neighbor relations when d i j < max R i , R j . Experimental verification demonstrates that the second method, using the maximum smoothing length as the effective radius for neighbor determination, introduces smaller computational errors. Consequently, this paper employs the second approach.
To enhance the efficiency of neighbor search, this paper employs a transient background grid method, selecting the maximum smoothing length among all particles as the grid cell size. This ensures any potential neighbor pair will be captured within adjacent grid cells. During particle neighbor search, instead of exhaustively matching all particles, the algorithm only needs to examine particles residing in the same grid cell and its immediate neighbors (9 cells in 2D scenarios, 27 cells in 3D scenarios). This optimization is valid because particles in other grid cells necessarily lie beyond the effective smoothing length range and cannot establish neighbor relationships.
Prior to neighbor search, all methods in this paper utilize spatial hashing with additional integer storage (index + hash + index table) to further improve search efficiency. As illustrated in Figure 2, this approach eliminates the need for exhaustive particle-by-particle searching, reducing computational complexity from O(N2) to O(Nlog2N), where N represents the total particle count. In practical applications with uniform particle distribution, each grid cell contains a roughly constant number of particles independent of the total count. Although the sorting and grid index establishment step remains O(Nlog2N) overall, the high efficiency of parallel sorting combined with constant-time neighbor searches (each particle checking only 27 cells) yields significant practical acceleration.

3.3. GPU Parallelization Method

Within the position-based fluid (PBF) algorithm, interactions between neighboring particles only require exchanging basic physical attributes, eliminating the need for complex coupled computations. In traditional CPU implementations, sequential loops typically compute physical state changes particle-by-particle, leading to linearly increasing computation time with growing particle counts. However, these computational characteristics make the PBF algorithm particularly suitable for GPU parallelization: firstly, the computational tasks, while intensive, maintain relatively simple logic; secondly, apart from interactions between neighboring particles, computations across different particles exhibit inherent independence. These features align perfectly with the requirements of GPU massively parallel architectures, providing an ideal computational foundation for efficient algorithm implementation.
In SPH method GPU frameworks [19], implementations can be categorized into partial pipeline acceleration and full-pipeline acceleration. Partial pipeline approaches only parallelize particle update procedures on GPUs, but their overall acceleration is constrained by frequent CPU-GPU data transfers [20], as illustrated in Figure 3. To achieve better speedup ratios, Domínguez et al. [21] subsequently implemented full-pipeline GPU acceleration encompassing neighbor search, particle interactions, and system updates. To obtain superior computational efficiency, this paper also employs full-pipeline GPU acceleration.

3.4. Algorithm Framework for Dynamic Smoothing Length in Position-Based Fluids

In the standard PBF algorithm (Algorithm 1), the smoothing length remains invariant throughout the simulation. When dynamic smoothing lengths are introduced, however, the timing of their update must be carefully integrated into the simulation loop to preserve consistency and numerical stability. The principal rationale is that the smoothing length must be refreshed prior to neighbor search, since the search phase relies on the current interaction radius to identify neighboring particles, and the subsequent constraint-solving stage depends on the neighbor relationships established therein. Consequently, in our dynamic smoothing length PBF method, the update is performed immediately after external forces are applied and before the position prediction step. This ordering guarantees that the neighbor search and all ensuing constraint evaluations employ a consistent, up-to-date smoothing length for each particle, thereby circumventing the neighbor asymmetry issues described in Section 3.2. The specific algorithmic procedure is outlined in Algorithm 2 below.
Algorithm 2. Dynamic Smoothing Length Simulation Procedure for Position-Based Fluids
For each particle i  do:
   | apply forces
   | adaptive smoothing length adjustment (new)
   | predict position
End
For each particle i  do:
   | find neighboring particles using adaptive smoothing length (modified)
End
while  (iter < solverIterations) do:
   | For each particle i  do
   |   | calculate λ with adaptive smoothing length (modified)
   | End
   | For each particle i  do:
   |   | calculate Δp with adaptive smoothing length (modified)
   |   | perform collision detection and response
| End
| For each particle i  do:
   |   | update position
   | End
End
For each particle i  do:
   | update velocity
   | update position
End

3.5. Analysis of Computational and Memory Overhead

While the proposed dynamic smoothing length method and full-pipeline GPU parallelization significantly enhance simulation accuracy and efficiency, they inevitably introduce additional computational and memory overhead. A candid analysis of these costs is essential for a comprehensive understanding of the method’s applicability.
The dynamic smoothing length mechanism itself requires extra computational steps. In each simulation step, beyond the standard PBF pipeline, our approach necessitates (1) computing the adaptive smoothing length for each particle (according to Equations (15), (17), or (18)); (2) constructing a unified background grid for neighbor search based on the maximum smoothing length among all particles (Section 3.2), as the smoothing length is variable. This may lead to particles in sparse regions performing neighbor retrieval within a spatial range slightly larger than strictly necessary. Compared to the fixed-length approach, the hybrid strategy (GPU4) incurs the highest overhead due to the simultaneous evaluation of both neighbor count and density ratio. However, as demonstrated by the experiments in Section 4, this additional cost is offset by a substantial reduction in superfluous neighbor computations within dense regions and a decreased iteration convergence time for constraint solving owing to more uniform particle distribution. Consequently, the overall performance yields a net gain.
The primary memory overhead in the GPU parallel implementation stems from particle state storage and neighbor lists. In our implementation, each particle requires storage for attributes such as its current position, predicted position, velocity, density, and smoothing length. The dynamic smoothing length itself adds only one `float` datum per particle. The main memory challenge arises from irregular memory access patterns. Since inter-particle interaction relationships change dynamically with the smoothing length, access to global memory cannot always maintain a perfectly coalesced state, potentially reducing memory bandwidth utilization.

4. Experimental Results and Analysis

To enhance the robustness of the dynamic smoothing length algorithm and improve fluid simulation stability, the particle kernel radius R i in our proposed dynamic method is constrained to the range [ 0.5 h 0 , 2 h 0 ] where h0 is the initial smoothing length. This bound is chosen based on a trade-off among numerical stability, physical plausibility, and computational efficiency: the lower limit 0.5 h 0 prevents insufficient neighbor particles and distorted density estimates that would result from an excessively small smoothing length, while the upper limit 2 h 0 avoids computational redundancy and over-smoothing of physical details. The selected interval aligns with empirical variation ranges commonly used in SPH-type methods, maintaining interpolation accuracy in sparse regions and controlling computational cost in dense regions. Through multiple comparative experiments—such as dam break and falling droplet scenarios—we verified that this range preserves simulation stability and visual realism. Tests with wider or narrower intervals (e.g., [ 0.3 h 0 , 2 h 0 ] further indicate that exceeding the proposed bounds tends to introduce numerical instability near interfaces or degrade performance, confirming that the current choice strikes a good balance between efficiency and robustness. In contrast, the fixed smoothing length method employs a constant value of R 0 = 2 h 0 throughout the simulation.

4.1. Implementation Environment

To ensure the reliability and fairness of the experiments, all tests in this study employ the hardware configuration specified in Table 1. To establish a clear baseline, the CPU version is implemented as a single-threaded process. Furthermore, to guarantee a fair comparison among GPU implementations, all GPU variants (GPU1–GPU4) share identical kernel structures, memory layouts, and optimization strategies; the only difference lies in their smoothing length update logic. This ensures that any observed performance differences are solely attributable to the adaptive smoothing length strategies rather than implementation discrepancies.
Key simulation parameters are set as follows: The gravitational acceleration is set to 9.8 m/s2 across all scenarios in this experiment. These parameter choices are consistent across all compared methods, enabling a direct and meaningful evaluation of the impact of smoothing length adaptation.

4.2. Neighbor Variance Comparison

The dynamic smoothing length demonstrates superior performance over the fixed smoothing length in controlling neighbor count variance. This is attributed to its adaptive adjustment mechanism, which maintains the number of neighbors around each particle within a more stable range. Within the experimental framework of position-based fluids (PBF), this study conducts a comparative analysis of the fixed smoothing length method and three adaptive smoothing length strategies—based on neighbor particle count, density variation, and a combination of both—for a falling droplet scenario with 300,592 particles and a dam break scenario with 221,100 particles. The analysis focuses on the variance of neighbor counts (denoted as variance1–variance4) under these different methods. Figure 4 illustrates the evolution of neighbor-count variance over the course of the simulation (steps 0–300). The vertical axis denotes the variance of neighbor counts, while the horizontal axis corresponds to the simulation step index, and the time step for the falling droplet scenario is set to   Δ t = 0.020 s .
As shown in Figure 4, all three dynamic smoothing length methods demonstrate significantly lower particle neighbor count variance compared to the fixed smoothing length approach. This indicates that dynamic smoothing length can effectively maintain the stability of global particle neighbor distribution, thereby enhancing numerical stability and reliability during simulation.
For the dam break scenario with 221,100 particles, we configured identical time steps ( Δ t = 0.010 s ) across all four methods. The evolution of neighbor count variance across simulation steps (0–600) is presented in Figure 5. The results show that in the dam break scenario, all three dynamic smoothing length methods maintain lower neighbor variance than the fixed-length approach. Particularly, the hybrid adaptive smoothing length method consistently achieves the lowest variance among all methods, demonstrating its superior capability in maintaining homogeneous density distribution throughout the fluid domain.

4.3. Visualization Analysis of Fluid Density Distribution

To intuitively evaluate the performance of different methods in terms of density distribution, we generated density cloud maps to compare the density fields of the fixed smoothing length method (GPU1) and the three dynamic smoothing length strategies (GPU2, GPU3, GPU4) in a falling droplet scenario (particle count N = 300,592, time step   Δ t = 0.020 s ). As shown in Figure 6 and Figure 7, at t = 2.4 s, the fixed smoothing length method (GPU1) exhibits noticeable density voids (blue regions) in splashing particle areas, indicating insufficient interpolation support. The neighbor-count-based dynamic method (GPU2) improves density continuity in sparse regions. The density-ratio-based method (GPU3) demonstrates smoother density transitions near the free surface. The hybrid strategy (GPU4) combines the advantages of both, enhancing the representation of dynamic details while maintaining overall density uniformity.

4.4. Free-Surface Simulation

This study establishes a falling droplet simulation scenario to systematically compare and analyze the performance of fixed smoothing length against three adaptive smoothing length methods in terms of simulation efficiency: neighbor-count-based, density-variation-based, and the hybrid approach incorporating both neighbor count and density variation. Under consistent software and hardware environments, simulation tests were conducted with three distinct particle resolutions, followed by systematic evaluation and comparison of computational performance.
As shown in Table 2, the performance assessment covers five implementations: CPU (fixed smoothing length), and four CUDA-accelerated GPU implementations—GPU1 (fixed smoothing length), GPU2 (neighbor-count-based adaptive smoothing length), GPU3 (density-variation-based adaptive smoothing length), and GPU4 (hybrid adaptive smoothing length considering both factors). The evaluation metrics include the particle count, the average simulation time per step (tsim), and the speed-up ratio relative to the CPU implementation. Specifically, tsim is measured by recording the duration of 100 consecutive simulation steps after the system reaches a steady state (starting from the simulation time t = 0.4 s), with a time step size of Δt = 0.02 s (corresponding to a total duration of 2.4 s), and then calculating the mean value. These metrics together provide a comprehensive measurement of the computational efficiency of each method.
Based on the experimental results presented in Table 2, it can be concluded that the dynamic smoothing length method employed in this study, when parallelized with CUDA, demonstrates significantly higher computational efficiency compared to the parallel implementation using a fixed smoothing length.

4.5. Dam Break Simulation

To ensure the rigor and reliability of our research conclusions, this study further employs the dam break scenario as a benchmark for comparative analysis, systematically evaluating the computational efficiency of adaptive smoothing length methods against fixed smoothing length approaches, thereby validating the superiority of the proposed method. As demonstrated by the dam break simulation results in Table 3, where the computational efficiency metrics were obtained by recording the duration of 100 consecutive simulation steps after the system reached a steady state (starting from the simulation time t = 1.0 s), with a time step of Δt = 0.01 s (corresponding to a total duration of 1.0 s), the adaptive smoothing length method proposed in this paper achieves significantly higher computational efficiency compared to fixed smoothing length methods. Furthermore, as particle count increases, the speed-up advantage of our method on GPU platforms becomes increasingly pronounced.

4.6. Analysis of Million-Particle Simulation Experiments

In Table 4, after the simulation reaches a steady state, we select 1000 consecutive time steps from t = 1 s to t =2 s (corresponding to a simulation time step size of Δt = 0.001 s) and compute the average simulation time tsim for each time step, the experimental results indicate that in large-scale simulations of falling droplets with nearly 2 million particles, the performance gain provided by the adaptive smoothing length levels off. We attribute this primarily to the following three factors: First, in simulations of such a large scale, the fixed smoothing length method already approaches or saturates the GPU memory bandwidth limit. Although the adaptive strategy reduces computational load, this benefit is partially offset by the irregular memory access patterns it introduces. Second, as the particle count increases dramatically, the fluid domain becomes statistically more homogeneous, which naturally diminishes the potential scope for meaningful adaptive adjustment of the smoothing length. Finally, the dynamic smoothing length mechanism itself incurs additional overhead for inter-particle synchronization and grid reconstruction. These overheads become particularly pronounced in large-scale simulations and further constrain the achievable performance improvement.

4.7. Visual Results

To provide a visual comparison of the different smoothing length strategies, this section presents simulation results for three typical scenarios. The analysis focuses on the level of splash detail, the number and distribution of fragments, and surface smoothness. All scenarios are simulated with a uniform time step of   Δ t = 0.020 s , and visual comparisons are made at key frames.
This section compares the visual performance of the three smoothing length strategies in typical scenarios, with a focus on splash detail, fragment count and distribution, and surface smoothness. All scenarios use a uniform time step, and visual comparisons are made at key frames. Figure 8 shows the visual evolution of the four methods in a falling droplet scenario (particle count N = 300,592) at t = 0 s, 0.8 s, 1.2 s, and 2.4 s. In the early stages (t = 0.8 s, 1.2 s), the fixed smoothing length method (GPU1) exhibits constrained splashing and particle clustering, whereas the dynamic smoothing length methods (GPU2, GPU3, GPU4) produce more dispersed and realistic splash patterns. The most pronounced visual difference appears in the final stage (t = 2.4 s). Here, the hybrid dynamic smoothing length strategy (GPU4) yields denser splash particles and richer fragment details, visibly outperforming the fixed-length method and the other two adaptive strategies. While maintaining a smooth main liquid surface, this approach forms a wider and more structured splash morphology that most closely resembles real liquid impact.
Thus, dynamic smoothing lengths effectively enhance splash realism. Among the strategies, the hybrid strategy (GPU4) demonstrates superior particle abundance and fragmentation detail in the later simulation stages, resulting in more natural morphology and visual coherence.
Figure 9 compares the four methods in a dam break simulation with 203,665 particles ( Δ t = 0.010 s ) at four time points: t = 0 s, 0.6 s, 1.8 s, and 2.4 s.
At t = 0 s (initial state), all methods start from the same static fluid behind the dam. By t = 0.6 s and t = 1.8 s, after the dam collapses, the overall flow patterns remain largely similar across the different approaches.
The most pronounced visual differences appear at t = 2.4 s. With the fixed smoothing length (GPU1), the splash remains constrained—fragmented particles are fewer and tend to cluster, the main liquid surface appears somewhat uneven, and the motion lacks fine dynamic detail. In contrast, the dynamic smoothing length approach, particularly the hybrid strategy (GPU4), yields a markedly richer outcome: the splash is finer and more dispersed, resembling a mist-like spray; fragmentation increases, with many small droplets distributed over a wider area; while the main fluid body retains a smooth surface and exhibits these details. This result aligns more closely with the dispersion behavior of a real liquid under high-speed impact.
In the Stanford bunny falling scenario shown in Figure 10 (particle count N = 183,113, time step   Δ t = 0.010 s ), a visual comparison is made at four key instants: t = 0 s, 0.8 s, 1.2 s, and 2.4 s. By t = 2.4 s, the dynamic smoothing length method preserves richer visual details: finer ejected particles remain suspended in the air—closer to the inertial motion of real droplets—and the remaining fragments are distributed more naturally, avoiding the clustering observed with GPU1. In contrast, the fixed smoothing length approach (GPU1) produces a more restrained splash, with limited particle dispersion and morphological detail.

4.8. Strategy Comparison and Applicable Scenarios

The three dynamic smoothing length strategies proposed in this work exhibit distinct behaviors, each suited to specific simulation scenarios.
The neighbor-count-based strategy (denoted as GPU2) adjusts the smoothing length according to the local particle density. It incurs the smallest computational overhead and effectively stabilizes the variance in particle neighbor counts (as shown in Figure 4 and Figure 5). This makes it well-suited for scenarios where particle distribution is uneven but strict density consistency is not critical, offering high computational efficiency.
The density-ratio-based strategy (GPU3) directly responds to the compression or expansion state of the fluid. In our visual comparisons, it tended to produce more numerous and finer splash particles compared to the fixed-length method. However, because it requires real-time density evaluation, it introduces additional computational cost.
The hybrid strategy (GPU4) integrates both neighbor-count and density-ratio information. In most tested scenarios, it achieves the best balance between computational efficiency and physical realism (see Table 2 and Table 3). Its advantages are especially pronounced in complex dynamic scenes where both particle distribution and fluid state change violently—e.g., dam break or object-entry simulations. Nevertheless, this strategy is also the most complex to implement.
In practice, if the priority is real-time performance and high efficiency, the neighbor-count-based strategy is recommended. If high-fidelity surface physics is the main goal, the neighbor-count-based strategy is more suitable. For applications that require both large-scale computational efficiency and high-quality visual output, the hybrid strategy is the preferred choice.

5. Conclusions

This study addresses the limitations of traditional position-based fluid (PBF) methods, namely, restricted interpolation accuracy and suboptimal computational efficiency caused by fixed smoothing lengths by proposing a fluid simulation method based on dynamic smoothing lengths and implementing full-pipeline parallel acceleration on GPUs. We developed an adaptive smoothing length model that integrates neighbor particle count and density variation, enabling dynamic adjustment of particle smoothing lengths according to local fluid characteristics. This effectively improves interpolation accuracy in sparse regions and reduces computational redundancy in dense areas. To resolve neighbor relation asymmetry introduced by dynamic smoothing lengths, we proposed a symmetry strategy based on maximum smoothing length, combined with spatial hashing and GPU-accelerated search techniques to achieve efficient and stable neighbor retrieval. Furthermore, the entire PBF pipeline—including neighbor search, constraint solving, and state updates—was fully deployed on GPUs to construct a comprehensive parallel simulation framework.
Experimental results across multiple typical scenarios, such as dam breaks and falling droplets, demonstrate that the proposed method significantly enhances computational efficiency while maintaining numerical stability. Neighbor count variance analysis further validates the method’s advantages in system stability from a numerical perspective.
Although the proposed dynamic smoothing length method demonstrates higher computational efficiency and clearer visual effects across various scenarios, it is important to acknowledge its limitations. The adaptive strategy presented in this paper may exhibit short-term instability before the smoothing length fully adapts in cases with extremely sparse distributions or rapidly changing conditions. This could temporarily affect the instantaneous accuracy of density estimation near evolving interfaces. Additionally, while our GPU-based implementation achieves significant performance gains, it remains constrained by the specific hardware’s memory bandwidth and parallel occupancy. When the number of particles reaches the order of millions, overheads in data transfer and synchronization may emerge as new bottlenecks.
For future work, there is potential for further optimization in GPU parallel computing, such as exploring the introduction of multi-GPU support [22] to enable higher-resolution simulations and achieve more significant acceleration. Additionally, cutting-edge deep learning techniques could be integrated to enhance the accuracy and efficiency of fluid simulations [23,24,25].

Author Contributions

Conceptualization, C.Z. and X.L.; Methodology, C.Z. and X.L.; Software and Validation, X.L.; Writing—Original Draft Preparation, X.L.; Writing—Review and Editing, C.Z. and X.L.; Supervision, C.Z. All authors have read and agreed to the published version of the manuscript.

Funding

National Natural Science Foundation of China (No. 62162027); Humanities and Social Sciences Research Project of Jiangxi Universities (JC24205); Innovation and Entrepreneurship Education Research Project of East China Jiaotong University (24hjct18).

Institutional Review Board Statement

Not applicable. This study did not involve humans or animals.

Data Availability Statement

The experimental portion of this paper contains simulation data analyzed during this study. The data generated during the current study are not publicly available, as key parts of this code will affect subsequent research, but are available from the corresponding author upon reasonable request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Stam, J. Stable fluids. In Proceedings of the 26th Annual Conference on Computer Graphics and Interactive Techniques, Los Angeles, CA, USA, 8–13 August 1999; ACM Press: New York, NY, USA; Addison-Wesley Publishing Co.: Carrollton, TX, USA, 1999; pp. 121–128. [Google Scholar]
  2. LeVeque, R.J. Finite Difference Methods for Ordinary and Partial Differential Equations: Steady-State and Time-Dependent Problems; SIAM: Philadelphia, PA, USA, 2007. [Google Scholar]
  3. Antoci, C.; Gallati, M.; Sibilla, S. Numerical simulation of fluid-structure interaction by SPH. Comput. Struct. 2007, 85, 879–890. [Google Scholar] [CrossRef]
  4. Müller, M.; Charypar, D.; Gross, M. Particle-based fluid simulation for interactive applications. In Proceedings of the ACM SIGGRAPH/Eurographics Symposium on Computer Animation, San Diego, CA, USA, 26–27 July 2003; ACM Press: New York, NY, USA, 2003; pp. 154–159. [Google Scholar]
  5. Becker, M.; Teschner, M. Weakly Compressible SPH for Free Surface Flows. In Proceedings of the 2007 ACM SIGGRAPH/Eurographics Symposium on Computer Animation, San Diego, CA, USA, 2–4 August 2007; Eurographics Association: Eindhoven, The Netherlands, 2007; pp. 209–217. [Google Scholar]
  6. Violeau, D.; Rogers, B.D. Smoothed particle hydrodynamics (SPH) for free-surface flows: Past, present and future. J. Hydraul. Res. 2016, 54, 1–26. [Google Scholar] [CrossRef]
  7. Alduan, I.; Otaduy, M.A. SPH Granular Flow with Friction and Cohesion. In Proceedings of the 2011 ACM SIGGRAPH/Eurographics Symposium on Computer Animation, Vancouver, BC, Canada, 5–7 August 2011; ACM: New York, NY, USA, 2011; pp. 25–32. [Google Scholar]
  8. Solenthaler, B.; Pajarola, R. Predictive-corrective incompressible SPH. ACM Trans. Graph. 2009, 28, 1–6. [Google Scholar] [CrossRef]
  9. Bodin, K.; Lacoursiere, C.; Servin, M. Constraint Fluids. IEEE Trans. Vis. Comput. Graph. 2012, 18, 516–526. [Google Scholar] [CrossRef] [PubMed]
  10. Wei, Q. Fluid Simulation Based on Position-Based Dynamics Framework. Mod. Comput. Prof. Ed. 2018, 25, 66–70. [Google Scholar]
  11. Macklin, M.; Müller, M. Position based fluids. ACM Trans. Graph. 2013, 32, 1–12. [Google Scholar] [CrossRef]
  12. Zhu, J.; Li, H.; Cai, R.; Chen, B.F. An SPH liquid simulation method based on adaptive smoothing length. Comput. Appl. Res. 2020, 37, 2871–2875. (In Chinese) [Google Scholar]
  13. Zeng, R. An Adaptive SPH Method Based on Neighbor Particle Density-Weighted Average. Master’s Thesis, Guangdong University of Technology, Guangzhou, China, 2021. (In Chinese). [Google Scholar]
  14. Zhou, P.; Jin, A. Application of GPU neighbor search method in SPH algorithm for aeolian sand flow. Comput. Appl. Softw. 2025, 42, 221–226. (In Chinese) [Google Scholar]
  15. Xing, X.; Peijie, S.; Huahai, Z.; Wang, L.M. Parallel Implementation of Three-Dimensional Lattice Boltzmann Method on Multi-GPU Platforms. Front. Data Comput. 2025, 7, 16–27. [Google Scholar]
  16. Yan, X. Research on GPU-Accelerated SPH with Improved Linked-List Search and Its Application to Free Surface Flow. Master’s Thesis, Guangxi University, Nanning, China, 2024. (In Chinese). [Google Scholar]
  17. Schechter, H.; Bridson, R. Ghost SPH for Animating Water. ACM Trans. Graph. (TOG) 2012, 31, 61. [Google Scholar] [CrossRef]
  18. Monaghan, J.J. SPH without a Tensile Instability. J. Comput. Phys. 2000, 159, 290–311. [Google Scholar] [CrossRef]
  19. Dominguez, J.M.; Crespo, A.J.C.; Gómez-Gesteira, M. Optimization strategies for CPU and GPU implementations of a smoothed particle hydrodynamics method. Comput. Phys. Commun. 2013, 184, 617–627. [Google Scholar] [CrossRef]
  20. Goswami, P.; Schlegel, P.; Solenthaler, B.; Pajarola, R. Interactive SPH simulation and rendering on the GPU. In Proceedings of the Eurographics/ACM SIGGRAPH Symposium on Computer Animation, Madrid, Spain, 2–4 July 2010; ACM Press: New York, NY, USA, 2010; pp. 55–61. [Google Scholar]
  21. Yan, X.; Long, T. Numerical Simulation of Dam Break Energy Dissipation Using SPH-GPU Parallel Method with Improved Linked-List Search. Water Resour. Power 2025, 43, 133–137+99. [Google Scholar] [CrossRef]
  22. Xu, A.; Li, B.T. Multi-GPU thermal lattice Boltzmann simulations using OpenACC and MPI. Int. J. Heat Mass Transf. 2023, 201, 123649. [Google Scholar] [CrossRef]
  23. Deng, Y.T.; Zhang, X.R.; Su, Z.J.; He, Q.L. Application of Deep Learning Methods in Computational Fluid Dynamics. J. Sichuan Univ. Nat. Sci. Ed. 2025, 62, 1254–1264. [Google Scholar] [CrossRef]
  24. Zhou, H.A.; Cheng, L.; Shi, K.Q.; Ou, M.Y.; Zhu, H.N. Unsteady Fluid Prediction Based on Multi-Task Graph Neural Network. Sci. Technol. Eng. 2024, 24, 11733–11740. [Google Scholar]
  25. Meng, W.; Mei, G. Machine Learning-Based VOF Method for Two-Dimensional Fluid Simulation. Shipbuild. China 2024, 65, 244–253. [Google Scholar]
Figure 1. Comparison of particle interaction domains with fixed and dynamic smoothing lengths. Black dots represent fluid particles. Red dots denote specific target particle, labeled i, i1 and i2. Dashed circles outline their respective interaction domains. Arrows indicate the magnitude of the smoothing length h: a single value h for the fixed case, and two distinct values h1 and h2.
Figure 1. Comparison of particle interaction domains with fixed and dynamic smoothing lengths. Black dots represent fluid particles. Red dots denote specific target particle, labeled i, i1 and i2. Dashed circles outline their respective interaction domains. Arrows indicate the magnitude of the smoothing length h: a single value h for the fixed case, and two distinct values h1 and h2.
Computers 15 00011 g001
Figure 2. Spatial hashing neighbor search algorithm. Green circles represent particles (labeled 0–9). Numbers indicate the hash indices of grid cells (0–9). Arrows illustrate the index mapping between data structures.
Figure 2. Spatial hashing neighbor search algorithm. Green circles represent particles (labeled 0–9). Numbers indicate the hash indices of grid cells (0–9). Arrows illustrate the index mapping between data structures.
Computers 15 00011 g002
Figure 3. Comparison of different GPU pipelines.
Figure 3. Comparison of different GPU pipelines.
Computers 15 00011 g003
Figure 4. Variation in neighbor variance for four methods in a falling droplet scenario. Color key: Blue, fixed. Orange, neighbor-count-based. Green, density-ratio-based. Red, hybrid.
Figure 4. Variation in neighbor variance for four methods in a falling droplet scenario. Color key: Blue, fixed. Orange, neighbor-count-based. Green, density-ratio-based. Red, hybrid.
Computers 15 00011 g004
Figure 5. Variation in neighbor variance for four methods in a dam break scenario. Color key: Blue, fixed. Orange, neighbor-count-based. Green, density-ratio-based. Red, hybrid.
Figure 5. Variation in neighbor variance for four methods in a dam break scenario. Color key: Blue, fixed. Orange, neighbor-count-based. Green, density-ratio-based. Red, hybrid.
Computers 15 00011 g005
Figure 6. Density–height cloud map for the falling droplet scenario. The circular structures denote the falling droplet; the color bar corresponds to the density magnitude, with warmer colors indicating higher density.
Figure 6. Density–height cloud map for the falling droplet scenario. The circular structures denote the falling droplet; the color bar corresponds to the density magnitude, with warmer colors indicating higher density.
Computers 15 00011 g006
Figure 7. The xy-slice density cloud map for the falling droplet scenario. The circular structures denote the falling droplet; the color bar corresponds to the density magnitude, with warmer colors indicating higher density.
Figure 7. The xy-slice density cloud map for the falling droplet scenario. The circular structures denote the falling droplet; the color bar corresponds to the density magnitude, with warmer colors indicating higher density.
Computers 15 00011 g007
Figure 8. Fluid simulation in a falling droplet scenario.
Figure 8. Fluid simulation in a falling droplet scenario.
Computers 15 00011 g008
Figure 9. Fluid simulation in a dam break scenario.
Figure 9. Fluid simulation in a dam break scenario.
Computers 15 00011 g009
Figure 10. Fluid simulation with a falling Stanford bunny.
Figure 10. Fluid simulation with a falling Stanford bunny.
Computers 15 00011 g010
Table 1. Performance parameters of CPU and GPU.
Table 1. Performance parameters of CPU and GPU.
DeviceModelCore CountMemory (GB)Clock Frequency (GHz)Compute Capability
CPUAMD Ryzen 7 4800H8162.9-
GPUGTX 165089641.497.5
Table 2. Computational efficiency comparison at different particle resolutions in a falling droplet scenario.
Table 2. Computational efficiency comparison at different particle resolutions in a falling droplet scenario.
Simulation MethodsParticletsim/msSpeed-Up
CPU56,3391332.02
GPU125.3052.63
GPU219.4668.42
GPU324.3354.73
GPU418.2972.80
CPU300,5927851.63
GPU1126.5162.05
GPU299.9378.56
GPU3117.2066.99
GPU484.3493.08
CPU592,56515,715.73
GPU1230.7068.11
GPU2195.0180.58
GPU3226.9969.23
GPU4177.7288.42
Table 3. Computational efficiency comparison at different particle resolutions in a dam break scenario.
Table 3. Computational efficiency comparison at different particle resolutions in a dam break scenario.
Simulation MethodsParticletsim/msSpeed-Up
CPU58,9601438.84
GPU125.7155.95
GPU224.1259.62
GPU324.8357.93
GPU421.8865.76
CPU203,6655464.48
GPU189.7460.89
GPU279.9368.36
GPU387.7162.3
GPU468.8579.36
CPU407,88510,587.29
GPU1155.3768.14
GPU2141.8474.64
GPU3146.9972.02
GPU4131.8480.30
Table 4. Computational efficiency comparison for four million particles in a falling droplet scenario.
Table 4. Computational efficiency comparison for four million particles in a falling droplet scenario.
Simulation Methods∆tParticletsim/ms
GPU10.0011,948,712862.07
GPU20.001828.50
GPU30.001840.47
GPU40.001709.22
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Zou, C.; Li, X. A Position-Based Fluid Method with Dynamic Smoothing Length. Computers 2026, 15, 11. https://doi.org/10.3390/computers15010011

AMA Style

Zou C, Li X. A Position-Based Fluid Method with Dynamic Smoothing Length. Computers. 2026; 15(1):11. https://doi.org/10.3390/computers15010011

Chicago/Turabian Style

Zou, Changjun, and Xirun Li. 2026. "A Position-Based Fluid Method with Dynamic Smoothing Length" Computers 15, no. 1: 11. https://doi.org/10.3390/computers15010011

APA Style

Zou, C., & Li, X. (2026). A Position-Based Fluid Method with Dynamic Smoothing Length. Computers, 15(1), 11. https://doi.org/10.3390/computers15010011

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop