Fluid particle processing method and device, computing equipment and computer storage medium

By intelligently selecting a fluid simulation algorithm and combining collision constraints to calculate the position and velocity of fluid particles, the problems of low selection efficiency and poor calculation accuracy of fluid simulation algorithms in the existing technology are solved, achieving efficient and accurate fluid particle simulation and improving user experience. experience.

CN118747472APending Publication Date: 2024-10-08BEIJING FORESTRY UNIVERSITY
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410741091.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

Fluid simulation algorithms in the existing technology have low selection efficiency and poor calculation accuracy, resulting in low calculation efficiency.

Method used

By responding to the operation of the target fluid particles, determine the scene object where it is located, and intelligently select a suitable fluid simulation algorithm, such as PBF or WCSPH algorithm, based on the calculation amount of the fluid particles, running speed requirements, interaction requirements, and iteration requirements, and calculate the fluid based on collision constraints. The current position and velocity of the particles are rendered and displayed.

Benefits of technology

It achieves strong dynamic adaptability, improved accurate simulation and interactivity, reasonable collision constraints, and improved rendering efficiency and visual quality. It optimizes resource utilization and is suitable for fluid particle simulation in multiple fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747472A_ABST
    Figure CN118747472A_ABST
Patent Text Reader

Abstract

The invention provides a fluid particle processing method and device, computing equipment and a computer storage medium. Wherein in response to an operation for a target fluid particle, a scene object where the target fluid particle is located is determined, and the operation relates to calculation of a plurality of continuous frames; in the calculation process of each frame in the plurality of continuous frames, according to a demand condition corresponding to the operation, determining a fluid simulation algorithm meeting the demand condition; calculating the current position and the current speed of the target fluid particle according to the determined fluid simulation algorithm and the collision constraint contained in the scene object where the target fluid particle is located; and based on the current position and the current speed of the target fluid particle, rendering and displaying the target fluid particle. According to the technical scheme provided by the invention, the algorithm can be intelligently selected, and the accuracy of fluid simulation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a fluid particle processing method, apparatus, computing device, and computer storage medium. Background Art

[0002] Fluid particle technology, as an advanced computer simulation method, is widely used in many fields, significantly improving the realism and physical simulation capabilities of visual effects. In the film special effects industry, it is used to create amazing natural phenomena such as floods, waterfalls, smoke and explosions, which enhances the immersion and visual impact of movie scenes. In game development, fluid particle technology makes water simulation and the interaction of fire and smoke more realistic, improving the interactivity and viewing of the game. In addition, this technology is also widely used in scientific research and engineering design, such as fluid mechanics research, car collision simulation, and wind tunnel test simulation in architectural design, helping researchers and engineers better understand fluid dynamics phenomena, optimize designs, and predict behaviors in the real world.

[0003] Currently, the mainstream methods for calculating the position of fluid particles mainly include the Weakly Compressible Smoothed Particle Hydrodynamic (WCSPH) algorithm and the Position Based Fluids (PBF) algorithm. Among them, WCSPH is a particle-based method that approximates the continuity of the fluid by smoothing the contribution of particles. Each particle represents a part of the fluid. The kernel function is used to estimate the density and pressure contribution of neighboring particles to the current particle, and then the force and position update of the particle are calculated. PBF is another position-based simulation technology that focuses on directly imposing position constraints to simulate the physical behavior of the fluid and is suitable for scenes that require accurate interactive simulation. These methods usually involve predicting the future state of the particles, and then correcting the position of the particles through iteration or constraint satisfaction to maintain the physical properties and stability of the fluid.

[0004] However, in practical applications, if a fluid simulation algorithm that does not meet the required conditions is selected, it will often cause the problem of low computational efficiency. Therefore, how to intelligently select an adaptive fluid simulation algorithm and how to improve the computational efficiency and accuracy of the selected fluid simulation algorithm have become problems that need to be solved. Summary of the invention

[0005] The embodiments of the present application provide a fluid particle processing method, apparatus, computing device and computer storage medium to solve the problems of low efficiency and poor calculation accuracy of fluid simulation algorithm selection in the prior art.

[0006] In a first aspect, an embodiment of the present application provides a fluid particle processing method, comprising:

[0007] In response to an operation on a target fluid particle, determining a scene object where the target fluid particle is located, wherein the operation involves calculation of a plurality of consecutive frames;

[0008] In the calculation process of each frame in the plurality of continuous frames, according to the requirement conditions corresponding to the operation, a fluid simulation algorithm that meets the requirement conditions is determined, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement;

[0009] Calculating the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located;

[0010] Based on the current position and current speed of the target fluid particles, the target fluid particles are rendered and displayed.

[0011] Optionally, the fluid simulation algorithm at least includes: a PBF algorithm and a WCSPH algorithm; the collision constraint includes one or a combination of a dynamic solid collision constraint and a static solid collision constraint;

[0012] The step of calculating the current position and the current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located comprises:

[0013] If the determined fluid simulation algorithm includes a PBF algorithm, traverse all target fluid particles to obtain an initial position of each target fluid particle, add an external force to each target fluid particle, and calculate a predicted position of each target fluid particle according to the external force and the initial position;

[0014] For each of the target fluid particles, traverse other fluid particles except the target fluid particle to calculate the density distribution of the other fluid particles except the target fluid particle around the target fluid particle by using a preset kernel function;

[0015] subtracting a gradient generated by a difference between the predicted positions of the target fluid particle and other fluid particles except the target fluid particle from the acquired cumulative constraint force derivative, and calculating a gradient vector of a total constraint force derivative according to the gradient;

[0016] Calculating a Lagrange multiplier according to the gradient vector of the total constraint force derivative, the density distribution of the target fluid particles, and the obtained reference density distribution of the target fluid particles;

[0017] Detecting whether each of the target fluid particles collides with the dynamic solid collision constraint, and if so, adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the dynamic solid collision constraint;

[0018] Traversing the target fluid particle and other fluid particles except the target fluid particle again to determine a correction term, and calculating a correction force according to the correction term, the density distribution of the target fluid particle and the obtained density distribution of other fluid particles except the target fluid particle;

[0019] The predicted position of each of the target fluid particles is adjusted according to the correction force to calculate the current position and current velocity of the target fluid particle.

[0020] Optionally, adjusting the predicted position of each of the target fluid particles according to the correction force further includes:

[0021] In the process of adjusting the predicted position of each of the target fluid particles according to the correction force, detecting whether each of the target fluid particles collides with the static solid collision constraint;

[0022] If so, the predicted position of each of the target fluid particles is adjusted based on the collision rule corresponding to the static solid collision constraint.

[0023] Optionally, adjusting the predicted position of each target fluid particle based on a collision rule corresponding to the dynamic solid collision constraint comprises:

[0024] Determine the solid ID corresponding to the dynamic solid;

[0025] The element hash table corresponding to the solid ID of the dynamic solid is queried, wherein the element hash table contains the displacement corresponding to the solid ID, so as to adjust the predicted position of each of the target fluid particles according to the displacement corresponding to the solid ID of the dynamic solid;

[0026] Among them, the collision rules corresponding to the dynamic solid collision constraint include: when the target fluid particles collide with the dynamic solid, the target fluid particles rebound, but do not affect the order and position of the internal particles in the dynamic solid, and only affect the overall position of the dynamic solid.

[0027] Optionally, adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the static solid collision constraint includes: calculating a rebound speed and a rebound displacement of each of the target fluid particles;

[0028] Adjusting the position of each of the target fluid particles according to the rebound speed and the rebound displacement of each of the target fluid particles;

[0029] Among them, the collision rules of the static solid collision constraint include: when the target fluid particles collide with the static solid, the target fluid particles rebound, and the rebound degree is greater than the rebound degree when the target fluid particles collide with the dynamic solid, but does not affect the overall position of the static solid.

[0030] Optionally, after adjusting the predicted position of each of the target fluid particles according to the correction force, the method further includes:

[0031] Determining the life cycle and particle ID of each of the target fluid particles;

[0032] When the calculation of each frame in the plurality of consecutive frames is completed, the life cycle of the target fluid particle is reduced, and if the life cycle of the target fluid particle is less than a preset life cycle, the target fluid particle is destroyed;

[0033] During the calculation process of each frame in the plurality of consecutive frames, if a plurality of the target fluid particles with the same particle ID collide with each other, the target fluid particles are destroyed.

[0034] Optionally, it also includes:

[0035] If the determined fluid simulation algorithm includes the WCSPH algorithm, for each of the target fluid particles, traverse other fluid particles except the target fluid particle to calculate the density distribution of the other fluid particles except the target fluid particle around the target fluid particle by using a preset kernel function;

[0036] Calculating the pressure of the target fluid particles according to the density distribution of the target fluid particles and the obtained reference density distribution of the target fluid particles;

[0037] Calculating a gradient according to a difference between the predicted positions of the target fluid particle and other fluid particles except the target fluid particle, and calculating a force acting on the target fluid particle based on the acquired Laplace operator, the gradient, and the pressure of the target fluid particle;

[0038] Based on the force of the target fluid particle and the set time step, the current position and current speed of the target fluid particle are calculated.

[0039] In a second aspect, an embodiment of the present application provides a fluid particle processing device, comprising:

[0040] A determination module, configured to determine the scene object where the target fluid particle is located in response to an operation on the target fluid particle, wherein the operation involves calculation of multiple consecutive frames; in the calculation process of each frame in the multiple consecutive frames, determine a fluid simulation algorithm that meets the requirement conditions according to the requirement conditions corresponding to the operation, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement;

[0041] A calculation module, used for calculating the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located;

[0042] A rendering module is used to render and display the target fluid particles based on the current position and current speed of the target fluid particles.

[0043] In a third aspect, an embodiment of the present application provides a computing device, comprising a processing component and a storage component; the storage component stores one or more computer instructions; the one or more computer instructions are used to be called and executed by the processing component to implement the fluid particle processing method described in the first aspect above.

[0044] In a fourth aspect, an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed by a computer, implements the fluid particle processing method as described in the first aspect above.

[0045] In an embodiment of the present application, in response to an operation on a target fluid particle, a scene object where the target fluid particle is located is determined, wherein the operation involves calculation of multiple consecutive frames; in the calculation process of each frame in the multiple consecutive frames, according to the requirement conditions corresponding to the operation, a fluid simulation algorithm that meets the requirement conditions is determined, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement; according to the determined fluid simulation algorithm and the target fluid particle, a fluid simulation algorithm that meets the requirement conditions is determined.

[0046] The fluid particle processing method proposed in the embodiment of the present application realizes efficient and accurate fluid particle simulation by flexibly adapting to different scenarios and operation requirements. Its beneficial effects are mainly reflected in the following aspects:

[0047] Enhanced dynamic adaptability: This method can dynamically adjust the fluid simulation algorithm used according to the operational requirements of the target fluid particles. This means that in different scenarios with different computing resource constraints, speed requirements, interaction complexity, or iteration sophistication, the system can automatically select the most appropriate simulation strategy, thereby optimizing resource usage and improving overall efficiency while ensuring simulation quality.

[0048] Accurate simulation and improved interactivity: By comprehensively considering the computational complexity, running speed requirements, interaction requirements, and iteration requirements of fluid particles, this method can provide more accurate particle positioning and velocity calculation in complex dynamic scenes, especially in applications that require high interactivity and real-time feedback (such as virtual reality, games, movie special effects, etc.), which can greatly enhance the user experience and the realism of the simulation.

[0049] Collision constraints and physical authenticity: Combined with the collision constraints in the scene objects, it ensures that the behavior of fluid particles in the simulation process is more in line with the laws of physics, reduces unnatural penetration or abnormal behavior, and enhances the authenticity and physical consistency of the simulation. This is especially important for simulating the interaction between fluids and solids or other fluids, making the simulation results more realistic and credible.

[0050] Rendering efficiency and visual quality: Direct rendering and display based on real-time calculated particle positions and velocities not only shortens the delay from calculation to visual presentation, but also ensures the smoothness and detail richness of the picture, providing users with a high-quality visual experience.

[0051] Wide applicability: The flexibility and adaptability of this method make it suitable not only for the entertainment industry (such as games, film and television special effects), but also for many fields such as scientific research, engineering design, and educational demonstrations, helping to promote cross-domain technological progress and innovative applications.

[0052] To sum up, the fluid particle processing method proposed in the embodiment of the present application not only improves the accuracy and interactivity of fluid simulation, but also optimizes resource utilization through intelligent selection algorithm, precise physical simulation and efficient rendering process, demonstrating extensive practical value and technological innovation.

[0053] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0055] Figure 1 A flow chart of a fluid particle processing method provided in an embodiment of the present application;

[0056] Figure 2 A schematic diagram of the effect of a dynamic solid collision constraint provided in an embodiment of the present application;

[0057] Figure 3 A schematic diagram of an element hash table provided in an embodiment of the present application;

[0058] Figure 4 A schematic diagram of the effect of a static solid collision constraint provided in an embodiment of the present application;

[0059] Figure 5 A schematic diagram of the structure of a fluid particle processing device provided in an embodiment of the present application;

[0060] Figure 6 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0062] In some of the processes described in the specification and claims of this application and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.

[0063] The fluid particle processing method provided in the embodiments of the present application is applicable to a variety of fields and application scenarios due to its high efficiency, flexibility and high fidelity, including but not limited to the following:

[0064] Film and television special effects and animation production: In the production of movies, TV series, and cartoons, it can be used to create realistic special effects such as water flow, smoke diffusion, and explosion debris scattering to enhance visual impact and realism.

[0065] Video game development: used for simulating dynamic fluid effects such as water, fire, fog, sand, etc. in the game environment to enhance the immersion and interactive experience of the game, especially in open world games and simulation games, to achieve a more delicate and dynamically changing natural environment.

[0066] Virtual Reality (VR) and Augmented Reality (AR): Simulate real fluid interactions in VR / AR experiences, such as the touch of water flow and smoke penetration effects, to enhance the user's immersive experience.

[0067] Scientific visualization and education: Used for visual teaching of complex fluid motion in fields such as meteorology, fluid mechanics, and geology, helping students and researchers better understand natural phenomena and scientific principles.

[0068] Architectural Design and Urban Planning: This method can provide accurate fluid dynamics analysis when simulating scenarios such as flooding, fire evacuation, and air flow, assisting in the design of safer and more efficient building and urban layouts.

[0069] Industrial simulation and testing: In the automotive, aerospace, oil and gas industries, it is used to simulate fluid flow, heat exchange, pollutant diffusion, etc., to optimize product design and process flow, and reduce actual testing costs and risks.

[0070] Medical simulation: In medical training and surgical simulation, blood flow, drug diffusion, etc. are simulated to help doctors and medical students better understand and practice complex medical operations.

[0071] Digital Art and Creative Design: Artists can use this method to create unique digital artworks, explore fluid aesthetics, and expand artistic expression.

[0072] These application scenarios demonstrate the great potential and value of this fluid particle processing method in improving entertainment, education, scientific research, industrial design and other fields.

[0073] The inventors have found that currently, the mainstream methods for calculating the position of fluid particles mainly include weakly compressible smooth particle hydrodynamics (WCSPH) and position-based fluids (PBF). Among them, WCSPH is a particle-based method that approximates the continuity of the fluid by smoothing the contribution of particles. Each particle represents a part of the fluid, and estimates the density and pressure contribution of neighboring particles to the current particle through kernel functions, thereby calculating the force and position update of the particle. PBF is another position-based simulation technology that focuses on directly applying position constraints to simulate the physical behavior of fluids, and is suitable for scenarios that require accurate interactive simulation. These methods usually involve predicting the future state of particles, and then correcting the position of the particles through iteration or constraint satisfaction conditions to maintain the physical properties and stability of the fluid.

[0074] However, in practical applications, if a fluid simulation algorithm that does not meet the requirements is selected, it will often cause the problem of low computational efficiency. Therefore, how to select an adaptive fluid simulation algorithm according to the requirements and how to improve the computational efficiency of the selected fluid simulation algorithm have become problems that need to be solved.

[0075] In view of this, an embodiment of the present application provides a fluid particle processing method, the method comprising: in response to an operation on a target fluid particle, determining a scene object where the target fluid particle is located, wherein the operation involves the calculation of multiple consecutive frames; in the calculation process of each frame in the multiple consecutive frames, determining a fluid simulation algorithm that meets the requirement conditions corresponding to the operation, wherein the requirement conditions include at least: the amount of fluid particle calculation, running speed requirements, interaction requirements, and iteration requirements; calculating the current position and current speed of the target fluid particle based on the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located; rendering and displaying the target fluid particle based on the current position and current speed of the target fluid particle.

[0076] The method can intelligently select an adaptive fluid simulation algorithm according to the required conditions, and calculate the current position and current velocity of the target fluid particles according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particles are located, so as to improve the computational efficiency and accuracy of fluid simulation.

[0077] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0078] Figure 1 A flow chart of an embodiment of a fluid particle processing method provided in an embodiment of the present application is as follows: Figure 1 As shown, the method includes:

[0079] 101. In response to an operation on a target fluid particle, determine a scene object where the target fluid particle is located, wherein the operation involves calculation of multiple consecutive frames;

[0080] In this step, the target fluid particles refer to a group or a single fluid particle that needs special treatment in the fluid simulation scene. They may be the key part that the user wants to focus on manipulating or affecting the simulation results. Operations on target fluid particles refer to any changes performed on these particles, including adding new particles to simulate the inflowing fluid, deleting particles that are no longer needed to save computing resources, or modifying the properties of particles (such as position, speed, color, etc.) to achieve specific visual or physical effects. The calculation of multiple consecutive frames means that these operations do not occur in isolation, but need to be continuously calculated and adjusted in a series of consecutive animation frames to ensure the consistency and realism of the fluid movement.

[0081] In an embodiment of the present application, it is assumed that a game is being developed, in which there is a level that needs to simulate the flow of a river, and players can throw stones into the river. At this time, the target fluid particles are the particles that make up the river, as well as the splash particles aroused by the stones thrown into the water by the players. The operation on the target fluid particles is specifically the stone throwing action performed by the player, which leads to the need to dynamically add new particles in the game engine to simulate the splashing water, and calculate the motion trajectories of these newly added particles in the next few frames, while considering their interaction with the original river particles (such as collision constraints, etc.).

[0082] To achieve this process, the game engine will first identify the specific scene object where the river is located when the player's throwing action occurs, and then determine the appropriate fluid simulation algorithm (which can be the PBF algorithm because it is good at handling precise interactions between particles) based on the needs of physical simulation (such as the natural diffusion of water splashes and the falling speed), and calculate the initial position and velocity of the new particles. Subsequently, in the next consecutive frames, the position and velocity of these particles will continue to be updated according to the collision constraints of the particles (such as the collision boundaries on both sides of the river and the interaction of the original river particles), and finally render a continuous and realistic water flow effect.

[0083] 102. In a calculation process of each frame in the plurality of consecutive frames, according to a requirement corresponding to the operation, determine a fluid simulation algorithm that meets the requirement;

[0084] In this step, the requirement conditions include at least: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement; the fluid simulation algorithm includes the PBF algorithm and the WCSPH algorithm.

[0085] The amount of fluid particle calculation refers to the total number of fluid particles that need to be processed in the simulation. A larger number of particles can provide a more delicate flow effect, but it also means a higher calculation cost.

[0086] Running speed requirement: refers to the performance requirement that the simulation system can run in real time or near real time. In interactive applications (such as games and virtual reality), high frame rate is key.

[0087] Interaction requirements: These involve the ability for users or external systems to interact with fluid simulations in real time, such as influencing the fluid through force fields, or the dynamic response of the fluid to objects.

[0088] Iteration requirement: refers to the number of iterations required to update the fluid state in each frame calculation in order to achieve the required simulation accuracy. A high number of iterations can improve simulation accuracy, but it will increase the computational burden.

[0089] The inventors have found that the PBF algorithm is particularly suitable for scenes that require accurate processing of contact and collision between fluids and other solids or fluids. It simulates incompressibility by directly applying position constraints, can better handle boundary conditions and maintain the stability of fluid shapes, and therefore performs well in simulations that require detailed interactive effects. Although the PBF algorithm may not be as efficient as WCSPH in large-scale fluid simulations, for small and medium-scale scenes, especially those that require fast feedback and iterative design (such as real-time interactive applications), the PBF algorithm is more advantageous because of its simplicity based directly on position correction. The WCSPH algorithm is based on the principle of particle interaction and is suitable for simulating large-scale, free-surface flow scenes, such as ocean waves, floods, etc., and can better handle the continuity and dynamic behavior of fluids.

[0090] Therefore, the PBF algorithm is more suitable for scenarios with high interaction requirements, high iteration requirements, and high running speed requirements, while the WCSPH algorithm is more suitable for scenarios with large fluid particle calculations.

[0091] In the embodiment of the present application, it is assumed that there are three different demand scenarios, namely high-precision display, real-time interactive games, and large-scale fluid simulation. We will select a suitable fluid simulation algorithm based on the above demand conditions.

[0092] Requirement 1: The running speed requirement is extremely high, basic interactive capabilities are required, and the computing power is moderate.

[0093] Example: Select the PBF (Position Based Fluids) algorithm. The PBF algorithm focuses on position-based constraint solving, and is characterized by fast calculation speed, which is suitable for real-time applications, especially in game development. It reduces the calculation complexity by directly processing the position of particles instead of directly calculating the force, so that it can meet the needs of instant feedback while maintaining a certain sense of reality.

[0094] Requirement 2: Focus on large-scale fluid flow. The amount of calculation is huge, but local details can be appropriately sacrificed. The running speed also needs to be considered.

[0095] Example: In extreme large-scale scenarios, it may be necessary to combine the advantages of both or adopt more efficient algorithm variants, or even multi-level fluid simulation technology, but based on the given options, we still choose from PBF and WCSPH. The WCSPH algorithm may be more suitable for preliminary screening of large-scale simulations due to its computational efficiency advantages, and can be further optimized to meet large-scale needs by reducing the number of particles, increasing the particle step size, etc., although this may sacrifice a certain degree of accuracy.

[0096] Through the above embodiments, it can be seen that selecting a suitable fluid simulation algorithm according to specific requirements is the key to achieving efficient and accurate fluid simulation. Based on the above settings, the corresponding fluid simulation algorithm can be intelligently selected by determining the requirements for fluid particle processing in subsequent practical applications, thereby improving the selection efficiency of the fluid simulation algorithm and ensuring the calculation efficiency of the subsequent fluid particle position.

[0097] 103. Calculate the current position and current speed of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located;

[0098] In this step, the fluid simulation algorithm refers to the calculation method previously selected according to the requirements, such as PBF or WCSPH, which specifies how to update the particle state according to physical rules and particle interactions. The collision constraint refers to the restriction on the movement of fluid particles in the simulation environment, such as the impenetrable rules between particles and solid boundaries, other fluid particles or the environment, to ensure the physical authenticity of the simulation.

[0099] In the present application embodiment:

[0100] Assume that the fluid simulation algorithm used is the PBF algorithm, and the target fluid particles are in a scene where water needs to be simulated to flow into a cup. The boundary of the cup is one of the important collision constraints, and the particles cannot penetrate the wall of the cup to enter the outside of the cup.

[0101] Initialization and constraint definition: First, according to the scene settings, determine the geometric boundaries of the cup and convert them into a series of collision constraints. Each constraint defines the behavior rules of particles when they come into contact with the boundary, such as reflection, sliding, etc.

[0102] Particle state update: Using the PBF algorithm, each target fluid particle is processed as follows:

[0103] Predict Position and Velocity: Predicts the new position and velocity of each particle based on its velocity and acceleration from the previous frame.

[0104] Collision detection: Detect whether the particle at the predicted position collides with the cup boundary. If a collision is detected, calculate the new position and velocity of the particle according to the collision constraint to ensure that the particle does not cross the boundary.

[0105] Constraint satisfaction: Apply the position constraint solving method in the PBF algorithm to adjust the particle position to meet constraints such as incompressibility and volume preservation, while considering the interaction forces between particles, such as pressure and viscosity, to further correct the position and velocity.

[0106] Iterative calculation: Multiple iterative calculations may be required until the particle position and velocity satisfy all constraints and physical rules.

[0107] Specific implementation example: In a simulation frame, a particle A representing a water flow is approaching the edge of the cup. According to the PBF algorithm, the predicted position of particle A is first calculated, and it is found that this position will penetrate the wall of the cup. At this time, the potential penetration is identified by the collision detection algorithm, and the normal reaction force of the contact point between particle A and the cup wall is calculated according to the collision constraint, and the position of particle A is adjusted to make it fit the cup wall without penetrating. At the same time, according to the constraint satisfaction step of the PBF algorithm, the speed of particle A is adjusted through iterative calculation to ensure that its speed change conforms to the rules of fluid dynamics and collision mechanics, and finally the accurate position and speed of particle A in the frame are obtained to maintain the physical authenticity and visual coherence of the simulation.

[0108] Through the above process, it is ensured that the fluid particles can obey the laws of physics while accurately responding to the specific constraints of the scene in which they are located, thus achieving a more realistic and accurate fluid simulation effect.

[0109] 104. Render and display the target fluid particles based on the current position and current speed of the target fluid particles.

[0110] In this step, the current position and current velocity refer to the spatial coordinates of each target fluid particle in the current simulation frame and its direction and velocity after being calculated by the simulation algorithm. Rendering refers to the process of converting the position and dynamic information of these particles into image data in order to display the visual effect of fluid movement on the screen. Display is to output the rendered image to the user interface so that the user can directly observe the real-time status of the fluid simulation.

[0111] In the present application embodiment:

[0112] Suppose you are developing a virtual reality application that simulates an underwater coral reef scene in real time. The target fluid particles represent particles in the water, such as water molecules, bubbles, or tiny suspended matter.

[0113] Data preparation: After determining the current position and current velocity of the target fluid particles, the system collects this data, including the color, transparency, size, and interaction information between light and particles of each particle.

[0114] Rendering technology selection: In order to enhance the sense of reality, this embodiment uses volume rendering technology to show the light transmittance and fluidity of water. Volume rendering can process the distribution of particles in three-dimensional space, simulate the scattering and absorption of light in fluids, and make the water look more natural and dynamic.

[0115] Particle rendering: For each particle, according to its position, speed and surrounding lighting, its scattering and absorption effects on light are calculated to generate color and transparency gradients to simulate the continuity and depth of fluid flow. Speed ​​information can also be used to simulate the motion blur effect of the fluid to increase the sense of movement.

[0116] Environmental interaction: Considering the coral reef scene, it is also necessary to simulate the interaction between particles and static objects such as corals and underwater plants, as well as the interaction between particles, such as reflection, refraction and shadow effects, to further enhance the realism of the scene.

[0117] Real-time display: After all calculations and rendering are completed, the final image data is output to the display screen of the VR headset in real time. Users can see vivid scenes of water flowing, bubbles rising, and particles changing under light, and feel an immersive experience as if they were on the bottom of the sea.

[0118] The above embodiments demonstrate how to transform the physical state of fluid particles into visual effects. With the help of modern rendering technology, complex fluid dynamics simulations are transformed into intuitive and beautiful visual displays, greatly enriching the user experience and the interactivity of the application.

[0119] Optionally, in an embodiment of the present application, the fluid simulation algorithm at least includes: a PBF algorithm and a WCSPH algorithm; the collision constraint includes one or a combination of a dynamic solid collision constraint and a static solid collision constraint, wherein the static solid collision constraint means that the object contacted by the fluid particles is a stable and immovable object, and the dynamic solid collision constraint means that the object contacted by the fluid particles is a movable object;

[0120] Based on this, step 103 may include the following steps:

[0121] 1031. If the determined fluid simulation algorithm includes a PBF algorithm, traverse all target fluid particles to obtain an initial position of each target fluid particle, add an external force to each target fluid particle, and calculate a predicted position of each target fluid particle according to the external force and the initial position;

[0122] In this step, for each target fluid particle Particlei in the scene object, an external force (such as gravity) is first added to each target fluid particle, and then the next position xNext (ie, the predicted position) of each target fluid particle is predicted and updated according to the external force.

[0123] 1032. For each of the target fluid particles, traverse other fluid particles except the target fluid particle to calculate the density distribution of the other fluid particles except the target fluid particle around the target fluid particle by using a preset kernel function;

[0124] In this step, each target fluid particle Particlei in the scene object is traversed again. For each target fluid particle, other fluid particles Particlej in the scene object except the target fluid particle are traversed, and the density ρi of Particlei is calculated. This usually involves using a kernel function W to estimate the density distribution around the particle, where the kernel function is used in the PBF algorithm to estimate the degree of influence between target fluid particles, which decays with increasing distance, helps calculate the density distribution around the target fluid particles, and thus affects the shape and dynamics of the fluid.

[0125] For example, the density distribution around the target fluid particles can be estimated using the following formula:

[0126]

[0127] In this formula, ρ i It is represented by the density of the target fluid particle Particlei (hereinafter referred to as particle i), N is represented by the total number of particles in the object scene, and m j is the mass of other fluid particles Particlej (hereinafter referred to as particle j) other than the target fluid particles, x i and x j are the position vectors of particles i and j, respectively, ||x i -x j || represents the Euclidean distance between particles i and j, W represents the kernel function, which depends on the distance between the two particles and the support radius h of the kernel function. Subscript j = 1, j ≠ i, j to N represents the sum of all particles j except particle i.

[0128] 1033. Subtract a gradient generated by a difference between the predicted positions of the target fluid particle and other fluid particles except the target fluid particle from the acquired cumulative constraint force derivative, and calculate a gradient vector of a total constraint force derivative according to the gradient;

[0129] In this step, the accumulated constraint force derivative refers to calculating the derivative of the force that needs to be applied to the particles based on the difference between the ideal layout and the actual layout between the particles, so as to drive the particles to move to the position that satisfies the constraint conditions.

[0130] Specifically, in the above traversal process, if Particlej is not equal to Particlei, then from the cumulative constraint force derivative The gradient calculated by subtracting the difference between the predicted positions of particles i and j (xNexti-xNextj) from (Right now ), and finally, Add to The gradient vector of the total constraint force derivative is obtained (That is, first calculate through the formula Recalculate To get the final ) to fully represent all constraints between particles.

[0131] 1034. Calculate a Lagrange multiplier according to the gradient vector of the total constraint force derivative, the density distribution of the target fluid particles, and the obtained reference density distribution of the target fluid particles;

[0132] In this step, Lagrange multipliers are a key concept in optimization problems and are used to introduce constraints. By adjusting these multipliers, we can ensure that the simulation process meets physical constraints, such as keeping the fluid volume unchanged or achieving a specific collision response.

[0133] Specifically, through the formula: Based on the density ρ of each particle i i The difference with its corresponding reference density ρ0, and the gradient vector of the total constraint force derivative (plus a small constant ε to avoid division by zero errors), the Lagrange multiplier λ is calculated i , where the multiplier λ i Used to adjust the position of particles to satisfy the incompressibility of the fluid and maintain volume conservation.

[0134] 1035. Detect whether each of the target fluid particles collides with the dynamic solid collision constraint, and if so, adjust the predicted position of each of the target fluid particles based on the collision rule corresponding to the dynamic solid collision constraint;

[0135] In this step, dynamic solid collision constraints mean that fluid particles must consider not only the interaction with other fluid particles, but also the interaction with movable solid boundaries, which requires the algorithm to update the positions of these boundaries in real time and adjust the behavior of fluid particles accordingly.

[0136] 1036. Traverse the target fluid particle and other fluid particles except the target fluid particle again to determine a correction term, and calculate a correction force according to the correction term, the density distribution of the target fluid particle and the obtained density distribution of other fluid particles except the target fluid particle;

[0137] In this step, the correction terms and correction forces are further adjusted based on the preliminary predicted positions by analyzing the interactions between particles and the conflicts with solid constraints to ensure the accuracy and stability of the simulation.

[0138] Specifically, through the formula group: Traverse each particle i and its corresponding particle j again to calculate a correction term scorr, which is related to the distance between the two particles and the weight function, and aims to enhance the repulsive effect between particles at close range. i , j (where λ j The calculation formula of i Similar) and scorr, calculate the correction force Δp i , this correction force will be applied to push the particle to satisfy the constraint.

[0139] In "Scorr = -k(W(xNext i -xNext j ) / W(Δq)) n In this formula, -k is a constant coefficient used to adjust the strength of the correction term scorr, W(xNext i -xNext j ) is represented by the value of the kernel function W at the distance between the next predicted position xNexti of particle i and the next predicted position xNextj of particle j, where the kernel function is usually used to measure the weight of the influence between particles and decreases with increasing distance. W(Δq) is represented by the value of the kernel function at a reference length Δq, which may represent the expected average spacing between particles or other defined distance scales, and is used to standardize the value of the kernel function so that the pressure correction term does not depend on the compactness of the local particle distribution. n is represented by an exponent, usually a positive value, which controls the rate at which the pressure correction term changes with distance. A larger n value will make the correction term have a stronger effect on particles at close distances.

[0140] exist In this formula, λ i Expressed as the Lagrange multiplier corresponding to particle i, λ j Expressed as the Lagrange multiplier corresponding to particle j, It is expressed as the gradient of the kernel function with respect to the position difference between particles i and j, and is used to calculate the pressure gradient, that is, how the pressure changes with space, so as to obtain the direction of the pressure force on particle i.

[0141] 1037. Adjust the predicted position of each of the target fluid particles according to the correction force to calculate the current position and current velocity of the target fluid particles.

[0142] In the present application embodiment:

[0143] Suppose you want to simulate a scene in which a water ball falls into a pool and collides elastically with the bottom of the pool.

[0144] Initialization and force addition (i.e., step 1031): Assume that the water ball and pool water are composed of a large number of fluid particles. First, record the initial position of each water particle and add gravity to the water ball particle as an external force. Based on gravity and initial position, predict the new position of each particle affected by gravity.

[0145] Density distribution calculation (ie step 1032): For each water particle, a Gaussian kernel function is used to estimate the density field formed by other water particles around it, which helps in the subsequent calculation of the mutual attraction and repulsion between particles.

[0146] Constraint force calculation and adjustment (i.e., steps 1033 to 1035): By comparing the predicted position differences between particles, the gradient vector of the constraint force derivative is calculated to force the particles to maintain a reasonable spacing. At the same time, when the water ball touches the bottom, the dynamic collision constraint is used to adjust the particle position to ensure that they do not penetrate the bottom of the pool, but bounce back according to the elastic collision rules.

[0147] Correction and velocity calculation (i.e., steps 1036 to 1037): Based on the correction terms obtained in the previous steps, the correction force is calculated to take into account the final interaction between particles and the bottom of the pool, and the predicted position is adjusted accordingly to obtain the actual position and velocity of each water particle. This series of corrections ensures the physical accuracy of the fluid simulation, especially in collision events.

[0148] The above examples demonstrate how to use the PBF algorithm to perform detailed and realistic fluid dynamics simulations, especially in scenarios dealing with complex collision constraints, to ensure the natural smoothness and physical authenticity of fluid motion.

[0149] Optionally, during the execution of step 1037, it is also necessary to confirm whether the number of iterations reaches a preset number (which can be set according to demand) in the process of "adjusting the predicted position of each target fluid particle according to the correction force". If so, calculate the current position and current speed of the target fluid particle. If not, continue to execute step 1034.

[0150] Optionally, in an embodiment of the present application, in the process of "adjusting the predicted position of each of the target fluid particles according to the correction force" in step 1037, it also includes: in the process of adjusting the predicted position of each of the target fluid particles according to the correction force, detecting whether each of the target fluid particles collides with the static solid collision constraint; if so, adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the static solid collision constraint.

[0151] In this step, static solid collision constraints refer to the rules that fluid particles must follow when they encounter fixed solid boundaries or obstacles during their movement. These constraints ensure that fluid particles do not penetrate or cross static solid boundaries, maintaining the physical reality and integrity of the simulation.

[0152] Detecting collisions means that after each adjustment of the predicted position of fluid particles, the system checks whether the new positions of these particles intersect with any static solid objects or are close to a preset minimum distance. This step is performed in real time to ensure an immediate response to any potential collision events.

[0153] Adjusting the position based on collision rules means that once a fluid particle is detected to have collided with a static solid, the system will correct the position of these particles according to preset physical rules (such as bouncing, sliding or staying still). These rules reflect the physical properties of the interaction between fluid and solid surfaces in the real world, such as energy conservation, momentum transfer, etc.

[0154] In the present application embodiment:

[0155] Suppose you are simulating a scene where water is dripping from a faucet into a stationary sink. The bottom and walls of the sink are treated as static solid collision constraints.

[0156] Predicted position adjustment: First, the predicted position of each water droplet particle in the next time slot is calculated using the PBF algorithm, taking into account the interaction of fluid dynamics and external forces.

[0157] Collision detection: After adjusting the predicted position, the program immediately performs a collision check on each water droplet particle to determine whether it has any intersection with the bottom or side walls of the tank. This is usually done by comparing the distance between the particle's new position and the solid boundary. If it is less than a certain threshold, a collision is considered to have occurred.

[0158] Collision response processing: When a collision is detected, the collision rules corresponding to the solid boundary are applied. For example, if a water droplet particle is predicted to pass through the bottom of the sink, the particle position is adjusted to make it bounce on the bottom surface of the sink according to its speed and angle, and the vertical speed is appropriately reduced according to the principle of conservation of momentum to simulate the bouncing effect of the water droplet. If the particle approaches the side wall, its movement direction and speed along the wall are adjusted according to the sliding friction coefficient to simulate the sliding of the fluid along the solid surface.

[0159] Iterative optimization: This process may require multiple iterations because adjusting the position of one particle to avoid collision may cause the new position of other particles to collide with solid objects. Therefore, the particle positions of the entire scene need to be repeatedly checked and adjusted until the predicted positions of all particles meet the collision constraints.

[0160] Through the above embodiments, it can be seen that in fluid particle simulation, dynamically considering static solid collision constraints and adjusting particle positions in real time according to physical rules are key links to ensure simulation authenticity and physical accuracy.

[0161] As a possible implementation scheme, the process of “adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the dynamic solid collision constraint” may include: determining the solid ID corresponding to the dynamic solid; querying the corresponding element hash table through the solid ID of the dynamic solid, wherein the element hash table contains the displacement corresponding to the solid ID, so as to adjust the predicted position of each of the target fluid particles according to the displacement corresponding to the solid ID of the dynamic solid;

[0162] Among them, Figure 2 As shown (where the dynamic solid is Figure 2 The target fluid particle collides with the dynamic solid, but does not affect the order and position of the internal particles in the dynamic solid, and only affects the overall position of the dynamic solid.

[0163] In the embodiment of the present application, the element hash table is as follows Figure 3 As shown, for example, when the solid ID of dynamic solid A is 1, the corresponding displacement is determined to be (1,1) through the element hash table query, and the predicted position of the target fluid particle is adjusted according to the displacement. For example, when the solid ID of dynamic solid A is 3, the corresponding displacement is determined to be (-1,2) through the element hash table query, and the predicted position of the target fluid particle is adjusted according to the displacement.

[0164] In this step, dynamic solid collision constraints refer to the interaction rules between fluid particles and movable solids, which are not only affected by the fluid but may also move or deform in the scene. The element hash table is a data structure used to efficiently store and retrieve information about dynamic solids, where each solid ID is associated with a displacement that indicates the latest movement of the solid in the scene.

[0165] The displacement refers to the change in the position of the dynamic solid in space since the last calculation. It can be used to directly adjust the predicted position of the fluid particles colliding with it to reflect the impact of the solid motion on the fluid behavior.

[0166] The rebound effect mentioned in the collision rules means that when fluid particles hit a dynamic solid, they will bounce back like a bouncy ball without changing the arrangement or position of the particles inside the solid. Only the position of the solid as a whole will change, which simulates the physical reality of the interaction between the fluid and the solid boundary.

[0167] In the present application embodiment:

[0168] Suppose you are simulating the changes in water flow caused by the movement of fish in an aquarium. The fish's body is regarded as a dynamic solid and the water molecules are regarded as fluid particles.

[0169] Dynamic solid ID identification: First, the system identifies the dynamic solid that collides with the fluid particles, such as a specific part of the fish's body, and determines its solid ID. For example, the solid ID of the fish tail is 1, and the solid ID of the fin is 3.

[0170] Query element hash table: Use these solid IDs to query the pre-built element hash table. Assume that the displacement of the fish tail (ID = 1) in the most recent frame is (1,1), which means that the fish tail has moved one unit to the lower right. Similarly, the displacement of the fin (ID = 3) is (-1,2), which means that it has moved one unit to the upper left and slightly floated.

[0171] Adjust the position of fluid particles: When the fluid particle is predicted to collide with the fish tail (ID=1), the predicted position of the fluid particle is adjusted accordingly according to its displacement (1,1), so that the particle simulates the displacement caused by the movement of the fish tail, as if it is pushed by the fish tail. Similarly, for the collision with the fish fin (ID=3), the particle position is adjusted using the displacement (-1,2) to reflect the change in water flow caused by the upward movement of the fish fin.

[0172] Maintaining the integrity of the solid: When adjusting the position of the fluid particles, the order and position of the particles inside the fish's body remain unchanged, and only the overall displacement of the fish is considered. This ensures that while the solid changes dynamically, its internal structure is not directly affected by the fluid collision, thus maintaining the rationality of the physical behavior.

[0173] The above embodiments demonstrate how to quickly respond to the movement of dynamic solids through element hash tables and adjust the predicted positions of fluid particles accordingly, thereby truly reflecting the dynamic interaction between the fluid and the movable solids in the simulation.

[0174] In addition, it should be noted that when the PBF method is used to calculate the lambda value of a fluid particle and the neighboring particles are traversed, the IDs of the neighboring particles will be checked. If the particle ID of the target fluid particle is 1, and a dynamic solid particle with a matching ID (i.e., a dynamic solid with an ID of 1) is found in its neighborhood, this is considered a collision event between the two, and the above-mentioned collision rules corresponding to the dynamic solid collision constraint need to be executed to adjust the predicted position of the target fluid particle. On the contrary, if the IDs of the two do not match, there is no need to adjust the predicted position of the target fluid particle.

[0175] As a possible implementation scheme, the process of “adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the static solid collision constraint” may include: calculating the rebound speed and rebound displacement of each of the target fluid particles; adjusting the position of each of the target fluid particles according to the rebound speed and rebound displacement of each of the target fluid particles;

[0176] Among them, Figure 4 As shown (where the static solid is Figure 4 ), the collision rule of the static solid collision constraint includes: when the target fluid particles collide with the static solid, the target fluid particles rebound, and the rebound degree is greater than the rebound degree when the target fluid particles collide with the dynamic solid, but does not affect the overall position of the static solid.

[0177] It should be noted that the purpose of distinguishing the two types of collision constraints is to provide different solutions for different needs. If a static solid collision constraint is required, you can choose the static method (good performance, but not movable). If a dynamic solid collision constraint is required, you can use the dynamic method (high overhead, but movable).

[0178] The reason why the rebound degree of the static solid is greater than the rebound degree when the target fluid particles collide with the dynamic solid is that: since the dynamic constraint is implemented using fixed particles, the calculation of the rebound position of the collision is weighted by the smooth kernel function mentioned above, so different effects will be produced due to the parameters used in the calculation.

[0179] In this step, the rebound velocity refers to the speed at which fluid particles move in the opposite direction after colliding with solids. It is the result of collision energy conversion and reflects the dynamic response of particles. The rebound displacement describes the actual displacement distance of particles after collision. It is the product of the rebound velocity and time. However, in actual calculation, it is usually determined in combination with the specific physical parameters of the collision to maintain the physical accuracy of the simulation.

[0180] The collision rules in the static solid collision constraint emphasize the handling method when the fluid particles collide with the static environment (immovable obstacles or boundaries). Compared with dynamic solids, the collision response of static solids is more direct. Because the position of the static solid itself does not change, the rebound effect of the fluid particles after the collision can be set to be more obvious to reflect the physical characteristics of the fluid when it encounters a hard and immovable surface.

[0181] In the present application embodiment:

[0182] Suppose you are simulating a scene where raindrops fall on a stationary ground (a static solid) and a slowly moving car roof (a dynamic solid).

[0183] Calculate the rebound speed and displacement: For raindrops (target fluid particles), when it is predicted that they will collide with the static ground, the rebound speed of the raindrops is calculated based on factors such as the incident speed, mass and hardness of the ground. Assuming the incident speed is v_in, and the rebound coefficient is set to e_static>e_dynamic (where e_dynamic is the rebound coefficient for collision with a dynamic solid), the rebound speed v_rebound = -e_static*v_in. Combined with the predicted time interval dt of the next frame of the raindrop, the rebound displacement is calculated. Among them, the specific process of calculating the rebound speed and the rebound displacement is not the focus of the invention of this application and can be implemented by referring to the existing solution, so this application will not repeat it.

[0184] Adjust position: Based on the calculated rebound speed and displacement, the predicted position of the raindrop is adjusted so that it moves a certain distance at the calculated reverse speed after the collision, ensuring that the raindrop does not penetrate the ground but bounces in the opposite direction, reflecting a strong rebound effect when colliding with a static solid.

[0185] Comparison with dynamic solid collision: In contrast, when raindrops fall on a slowly moving roof (dynamic solid), the rebound calculation will be different. Since the dynamic solid itself is also moving, the rebound speed of the raindrops v_rebound_dyna=-e_dynamic*v_in will be less than the rebound speed when colliding with a static solid, and the particles on the roof will also make corresponding adjustments according to their own movement and collision rules, but overall it will not affect the movement path of the roof.

[0186] Through this distinction, this embodiment demonstrates how to achieve diversified physical manifestations of fluid particle-solid collisions by adjusting rebound parameters under different types of solid constraints, which not only ensures the authenticity of the simulation but also provides the flexibility of customized processing according to different scene requirements.

[0187] Optionally, in an embodiment of the present application, in step 1037 "adjusting the predicted position of each of the target fluid particles according to the correction force", the process also includes: determining the life cycle and particle ID of each of the target fluid particles; after the calculation of each frame in the multiple consecutive frames is completed, reducing the life cycle of the target fluid particle, if the life cycle of the target fluid particle is less than a preset life cycle, destroying the target fluid particle; during the calculation process of each frame in the multiple consecutive frames, if a collision occurs between multiple target fluid particles with the same particle ID, destroying the target fluid particle.

[0188] In this step, the life cycle refers to the time limit of the fluid particles in the simulation scene, which simulates the natural process of particles from generation to disappearance, helps manage memory and computing resources, and avoids endless tracking and calculation of particles that no longer have a significant impact on the simulation.

[0189] A particle ID is a unique identifier assigned to each fluid particle, making it easy to track and manage the state of individual particles, which is especially important when dealing with collision detection and eliminating duplicate calculations.

[0190] Destroying particles means removing the particles from the simulation when they reach the end of their life cycle or a collision occurs under certain conditions, stopping further calculation and rendering of the particles, thereby optimizing performance and the realism of the simulation.

[0191] In the present application embodiment:

[0192] Suppose you are simulating a short but intense rainstorm scenario, where raindrops participate in the simulation as fluid particles.

[0193] Lifecycle management: When each raindrop (target fluid particle) is generated, it is assigned a lifecycle value that is random or calculated based on its initial speed and position, such as setting an average lifespan of 10 seconds. As each frame is calculated, the system decrements the lifecycle counter of all active raindrops. When the lifecycle of any raindrop is reduced to zero, indicating that the raindrop has "landed" or evaporated, the system immediately removes the raindrop from the simulation and releases the computing resources associated with it.

[0194] Particle ID and collision detection: To avoid unnecessary repeated calculations and visual errors in the simulation, such as raindrops penetrating each other, the system assigns a unique particle ID to each raindrop. During the calculation process of each frame, the particle ID is compared to detect whether two or more raindrops with the same ID accidentally overlap or "collide". Once this is found, the system determines that these raindrops are duplicates caused by simulation errors, and immediately destroys the excess raindrops, retaining only one to maintain the logical consistency and resource efficiency of the simulation.

[0195] Example: At the 5th second of the simulation, a group of raindrops begin to approach the ground. Each raindrop has an initial life cycle set to 15 frames (assuming a refresh rate of 30 frames per second, which is equivalent to a life cycle of 5 seconds). As the simulation progresses, the system checks and reduces the life cycle counts of all raindrops with each frame. When the simulation reaches the 10th second, the life cycle of the earliest batch of raindrops reaches the preset value, and these raindrops are marked as "landed", removed from the simulation, and no longer participate in subsequent calculations and rendering. At the same time, at the 7th second of the simulation, the system detects that two raindrops with the same ID overlap due to a calculation error, and immediately destroys one of them, ensuring the natural continuity of the rain scene and avoiding visual unreality. Through such a mechanism, the simulation not only maintains physical accuracy, but also effectively manages computing resources.

[0196] Optionally, in an embodiment of the present application, it also includes: if the determined fluid simulation algorithm includes a WCSPH algorithm, for each of the target fluid particles, traverse the other fluid particles except the target fluid particle to calculate the density distribution of the other fluid particles except the target fluid particle located around the target fluid particle through a preset kernel function; calculate the pressure of the target fluid particle according to the density distribution of the target fluid particle and the obtained reference density distribution of the target fluid particle; calculate the gradient according to the difference between the predicted position of the target fluid particle and the other fluid particles except the target fluid particle, and calculate the force of the target fluid particle based on the obtained Laplace operator, the gradient and the pressure of the target fluid particle; calculate the current position and current velocity of the target fluid particle based on the force of the target fluid particle and the set time step.

[0197] In this step, the WCSPH algorithm (Weakly Compressible Smoothed Particle Hydrodynamics) is a particle-based method suitable for simulating fluid dynamics problems, especially for dealing with complex phenomena such as free surface flow and breakup. It approximates the continuity equation and Navier-Stokes equation of the fluid through smooth particle technology.

[0198] Kernel functions play a core role in WCSPH, and are used to estimate the forces and density distribution between particles. Common kernel functions include Gaussian kernels and polynomial kernels, which determine how to calculate the interaction strength based on the distance between particles.

[0199] The density distribution is estimated by weighting the contribution of surrounding particles through the kernel function, which reflects the distribution of the fluid in space and is the basis for calculating pressure.

[0200] Pressure is an important parameter in fluid simulation. It reflects the interaction force inside the fluid by considering the compressibility of the fluid and is used to prevent unnatural penetration between particles.

[0201] Gradient and Laplace operator are concepts in vector calculus, representing the rate of change and curvature of a function value in space, respectively. In WCSPH, they are used to calculate the forces between fluid particles, especially the pressure gradient force and the viscous force, which in turn affect the acceleration of the particles.

[0202] In the present application embodiment:

[0203] Suppose that the WCSPH algorithm is being used to simulate ocean waves hitting rocks on the shore.

[0204] Density distribution calculation: For each fluid particle representing seawater, all other water particles around it are traversed, and the density contribution of the neighboring particles to the central particle is calculated using the kernel function according to the distance between them. By accumulating these contributions, the instantaneous density distribution of the central particle is obtained. The specific calculation process of this step can be referred to step 1032 in the above embodiment.

[0205] Pressure calculation: Based on the density distribution of each particle (including the density of the central particle itself and the contribution of the surrounding particles to its density), the pressure of each particle is calculated through a state equation (such as the Tait equation). This step ensures that the fluid remains approximately incompressible, that is, the density changes very little, and the pressure reflects the force balance inside the fluid. Specifically, the pressure of the target fluid particles can be calculated according to the density distribution of the target fluid particles and the reference density distribution of the target fluid particles obtained by the formula: pi = kp (ρi-ρ0), where pi represents pressure, kp represents pressure constant, ρi represents density distribution of target fluid particles, and ρ0 represents reference density distribution.

[0206] Force calculation: For each pair of particles, the distance difference between their predicted positions is calculated, and the gradient of the force is calculated using this distance difference. At the same time, the Laplace operator is used to consider the pressure gradient force between particles, as well as possible viscosity and other external forces, and the total force acting on each particle is obtained by combining this information. Specifically, the formula can be used:

[0207]

[0208] Calculate the force, where f i Expressed as force, m i is the mass of particle i, Expressed as the pressure p of particle i i With its density ρ i The ratio of the squares of Expressed as the pressure p of particle jj With its density ρ j The ratio of the squares of It is expressed as the gradient of the kernel function W with respect to the position difference (xi-xj), which is used to calculate the direction and magnitude of the force caused by pressure and represents the effect of the pressure gradient between particles. μ is expressed as the dynamic viscosity coefficient, which controls the viscosity of the fluid, that is, the friction inside the fluid. m j *(v j -v i ) / ρ j It is expressed as the viscous force contribution of particle j to particle i, where (v j -v i ) is the velocity difference between the two particles, representing the velocity gradient, ρ j Expressed as the density of particle j, it is used to normalize the viscous force and ensure the consistency of physical quantities. It is expressed as the kernel function W about the position difference (x i -x j ) is used to calculate the viscous force term, which reflects the viscous effect of the fluid, that is, the mutual drag force caused by the difference in particle velocity.

[0209] Position and velocity update: Based on the total force on each particle and a given time step (e.g., 0.001 seconds), Newton's second law is applied to calculate the acceleration of each particle, and then its position and velocity are updated. This step ensures that the particles move according to physical laws in continuous time frames, simulating realistic fluid motion effects.

[0210] Through this series of steps, the complex fluid dynamics behavior of waves colliding with rocks can be accurately simulated in a virtual environment, including wave breaking, splashing effects, and interactions with solid boundaries, demonstrating the powerful ability of the WCSPH algorithm in handling such complex fluid simulation tasks.

[0211] Figure 5 A schematic diagram of the structure of a fluid particle processing device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the device comprises:

[0212] A determination module 51 is used to determine the scene object where the target fluid particle is located in response to an operation on the target fluid particle, wherein the operation involves the calculation of multiple consecutive frames; in the calculation process of each frame in the multiple consecutive frames, according to the requirement conditions corresponding to the operation, determine a fluid simulation algorithm that meets the requirement conditions, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement;

[0213] A calculation module 52, used to calculate the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located;

[0214] The rendering module 53 is used to render and display the target fluid particles based on the current position and current speed of the target fluid particles.

[0215] Optionally, in the embodiment of the present application, the fluid simulation algorithm at least includes: a PBF algorithm and a WCSPH algorithm; the collision constraint includes one or a combination of a dynamic solid collision constraint and a static solid collision constraint;

[0216] The calculation module 52 is specifically used for, if the determined fluid simulation algorithm includes the PBF algorithm, traversing all target fluid particles to obtain the initial position of each target fluid particle, adding an external force to each target fluid particle, and calculating the predicted position of each target fluid particle according to the external force and the initial position; for each target fluid particle, traversing other fluid particles except the target fluid particle to calculate the density distribution of other fluid particles except the target fluid particle around the target fluid particle through a preset kernel function; subtracting the gradient generated by the difference between the predicted position of the target fluid particle and other fluid particles except the target fluid particle from the obtained cumulative constraint force derivative, and calculating the gradient vector of the total constraint force derivative according to the gradient; The Lagrange multiplier is calculated based on the gradient vector of the total constraint force derivative, the density distribution of the target fluid particles, and the obtained reference density distribution of the target fluid particles; each of the target fluid particles is detected to determine whether it collides with the dynamic solid collision constraint, and if so, the predicted position of each of the target fluid particles is adjusted based on the collision rule corresponding to the dynamic solid collision constraint; the target fluid particles and other fluid particles except the target fluid particles are traversed again to determine the correction term, and the correction force is calculated based on the correction term, the density distribution of the target fluid particles, and the obtained density distribution of other fluid particles except the target fluid particles; the predicted position of each of the target fluid particles is adjusted based on the correction force to calculate the current position and current velocity of the target fluid particle.

[0217] Optionally, in an embodiment of the present application, the calculation module 52 is also used to detect whether each of the target fluid particles collides with the static solid collision constraint during the process of adjusting the predicted position of each of the target fluid particles according to the correction force; if so, adjust the predicted position of each of the target fluid particles based on the collision rule corresponding to the static solid collision constraint.

[0218] Optionally, in an embodiment of the present application, the calculation module 52 is also used to determine the solid ID corresponding to the dynamic solid; query the corresponding element hash table through the solid ID of the dynamic solid, and the element hash table contains the displacement corresponding to the solid ID, so as to adjust the predicted position of each target fluid particle according to the displacement corresponding to the solid ID of the dynamic solid; wherein the collision rule corresponding to the dynamic solid collision constraint includes: when the target fluid particle collides with the dynamic solid, the target fluid particle rebounds, but does not affect the sorting and position of the internal particles in the dynamic solid, and only affects the overall position of the dynamic solid.

[0219] Optionally, in an embodiment of the present application, the calculation module 52 is also used to calculate the rebound speed and rebound displacement of each of the target fluid particles; adjust the position of each of the target fluid particles according to the rebound speed and rebound displacement of each of the target fluid particles; wherein the collision rule of the static solid collision constraint includes: when the target fluid particle collides with the static solid, the target fluid particle rebounds, and the degree of rebound is greater than the degree of rebound when the target fluid particle collides with the dynamic solid, but does not affect the overall position of the static solid.

[0220] Optionally, in an embodiment of the present application, the calculation module 52 is also used to determine the life cycle and particle ID of each of the target fluid particles; when the calculation of each frame in the multiple consecutive frames is completed, the life cycle of the target fluid particle is reduced, and if the life cycle of the target fluid particle is less than a preset life cycle, the target fluid particle is destroyed; when the calculation of each frame in the multiple consecutive frames is in the process, if a collision occurs between multiple target fluid particles with the same particle ID, the target fluid particle is destroyed.

[0221] Optionally, in an embodiment of the present application, the calculation module 52 is also used to, if the determined fluid simulation algorithm includes a WCSPH algorithm, traverse other fluid particles except the target fluid particle for each target fluid particle, so as to calculate the density distribution of other fluid particles except the target fluid particle located around the target fluid particle through a preset kernel function; calculate the pressure of the target fluid particle according to the density distribution of the target fluid particle and the obtained reference density distribution of the target fluid particle; calculate the gradient according to the difference between the predicted position of the target fluid particle and other fluid particles except the target fluid particle, and calculate the force of the target fluid particle based on the obtained Laplace operator, the gradient and the pressure of the target fluid particle; calculate the current position and current velocity of the target fluid particle based on the force of the target fluid particle and the set time step.

[0222] Figure 5 The fluid particle processing device can perform Figure 1 The implementation principle and technical effect of the fluid particle processing method described in the illustrated embodiment will not be described in detail. The specific manner in which each module and unit performs operations in the fluid particle processing device in the above embodiment has been described in detail in the embodiment of the method, and will not be described in detail here.

[0223] In one possible design, Figure 5 The fluid particle processing apparatus of the embodiment shown can be implemented as a computing device, such as Figure 6 As shown, the computing device may include a storage component 61 and a processing component 62;

[0224] The storage component 61 stores one or more computer instructions, wherein the one or more computer instructions are called and executed by the processing component 62 .

[0225] The processing component 62 is used to: determine the scene object where the target fluid particles are located in response to an operation on the target fluid particles, wherein the operation involves the calculation of multiple consecutive frames; during the calculation process of each frame in the multiple consecutive frames, determine a fluid simulation algorithm that meets the requirement conditions corresponding to the operation, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement; calculate the current position and current speed of the target fluid particles based on the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particles are located; and render and display the target fluid particles based on the current position and current speed of the target fluid particles.

[0226] The processing component 62 may include one or more processors to execute computer instructions to complete all or part of the steps in the above method. Of course, the processing component may also be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0227] The storage component 61 is configured to store various types of data to support operations at the terminal. The storage component can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0228] The display component 63 can be an electroluminescent (EL) element, a liquid crystal display or a micro display having a similar structure, or a retinal direct display or a similar laser scanning display.

[0229] Of course, a computing device may also include other components, such as input / output interfaces, communication components, etc.

[0230] The input / output interface provides an interface between the processing component and the peripheral interface module, which may be an output device, an input device, etc.

[0231] The communication component is configured to facilitate, among other things, wired or wireless communications between the computing device and other devices.

[0232] Among them, the computing device can be a physical device or an elastic computing host provided by a cloud computing platform, etc. In this case, the computing device can refer to a cloud server, and the above-mentioned processing components, storage components, etc. can be basic server resources rented or purchased from the cloud computing platform.

[0233] The present application also provides a computer storage medium storing a computer program, wherein the computer program can achieve the above-mentioned Figure 1 The fluid particle processing method of the illustrated embodiment.

[0234] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0235] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0236] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0237] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for processing fluid particles, characterized in that: include: In response to an operation on a target fluid particle, determining a scene object where the target fluid particle is located, wherein the operation involves calculation of a plurality of consecutive frames; In the calculation process of each frame in the plurality of continuous frames, according to the requirement conditions corresponding to the operation, a fluid simulation algorithm that meets the requirement conditions is determined, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement; Calculating the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located; Based on the current position and current speed of the target fluid particles, the target fluid particles are rendered and displayed.

2. The method according to claim 1, characterized in that The fluid simulation algorithm at least includes: PBF algorithm, WCSPH algorithm; the collision constraint includes one or a combination of dynamic solid collision constraint and static solid collision constraint; The step of calculating the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located comprises: If the determined fluid simulation algorithm includes a PBF algorithm, traverse all target fluid particles to obtain an initial position of each target fluid particle, add an external force to each target fluid particle, and calculate a predicted position of each target fluid particle according to the external force and the initial position; For each of the target fluid particles, traverse other fluid particles except the target fluid particle to calculate the density distribution of other fluid particles except the target fluid particle around the target fluid particle by using a preset kernel function; subtracting a gradient generated by a difference between the predicted positions of the target fluid particle and other fluid particles except the target fluid particle from the acquired cumulative constraint force derivative, and calculating a gradient vector of a total constraint force derivative according to the gradient; Calculating a Lagrange multiplier according to the gradient vector of the total constraint force derivative, the density distribution of the target fluid particles, and the obtained reference density distribution of the target fluid particles; Detecting whether each of the target fluid particles collides with the dynamic solid collision constraint, and if so, adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the dynamic solid collision constraint; Traversing the target fluid particle and other fluid particles except the target fluid particle again to determine a correction term, and calculating a correction force according to the correction term, the density distribution of the target fluid particle and the obtained density distribution of other fluid particles except the target fluid particle; The predicted position of each of the target fluid particles is adjusted according to the correction force to calculate the current position and current velocity of the target fluid particle.

3. The method according to claim 2, characterized in that The step of adjusting the predicted position of each of the target fluid particles according to the correction force further includes: In the process of adjusting the predicted position of each of the target fluid particles according to the correction force, detecting whether each of the target fluid particles collides with the static solid collision constraint; If so, the predicted position of each of the target fluid particles is adjusted based on the collision rule corresponding to the static solid collision constraint.

4. The method according to claim 2, characterized in that: The step of adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the dynamic solid collision constraint comprises: Determine the solid ID corresponding to the dynamic solid; Querying a corresponding element hash table through the solid ID of the dynamic solid, wherein the element hash table contains a displacement corresponding to the solid ID, so as to adjust the predicted position of each of the target fluid particles according to the displacement corresponding to the solid ID of the dynamic solid; Among them, the collision rules corresponding to the dynamic solid collision constraint include: when the target fluid particles collide with the dynamic solid, the target fluid particles rebound, but do not affect the order and position of the internal particles in the dynamic solid, and only affect the overall position of the dynamic solid.

5. The method according to claim 3, characterized in that: The adjusting the predicted position of each of the target fluid particles based on the collision rule corresponding to the static solid collision constraint includes: calculating the rebound speed and rebound displacement of each of the target fluid particles; Adjusting the position of each of the target fluid particles according to the rebound speed and the rebound displacement of each of the target fluid particles; Among them, the collision rules of the static solid collision constraint include: when the target fluid particles collide with the static solid, the target fluid particles rebound, and the rebound degree is greater than the rebound degree when the target fluid particles collide with the dynamic solid, but does not affect the overall position of the static solid.

6. The method according to claim 2, characterized in that After adjusting the predicted position of each of the target fluid particles according to the correction force, the method further includes: Determining the life cycle and particle ID of each of the target fluid particles; When the calculation of each frame in the plurality of consecutive frames is completed, the life cycle of the target fluid particle is reduced, and if the life cycle of the target fluid particle is less than a preset life cycle, the target fluid particle is destroyed; During the calculation process of each frame in the plurality of consecutive frames, if a plurality of the target fluid particles with the same particle ID collide with each other, the target fluid particles are destroyed.

7. The method according to claim 1, characterized in that Also includes: If the determined fluid simulation algorithm includes the WCSPH algorithm, for each of the target fluid particles, traverse other fluid particles except the target fluid particle to calculate the density distribution of the other fluid particles except the target fluid particle around the target fluid particle by using a preset kernel function; Calculating the pressure of the target fluid particles according to the density distribution of the target fluid particles and the obtained reference density distribution of the target fluid particles; Calculating a gradient according to a difference between the predicted positions of the target fluid particle and other fluid particles except the target fluid particle, and calculating a force acting on the target fluid particle based on the acquired Laplace operator, the gradient, and the pressure of the target fluid particle; Based on the force of the target fluid particle and the set time step, the current position and current speed of the target fluid particle are calculated.

8. A fluid particle processing device, characterized in that: include: A determination module, configured to determine the scene object where the target fluid particle is located in response to an operation on the target fluid particle, wherein the operation involves calculation of multiple consecutive frames; in the calculation process of each frame in the multiple consecutive frames, determine a fluid simulation algorithm that meets the requirement conditions according to the requirement conditions corresponding to the operation, wherein the requirement conditions at least include: the amount of fluid particle calculation, the running speed requirement, the interaction requirement, and the iteration requirement; A calculation module, used for calculating the current position and current velocity of the target fluid particle according to the determined fluid simulation algorithm and the collision constraints contained in the scene object where the target fluid particle is located; A rendering module is used to render and display the target fluid particles based on the current position and current speed of the target fluid particles.

9. A computing device, characterized in that It comprises a processing component and a storage component; the storage component stores one or more computer instructions; the one or more computer instructions are used to be called and executed by the processing component to implement the fluid particle processing method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that: A computer program is stored, and when the computer executes the computer program, the fluid particle processing method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Particle motion trail simulation method and electronic equipment

    CN120217814A

  • Protein molecular structure simulation method based on Niagara particle calculation

    CN121096421A

  • A method for simulating protein molecular structure based on Niagara particle calculations

    CN121096421B

  • Particle driving fluid simulation and rendering method of mobile phone terminal

    CN121685804A