A real-time smoke simulation method and system based on Lagrangian perspective

Through the real-time smoke simulation method based on the Lagrangian perspective, GPU parallel calculation is used to solve the problems of high calculation cost and numerical dissipation of existing gas simulation solutions, and efficient and accurate gas motion simulation is achieved.

CN114564875BActive Publication Date: 2025-05-06FUJIAN TIANQUAN EDUCATION TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011356568.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-27
Publication Date
2025-05-06
Estimated Expiration
2040-11-27

AI Technical Summary

Technical Problem

The existing gas simulation schemes are costly when calculating gas particles in real time, and have disadvantages such as numerical dissipation.

Method used

The real-time smoke simulation method based on the Lagrangian perspective is adopted, and the parallel computing power of the GPU is used to support the calculation of a large number of gas particles. The gas movement is accurately simulated by initializing fluid and smoke particles, applying gravity and surface tension, maintaining incompressibility, introducing resistance and vortex force.

Benefits of technology

The calculation efficiency of smoke simulation simulation is improved, the calculation cost is reduced, and the numerical dissipation is reduced, achieving more accurate gas motion simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114564875B_ABST
    Figure CN114564875B_ABST
Patent Text Reader

Abstract

The present invention provides a real-time smoke simulation method based on Lagrangian perspective, and the method comprises the following steps: step S1, initializing fluid particles and smoke particles; step S2, applying gravity to the fluid particles to obtain the speed and predicted position of each fluid particle after being subjected to gravity, and applying surface tension to the fluid particles to further correct the speed and predicted position of the particles after being subjected to tension; step S3, maintaining the incompressibility of the fluid particles; step S4, in order to simulate the influence of air resistance in the environment on smoke, introducing resistance and vortex force into the fluid simulation to further correct the speed of the fluid particles after the above-mentioned calculation steps; step S5, updating the smoke speed and the position information of the smoke particles by means of the speed of the fluid particles; the present invention simulates the smoke movement more accurately by means of the powerful parallel computing capability of a GPU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of real-time rendering of realistic graphics, and in particular to a real-time smoke simulation method and system based on Lagrangian perspective, which can simulate gas movement in real time. Background Art

[0002] The mainstream gas simulation scheme uses the Euler method to start from each fixed point occupied by the gas, analyze the change of physical parameters of each fixed point in the space filled with gas over time, and the change of parameters when transferring from one spatial point to another spatial point. This method has a fixed solution domain, which is easy to waste computing resources, and there is serious numerical dissipation in the fallback solution method for calculating convection terms. That is, the existing gas simulation scheme has high computational cost in real-time calculation of gas particles and has shortcomings such as numerical dissipation.

[0003] Lagrangian perspective and Euler perspective; for the simulation of various media in physics-based animations, the media can be observed from two perspectives, one is the Lagrangian perspective and the other is the Euler perspective.

[0004] The Lagrangian perspective generally views the medium as a collection of particles (or tiny grids) that move with the medium, and the changes in the medium are represented by calculating the motion state and force conditions of each particle.

[0005] The Euler perspective usually divides the space occupied by the medium into small grids, and calculates the state of the medium in each small grid, the input and output conditions, and the impact on other grids. Summary of the invention

[0006] To overcome the above problems, the purpose of the present invention is to provide a real-time smoke simulation method based on Lagrangian perspective, which can support the calculation of a large number of gas particles and accurately simulate gas movement with the help of the powerful parallel computing capability of GPU.

[0007] The present invention is implemented by the following scheme: a real-time smoke simulation method based on Lagrangian perspective, the method comprising the following steps:

[0008] Step S1, initializing fluid particles and smoke particles;

[0009] Step S2, applying gravity to the fluid particles to obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and applying surface tension to the fluid particles to further correct the velocity and predicted position of the particles after being subjected to surface tension;

[0010] Step S3, maintaining the incompressibility of the fluid particles;

[0011] Step S4: In order to simulate the effect of air resistance in the environment on smoke, drag and vortex force are introduced into the fluid simulation to

[0012] Further correcting the velocity of the fluid particles after the above calculation steps;

[0013] Step S5: Update the smoke velocity and the position information of the smoke particles by using the velocity of the fluid particles.

[0014] Furthermore, the step S1 is further specified as follows: smoke is affected by the convection of the air in the environment, and in order to simulate real smoke, two types of particles need to be used, one type is fluid particles, and the other type is smoke particles;

[0015] Set the data structure of fluid particles to: ComputeBuffer Positions; ComputeBufferPredictedPos; ComputeBuffer Velocities; ComputeBuffer Density; ComputeBufferPressures; ComputeBuffer Mass; ComputeBuffer LifeTime; Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the predicted position value to Positions, Density represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles;

[0016] Set the data structure of smoke particles to:

[0017] ComputeBuffer smokePositions; ComputeBuffer smokeVelocities; ComputeBuffer smokeLifeTime; Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

[0018] Furthermore, the step S2 is further specifically as follows: when the simulation process starts, the fluid is affected by gravity, and the number of threads of the total number of fluid particles is started to calculate the velocity Velocities of each fluid particle after being affected by gravity:

[0019] Velocities[i] after being affected by gravity = Velocities[i] of the previous frame + deltaTime·α·gravity;

[0020] At the same time, update the predicted position PredictedPos:

[0021] Predicted position after gravity PredictedPos[i] = Positions[i] + Velocities[i] after gravity·deltaTime;

[0022] Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Position[i] is the current position of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the set adjustment coefficient;

[0023] Cohesion is the mutual attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. The formula for cohesion is:

[0024]

[0025] Where cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j, C_R is the kernel function specific to calculating cohesion, and r is the distance between two adjacent particles;

[0026] The surface tension is calculated as:

[0027] tension=K·(curvature+cohesion)

[0028] Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, K is the symmetry correction factor, K can be calculated according to the following formula;

[0029]

[0030] Where InitDensities is the initial density of the fluid particles, Density[i] is the density of fluid particle i, Density[j] is the density of fluid particle j, and k is the total number of neighboring particles within the radius of the smooth core;

[0031] The calculation formula of curvature force is as follows:

[0032]

[0033] Among them, CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of fluid particles i and j, and k is the total number of neighboring particles within the radius of the smooth core. The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step.

[0034] Velocities[i] after surface tension = Velocities[i] after gravity + deltaTime·tension / Masses[i]

[0035] Predicted position after surface tension PredictedPos[i] = Predicted position after gravity PredictedPos[i] + Velocities[i] after surface tension·deltaTime

[0036] Where i is the index value of the current fluid particle, tension is the surface tension of particle i, and PredictedPos[i]

[0037] The predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0038] Furthermore, the step S3 is further specifically as follows: the calculation of maintaining the incompressibility of the fluid particles is divided into three steps:

[0039] Calculate density

[0040]

[0041] Where Poly6Kernel is the Poly6 kernel function, Masses[j] is the mass of fluid particle j, r is the distance between fluid particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius;

[0042] Calculating pressure

[0043]

[0044] Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function;

[0045] Calculate the displacement to be corrected based on the pressure

[0046]

[0047] Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of fluid particles i and j respectively, Masses[i] is the mass of fluid particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smoothing kernel radius.

[0048] The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle.

[0049] Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr

[0050] At the same time, update the fluid particle position attributes of the next frame:

[0051] Positon[i] = Corrected predicted position PredictedPos[i]

[0052] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame.

[0053] Furthermore, the step S4 is further specifically as follows: introducing drag in the fluid simulation, drag=DragCoefficient·(Velocities[i]-EnviVel)·(Density[i]·InvDensity-1.0f), wherein DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the environmental velocity, and this item can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density;

[0054] Because of the introduction of additional resistance, the energy of the gas particles will be lost, and the fluid particles cannot show the effect of rotating and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy force is as follows:

[0055]

[0056] Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the particle, and k is the total number of neighboring particles within the smooth kernel radius.

[0057] The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute.

[0058] Velocities[i] after drag and vorticity = Velocities[i] after surface tension + deltaTime·(drag+vorticity) / Masses[i]

[0059] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0060] Furthermore, the step S5 is further specifically as follows: in order to simulate the convection effect of air on gas particles, the fluid particles previously subject to density constraints are used to simulate the convection of air, and the motion state of the real smoke particles is determined by the surrounding fluid particles; the number of threads for the total number of particles is opened, and the calculated fluid particle velocity data is assigned to the velocity of the smoke particles;

[0061]

[0062] Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the radius of the smooth kernel;

[0063] According to the speed of smoke particles, the position of smoke particles can be calculated:

[0064] The position of the smoke particle in the current frame smokePositions[i] = the position of the smoke particle in the previous frame

[0065] Where smokePosition[i] is the position of the smoke particle, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and fluid particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame.

[0066] Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using the GPU graphics rendering interface to achieve real-time smoke simulation.

[0067] The present invention also provides a real-time smoke simulation system based on Lagrangian perspective, the system comprising an initialization module, a gravity and tension application module, a compressibility maintenance module, an external force introduction module, and an update module;

[0068] The initialization module is used to initialize fluid particles and smoke particles;

[0069] The gravity and tension applying module is used to apply gravity to the fluid particles, obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and apply surface tension to the fluid particles;

[0070] The compressibility maintaining module is used to maintain the incompressibility of fluid particles;

[0071] The external force introduction module introduces resistance and vortex force into the fluid simulation in order to simulate the influence of air resistance in the environment on smoke;

[0072] The updating module is used to update the smoke velocity and the position information of the smoke particles by means of the velocity of the fluid particles.

[0073] Furthermore, the implementation of the initialization module is further specifically as follows: smoke is affected by the convection of air in the environment, and in order to simulate real smoke, two types of particles need to be used, one is fluid particles and the other is smoke particles;

[0074] Set the data structure of fluid particles to: ComputeBuffer Positions; ComputeBufferPredictedPos; ComputeBuffer Velocities; ComputeBuffer Density; ComputeBufferPressures; ComputeBuffer Mass; ComputeBuffer LifeTime; Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the predicted position value to Positions, Density represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles;

[0075] Set the data structure of smoke particles to:

[0076] ComputeBuffer smokePositions; ComputeBuffer smokeVelocities; ComputeBuffer smokeLifeTime; Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

[0077] Furthermore, the implementation of the gravity and tension application module is further specific as follows: at the beginning of the simulation process, the fluid is affected by gravity, and the number of threads of the total number of fluid particles is opened to calculate the velocity Velocities of each fluid particle after being affected by gravity:

[0078] Velocities[i] after being affected by gravity = Velocities[i] of the previous frame + deltaTime·α·gravity;

[0079] At the same time, update the predicted position PredictedPos:

[0080] Predicted position after gravity PredictedPos[i] = Positions[i] + Velocities[i] after gravity·deltaTime;

[0081] Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Position[i] is the current position of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the set adjustment coefficient;

[0082] Cohesion is the mutual attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. The formula for cohesion is:

[0083]

[0084] Where cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j, C_R is the kernel function specific to calculating cohesion, and r is the distance between two adjacent particles;

[0085] The surface tension is calculated as:

[0086] tension=K·(curvature+cohesion)

[0087] Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, K is the symmetry correction factor, K can be calculated according to the following formula;

[0088]

[0089] Where InitDensities is the initial density of the fluid particles, Density[i] is the density of fluid particle i, Density[j] is the density of fluid particle j, and k is the total number of neighboring particles within the radius of the smooth core;

[0090] The calculation formula of curvature force is as follows:

[0091]

[0092] Where CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of fluid particles i and j, and k is the total number of neighboring particles within the smooth core radius.

[0093] The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step.

[0094] Velocities[i] after surface tension = Velocities[i] after gravity + deltaTime·tension / Masses[i]

[0095] Predicted position after surface tension PredictedPos[i] = Predicted position after gravity PredictedPos[i] + Velocities[i] after surface tension·deltaTime

[0096] Where i is the index value of the current fluid particle, tension is the surface tension of particle i, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0097] Furthermore, the implementation of the compressibility maintaining module is further specifically as follows: the calculation of maintaining the incompressibility of fluid particles is divided into three steps:

[0098] Calculate density

[0099]

[0100] Where Poly6Kernel is the Poly6 kernel function, Masses[j] is the mass of fluid particle j, r is the distance between fluid particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius;

[0101] Calculating pressure

[0102]

[0103] Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function;

[0104] Calculate the displacement to be corrected based on the pressure

[0105]

[0106] Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of fluid particles i and j respectively, Masses[i] is the mass of fluid particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smoothing kernel radius.

[0107] The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle.

[0108] Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr

[0109] At the same time, update the fluid particle position attributes of the next frame:

[0110] Positon[i] = Corrected predicted position PredictedPos[i]

[0111] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame.

[0112] Furthermore, the implementation method of the external force introduction module is further specifically as follows: introducing drag in the fluid simulation, drag = DragCoefficient · (Velocities[i] - EnviVel) · (Density[i] · InvDensity - 1.0f) where DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the environmental velocity, and this item can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density;

[0113] Because of the introduction of additional resistance, the energy of the gas particles will be lost, and the fluid particles cannot show the effect of rotating and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy force is as follows:

[0114]

[0115] Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the particle, and k is the total number of neighboring particles within the smooth kernel radius.

[0116] The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute.

[0117] Velocities[i] after drag and vorticity = Velocities[i] after surface tension + deltaTime·(drag+vorticity) / Masses[i]

[0118] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0119] Furthermore, the implementation of the update module is further specifically as follows: in order to simulate the convection effect of air on gas particles, the fluid particles previously subject to density constraints are used to simulate the convection of air, and the motion state of the real smoke particles is determined by the surrounding fluid particles; the number of threads for the total number of particles is turned on, and the calculated fluid particle velocity data is assigned to the velocity of the smoke particles;

[0120]

[0121] Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the radius of the smooth kernel;

[0122] According to the speed of smoke particles, the position of smoke particles can be calculated:

[0123]

[0124] Where smokePosition[i] is the position of the smoke particle, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and fluid particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame.

[0125] Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using the GPU graphics rendering interface to achieve real-time smoke simulation.

[0126] The beneficial effect of the present invention is that: in view of the shortcomings of existing gas simulation schemes such as high cost of real-time calculation of gas particles and numerical dissipation, this patent proposes a real-time smoke simulation method based on Lagrangian perspective, which supports a large number of gas particle calculations and accurately simulates gas movement with the help of the powerful parallel computing capability of GPU. The computational efficiency of smoke simulation is improved and the cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0127] Figure 1 It is a schematic flow chart of the method of the present invention.

[0128] Figure 2 It is a system principle block diagram of the present invention. DETAILED DESCRIPTION

[0129] The present invention will be further described below in conjunction with the accompanying drawings.

[0130] See also Figure 1 As shown, a real-time smoke simulation method based on Lagrangian perspective of the present invention comprises the following steps:

[0131] Step S1, initializing fluid particles and smoke particles;

[0132] Step S2, applying gravity to the fluid particles to obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and applying surface tension to the fluid particles to further correct the velocity and predicted position of the particles after being subjected to surface tension;

[0133] Step S3, maintaining the incompressibility of the fluid particles;

[0134] Step S4: In order to simulate the effect of air resistance in the environment on smoke, drag and vortex force are introduced into the fluid simulation to

[0135] Further correcting the velocity of the fluid particles after the above calculation steps;

[0136] Step S5: Update the smoke velocity and the position information of the smoke particles by using the velocity of the fluid particles. The definition of the Lagrangian perspective in this patent is simply based on the motion calculation of particles. Each calculation step in this patent is to calculate the motion force, position, and velocity of the particles, so each step reflects the physical simulation based on the Lagrangian perspective.

[0137] The present invention will be further described below in conjunction with a specific embodiment:

[0138] The present invention provides a real-time smoke simulation method based on Lagrangian perspective, which is divided into the following five steps:

[0139] 1. Initialize fluid particles and smoke particles

[0140] Since smoke is affected by the convection of the air in the environment, in order to simulate real smoke, two types of particles are needed. One type is fluid particles, which are constrained by density and used to simulate air convection. The other type is smoke particles, whose motion state is determined by the fluid particles moving around them.

[0141] The data structure of fluid particles is as follows:

[0142] ComputeBufferPositions;

[0143] ComputeBuffer PredictedPos;

[0144] ComputeBuffer Velocities;

[0145] ComputeBuffer Density;

[0146] ComputeBufferPressures;

[0147] ComputeBuffer Mass;

[0148] ComputeBuffer LifeTime;

[0149] Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the value of the predicted position to Positions, Densities represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles.

[0150] The data structure of smoke particles is as follows:

[0151] ComputeBuffer smokePositions;

[0152] ComputeBuffer smokeVelocities;

[0153] ComputeBuffer smokeLifeTime;

[0154] Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

[0155] 2. Apply gravity and surface tension to fluid particles

[0156] At the beginning of the simulation process, the fluid will be affected by external forces such as gravity and tension. The number of threads for the total number of particles is turned on to calculate the velocity of each particle after being affected by gravity:

[0157] Velocities[i] after being affected by gravity = Velocities[i] of the previous frame + deltaTime·α·gravity;

[0158] At the same time, update the predicted position PredictedPos:

[0159] Predicted position after gravity PredictedPos[i] = Positions[i] + Velocities[i] after gravity·deltaTime;

[0160] Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Position[i] is the current position of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the manually set adjustment coefficient. Since the fluid here is to simulate the convection in the air, α is used to adjust the value of gravitational acceleration.

[0161] Cohesion is the attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. Inside the liquid, molecules are subjected to molecular forces from all directions that cancel each other out.

[0162]

[0163] Among them, cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j, and C_R is the kernel function specific to calculating cohesion. [1] , r is the distance between two adjacent fluid particles.

[0164] The surface tension is calculated as:

[0165] tension=K·(curvature+cohesion)

[0166] Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, and K is the symmetry correction factor. K can be calculated according to the following formula.

[0167]

[0168] Where InitDensities is the initial density, Density[i] is the density of fluid particle i, Density[j] is the density of particle j, and k is the total number of neighboring particles within the smooth core radius.

[0169] The calculation formula of curvature force is as follows:

[0170]

[0171] Where CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of particles i and j, and k is the total number of neighboring particles within the smooth kernel radius.

[0172] The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step.

[0173] Velocities[i] after surface tension = Velocities[i] after gravity + deltaTime·tension / Masses[i]

[0174] Predicted position after surface tension PredictedPos[i] = Predicted position after gravity PredictedPos[i] + Velocities[i] after surface tension·deltaTime

[0175] Where i is the index value of the current fluid particle, tension is the surface tension of particle i, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0176] 3. Maintain the incompressibility of fluid particles

[0177] Real fluids will change their volume, but the amplitude is usually not large. Simulating these small volume changes of fluids is very complex and time-consuming, and from a macroscopic point of view, their impact on fluid motion is very small. Therefore, in general, the field of fluid simulation animation does not consider the change of fluid volume, that is, fluids are incompressible.

[0178] The calculation to maintain the incompressibility of fluid particles is divided into three steps:

[0179] 3.1 Calculation of density

[0180]

[0181] Among them, Poly6Kernel is the Poly6 kernel function [2] , Masses[j] is the mass of particle j, and r is the distance between particles i and j.

[0182] 3.2 Calculation of pressure

[0183]

[0184] Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function.

[0185] 3.3 Calculate the displacement to be corrected based on pressure

[0186]

[0187] Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of particles i and j respectively, Masses[i] is the mass of particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smooth kernel radius.

[0188] The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle.

[0189] Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr

[0190] At the same time, update the fluid particle position attributes of the next frame:

[0191] Positon[i] = Corrected predicted position PredictedPos[i]

[0192] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame. PredictedPos[i] appears twice in the formula here, so let’s explain it here:

[0193] The PredictedPos[i] on the left side of the equal sign in the formula represents the result of the operation. The meaning of this formula is that after adding an offset to the variable PredictedPos[i] itself, a correction is obtained. PredictedPos[i] means the predicted position. When the particle is subjected to various forces, the predicted position after multiple corrections is finally written back to the particle's position attribute Posion[i] as the particle's position in the next frame.

[0194] 4. Calculate environmental resistance and vortex force

[0195] In order to simulate the effect of air resistance in the environment on smoke, resistance is introduced in the fluid simulation.

[0196] drag=DragCoefficient·(Velocities[i]-EnviVel)·(Density[i]·InvDensity-1.0f) where DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the ambient velocity, and this item can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density.

[0197] Because of the introduction of additional resistance, the energy of the gas particles will be lost, and it is impossible to show the effect of rotation and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy force is as follows:

[0198]

[0199] Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the fluid particle, and k is the total number of neighboring particles within the smooth kernel radius.

[0200] The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute.

[0201] Velocities[i] after drag and vorticity = Velocities[i] after surface tension + deltaTime·(drag+vorticity) / Masses[i]

[0202] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0203] 5. Update smoke speed and position

[0204] The flow of air makes the smoke present an irregular shape. In order to simulate the convection of air on gas particles, we use the fluid particles constrained by density to simulate the convection of air. The motion state of real smoke particles is determined by the surrounding fluid particles. Open the number of threads for the total number of particles and assign the calculated fluid particle velocity data to the velocity of smoke particles.

[0205]

[0206] Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius.

[0207] According to the speed of smoke particles, the position of smoke particles can be calculated:

[0208]

[0209] Where smokePosition[i] is the position of the smoke particle, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame.

[0210] Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using a graphics drawing interface to achieve real-time smoke simulation.

[0211] like Figure 2 As shown, the present invention also provides a real-time smoke simulation system based on Lagrangian perspective, the system comprising an initialization module, a gravity and tension application module, a compressibility maintenance module, an external force introduction module, and an update module;

[0212] The initialization module is used to initialize fluid particles and smoke particles;

[0213] The gravity and tension applying module is used to apply gravity to the fluid particles, obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and apply surface tension to the fluid particles;

[0214] The compressibility maintaining module is used to maintain the incompressibility of fluid particles;

[0215] The external force introduction module introduces resistance and vortex force into the fluid simulation in order to simulate the influence of air resistance in the environment on smoke;

[0216] The updating module is used to update the smoke velocity and the position information of the smoke particles by means of the velocity of the fluid particles.

[0217] The implementation of the initialization module is further specifically as follows: smoke is affected by the convection of the air in the environment. To simulate real smoke, two types of particles are needed, one is fluid particles and the other is smoke particles;

[0218] Set the data structure of fluid particles to: ComputeBuffer Positions; ComputeBufferPredictedPos; ComputeBuffer Velocities; ComputeBuffer Density; ComputeBufferPressures; ComputeBuffer Mass; ComputeBuffer LifeTime; Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the predicted position value to Positions, Density represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles;

[0219] Set the data structure of smoke particles to:

[0220] ComputeBuffer smokePositions; ComputeBuffer smokeVelocities; ComputeBuffer smokeLifeTime; Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

[0221] The implementation of the gravity and tension application module is further specified as follows: at the beginning of the simulation process, the fluid is affected by gravity, and the number of threads of the total number of fluid particles is opened to calculate the velocity Velocities of each fluid particle after being affected by gravity:

[0222] Velocities[i] after being affected by gravity = Velocities[i] of the previous frame + deltaTime·α·gravity;

[0223] At the same time, update the predicted position PredictedPos:

[0224] Predicted position after gravity PredictedPos[i] = Positions[i] + Velocities[i] after gravity·deltaTime;

[0225] Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Position[i] is the current position of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the set adjustment coefficient;

[0226] Cohesion is the mutual attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. The formula for cohesion is:

[0227]

[0228] Where cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j, C_R is the kernel function specific to calculating cohesion, and r is the distance between two adjacent particles;

[0229] The surface tension is calculated as:

[0230] tension=K·(curvature+cohesion)

[0231] Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, K is the symmetry correction factor, K can be calculated according to the following formula;

[0232]

[0233] Where InitDensities is the initial density of the fluid particles, Density[i] is the density of fluid particle i, Density[j] is the density of fluid particle j, and k is the total number of neighboring particles within the radius of the smooth core;

[0234] The calculation formula of curvature force is as follows:

[0235]

[0236] Where CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of fluid particles i and j, and k is the total number of neighboring particles within the smooth core radius.

[0237] The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step.

[0238] Velocities[i] after surface tension = Velocities[i] after gravity + deltaTime·tension / Masses[i]

[0239] Predicted position after surface tension PredictedPos[i] = Predicted position after gravity PredictedPos[i] + Velocities[i] after surface tension · deltaTime

[0240] Where i is the index value of the current fluid particle, tension is the surface tension of particle i, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0241] The implementation of the compressibility maintenance module is further specifically as follows: the calculation of maintaining the incompressibility of fluid particles is divided into three steps:

[0242] Calculate density

[0243]

[0244] Where Poly6Kernel is the Poly6 kernel function, Masses[j] is the mass of fluid particle j, r is the distance between fluid particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius;

[0245] Calculating pressure

[0246]

[0247] Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function;

[0248] Calculate the displacement to be corrected based on the pressure

[0249]

[0250] Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of fluid particles i and j respectively, Masses[i] is the mass of fluid particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smoothing kernel radius.

[0251] The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle.

[0252] Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr

[0253] At the same time, update the fluid particle position attributes of the next frame:

[0254] Positon[i] = Corrected predicted position PredictedPos[i]

[0255] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame.

[0256] The implementation method of the external force introduction module is further specifically as follows: introducing drag in the fluid simulation, drag = DragCoefficient · (Velocities[i] - EnviVel) · (Density[i] · InvDensity - 1.0f) where DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the environmental velocity, and this item can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density;

[0257] Because of the introduction of additional resistance, the energy of the gas particles will be lost, and the fluid particles cannot show the effect of rotating and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy force is as follows:

[0258]

[0259] Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the particle, and k is the total number of neighboring particles within the smooth kernel radius.

[0260] The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute.

[0261] Velocities[i] after drag and vorticity = Velocities[i] after surface tension + deltaTime·(drag+vorticity) / Masses[i]

[0262] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

[0263] Furthermore, the implementation of the update module is further specifically as follows: in order to simulate the convection effect of air on gas particles, the fluid particles previously subject to density constraints are used to simulate the convection of air, and the motion state of the real smoke particles is determined by the surrounding fluid particles; the number of threads for the total number of particles is turned on, and the calculated fluid particle velocity data is assigned to the velocity of the smoke particles;

[0264]

[0265] Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the radius of the smooth kernel;

[0266] According to the speed of smoke particles, the position of smoke particles can be calculated:

[0267]

[0268] Among them, smokePosition[i] is the position of the smoke particle, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and fluid particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame. In the formula, the first smokePosition[i] represents the position of the smoke particle to be obtained, that is, the position of the smoke particle in the next frame; the second smokePosition[i] represents the position of the smoke particle in the current frame. In the initial frame, the position of the smoke particle is unified to (0, 0, 0), and the initialization work is performed in the initial frame.

[0269] Take a particle:

[0270] The smoke particle is at frame 0, and its position is (0, 0, 0);

[0271] In the first frame, the position is assumed to be:

[0272] smokePositions[i] = (0, 0, 0) + displacement generated in this frame = (1, 1, 1);

[0273] In the second frame, the position is:

[0274] smokePositions[i] = the position of the previous frame (1,1,1) + the displacement of this frame = (2,2,2).

[0275] The meaning of the formula is that the position of the smoke particle = the position of the previous frame + the displacement generated by the current frame

[0276] This variable represents the position of the smoke particles regardless of the previous frame or the current frame.

[0277] Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using the GPU graphics rendering interface to achieve real-time smoke simulation.

[0278] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A real-time smoke simulation method based on Lagrangian perspective, characterized in that: The method comprises the following steps: Step S1, initializing fluid particles and smoke particles; Step S2, applying gravity to the fluid particles to obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and applying surface tension to the fluid particles to further correct the velocity and predicted position of the particles after being subjected to surface tension; Step S3, maintaining the incompressibility of the fluid particles; Step S4: In order to simulate the influence of air resistance in the environment on smoke, drag and vortex force are introduced into the fluid simulation to further correct the velocity of the fluid particles after the above calculation steps; Step S5, updating the smoke velocity and the position information of the smoke particles by using the velocity of the fluid particles; The step S4 is further specifically as follows: introducing drag in the fluid simulation, drag=DragCoefficient·(Velocities[i]-EnviVel)·(Density[i]·InvDensity-1.0f)where, DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the ambient velocity, which can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density; Because of the introduction of additional resistance, the energy of the gas particles will be lost, and the fluid particles cannot show the effect of rotating and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy current force is as follows: Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the particle, k is the total number of neighboring particles within the smooth kernel radius, and r is the distance between fluid particles i and j; The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute; Velocities[i] after drag and eddy force = Velocities[i] after surface tension +deltaTime·(drag+vorticity) / Masses[i] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, deltaTime is the time step of each frame.

2. The real-time smoke simulation method based on Lagrangian perspective according to claim 1, characterized in that: The step S1 is further specifically as follows: smoke is affected by the convection of the air in the environment. To simulate real smoke, two types of particles need to be used, one is fluid particles and the other is smoke particles; Set the data structure of fluid particles to: ComputeBuffer Positions; ComputeBufferPredictedPos; ComputeBuffer Velocities; ComputeBuffer Density; ComputeBufferPressures; ComputeBuffer Mass; ComputeBuffer LifeTime; Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the predicted position value to Positions, Density represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles; Set the data structure of smoke particles to: ComputeBuffer smokePositions; ComputeBuffer smokeVelocities; ComputeBuffersmokeLifeTime; Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

3. The real-time smoke simulation method based on Lagrangian perspective according to claim 2, characterized in that: The step S2 is further specifically as follows: at the beginning of the simulation process, the fluid is affected by gravity, and the number of threads of the total number of fluid particles is started to calculate the velocity Velocities of each fluid particle after being affected by gravity: Velocities[i] after being affected by gravity = Velocities[i] of the previous frame +deltaTime·α·gravity; At the same time, update the predicted position PredictedPos: Predicted position after gravity PredictedPos[i] = Positions[i] + Velocities[i]·deltaTime after being affected by gravity; Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle after being affected by gravity, Velocities[i] is the velocity of the fluid particle, Position[i] is the current position of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the set adjustment coefficient; Cohesion is the mutual attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. The formula for cohesion is: Where cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j, C_R is the kernel function specific to calculating cohesion, and r is the distance between two adjacent particles. The surface tension is calculated as follows: tension=K·(curvature+cohesion) Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, K is the symmetry correction factor, K can be calculated according to the following formula; Where InitDensities is the initial density of the fluid particles, Density[i] is the density of fluid particle i, Density[j] is the density of fluid particle j, and k is the total number of neighboring particles within the radius of the smooth core; The calculation formula of curvature force is as follows: Where CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of fluid particles i and j, and k is the total number of neighboring particles within the radius of the smooth core. The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step: Velocities[i] after surface tension = Velocities[i] after gravity +deltaTime·tension / Masses[i] PredictedPos[i] after surface tension = PredictedPos[i] after gravity + Velocities[i] after surface tension·deltaTime Where i is the index value of the current fluid particle, tension is the surface tension of particle i, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

4. The real-time smoke simulation method based on Lagrangian perspective according to claim 3, characterized in that: The step S3 is further specifically as follows: the calculation of maintaining the incompressibility of the fluid particles is divided into three steps: Calculate density Where Poly6Kernel is the Poly6 kernel function, Masses[j] is the mass of fluid particle j, r is the distance between fluid particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius; Calculating pressure Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function; Calculate the displacement to be corrected based on the pressure Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of fluid particles i and j respectively, Masses[i] is the mass of fluid particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smooth kernel radius; The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle; Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr. At the same time, update the fluid particle position attributes of the next frame: Positon[i] = Corrected predicted position PredictedPos[i] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame.

5. The real-time smoke simulation method based on Lagrangian perspective according to claim 1, characterized in that: The step S5 is further specifically as follows: in order to simulate the convection effect of air on gas particles, the fluid particles previously subject to density constraints are used to simulate the convection of air, and the motion state of the real smoke particles is determined by the surrounding fluid particles; the number of threads for the total number of particles is opened, and the calculated fluid particle velocity data is assigned to the velocity of the smoke particles; Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the radius of the smooth kernel; According to the speed of smoke particles, the position of smoke particles can be calculated: The position of the smoke particle in the current frame smokePositions[i] = the position of the smoke particle in the previous frame Where smokePostions[i] on the left side of the equal sign is the position of the smoke particle in the next frame, smokePostions[i] on the right side is the position of the smoke particle in the current frame, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and fluid particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame; Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using the GPU graphics rendering interface to achieve real-time smoke simulation.

6. A real-time smoke simulation system based on Lagrangian perspective, characterized in that: The system includes an initialization module, a gravity and tension application module, a compressibility maintenance module, an external force introduction module, and an update module; The initialization module is used to initialize fluid particles and smoke particles; The gravity and tension applying module is used to apply gravity to the fluid particles, obtain the velocity and predicted position of each fluid particle after being subjected to gravity, and apply surface tension to the fluid particles; The compressibility maintaining module is used to maintain the incompressibility of fluid particles; The external force introduction module introduces resistance and vortex force into the fluid simulation in order to simulate the influence of air resistance in the environment on smoke; The updating module is used to update the smoke velocity and the position information of the smoke particles by means of the velocity of the fluid particles; The implementation method of the external force introduction module is further specifically as follows: introducing drag in the fluid simulation, drag = DragCoefficient · (Velocities[i] - EnviVel) · (Density[i] · InvDensity - 1.0f) where DragCoefficient is the drag coefficient, Velocities[i] is the velocity of fluid particle i after surface tension, EnviVel is the environmental velocity, and this item can be omitted in a still and windless environment; Density[i] is the density of fluid particle i, and InvDensity is the inverse of the initial fluid density; Because of the introduction of additional resistance, the energy of the gas particles will be lost, and the fluid particles cannot show the effect of rotating and circling in the real world. Therefore, eddy force is added to accelerate the rotation of the particles and re-inject energy into the particles. The calculation formula of eddy force is as follows: Where vorticity is the vortex force, PredictedPos[i] and PredictedPos[j] are the predicted positions of fluid particles i and j respectively, Poly6Kernel is the Poly6 kernel function, ω is the curl of the particle, k is the total number of neighboring particles within the smooth kernel radius, and r is the distance between fluid particles i and j; The calculated drag and acceleration generated by the eddy force are added to the particle's velocity attribute; Velocities[i] after drag and eddy force = Velocities[i] after surface tension +deltaTime·(drag+vorticity) / Masses[i] Where Velocities[i] is the velocity of fluid particle i, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

7. The real-time smoke simulation system based on Lagrangian perspective according to claim 6, characterized in that: The implementation of the initialization module is further specifically as follows: smoke is affected by the convection of the air in the environment. To simulate real smoke, two types of particles are needed, one is fluid particles and the other is smoke particles; Set the data structure of fluid particles to: ComputeBuffer Positions; ComputeBufferPredictedPos; ComputeBuffer Velocities; ComputeBuffer Density; ComputeBufferPressures; ComputeBuffer Mass; ComputeBuffer LifeTime; Among them, Positions saves the actual position of the fluid particles, PredictedPos and Velocities are used to calculate the predicted position and velocity data of each fluid particle in the simulation, and finally assign the predicted position value to Positions, Density represents the density information of each particle, Pressures is the pressure value of each particle, Mass is the mass, and LifeTime is used to control the life cycle of the fluid particles; Set the data structure of smoke particles to: ComputeBuffer smokePositions; ComputeBuffer smokeVelocities; ComputeBuffersmokeLifeTime; Among them, smokePositions saves the actual position of the smoke particles, smokeVelocities is the speed of the smoke particles, and smokeLifeTime is used to control the life cycle of the smoke particles.

8. The real-time smoke simulation system based on Lagrangian perspective according to claim 7, characterized in that: The implementation method of the gravity and tension application module is further specifically as follows: at the beginning of the simulation process, the fluid will be affected by gravity, and the number of threads of the total number of fluid particles is opened to calculate the velocity Velocities of each fluid particle after being affected by gravity: And the predicted position PredictedPos: Where i is the index value of the current fluid particle, PredictedPos[i] is the predicted position of the fluid particle, Position[i] is the current position of the fluid particle, Velocities[i] is the velocity of the fluid particle, deltaTime is the time step of each frame, gravity is the gravitational acceleration, and α is the set adjustment coefficient; Cohesion is the mutual attraction between adjacent molecules in a liquid. Surface tension is caused by the cohesion between liquid molecules. The formula for cohesion is: Among them, cohension is the cohesion, CohensionCoefficient is the cohesion coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, and PredictedPos[i] and PredictedPos[j] are the fluid The predicted position of particles i and j, C_R is the kernel function for calculating cohesion, and r is the distance between two adjacent particles; the calculation formula for surface tension is: tension=K·(curvature+cohesion) Among them, tension is surface tension, cohesion is cohesion, curvature is curvature force, K is the symmetry correction factor, K can be calculated according to the following formula; Where InitDensities is the initial density of the fluid particles, Density[i] is the density of fluid particle i, Density[j] is the density of fluid particle j, and k is the total number of neighboring particles within the radius of the smooth core; The calculation formula of curvature force is as follows: Where CurCoefficient is the curvature force coefficient, Masses[i] and Masses[j] are the masses of fluid particles i and j respectively, Normal[i] and Normal[j] are the normal vector information of the surface of fluid particles i and j, and k is the total number of neighboring particles within the radius of the smooth core. The surface tension can be obtained by completing the above calculations. Furthermore, the acceleration generated by the surface tension acting on the particle can be easily obtained based on the mass of the particle. Similar to gravity, the acceleration generated by the surface tension will act on the predicted position and velocity of the particle, correcting the predicted position and velocity obtained in the previous step. Velocities[i] = Velocities[i] after being affected by gravity +deltaTime · tension / Masses[i] Where i is the index value of the current fluid particle, tension is the surface tension of particle i, PredictedPos[i] is the predicted position of the fluid particle, Velocities[i] is the velocity of the fluid particle, Masses[i] is the mass of fluid particle i, and deltaTime is the time step of each frame.

9. The real-time smoke simulation system based on Lagrangian perspective according to claim 8, characterized in that: The implementation of the compressibility maintenance module is further specifically as follows: the calculation of maintaining the incompressibility of fluid particles is divided into three steps: Calculate density Where Poly6Kernel is the Poly6 kernel function, Masses[j] is the mass of fluid particle j, r is the distance between fluid particle i and particle j, and k is the total number of neighboring particles within the smooth kernel radius; Calculating pressure Among them, the numerator C(p) of the formula is the density constraint, and the denominator ▽C(p) of the formula is the gradient of the constraint function; Calculate the displacement to be corrected based on the pressure Where corr corresponds to the displacement to be corrected under pressure, Presssures[i] and Presssures[j] correspond to the pressure of fluid particles i and j respectively, Masses[i] is the mass of fluid particle i, InvDensity is the inverse of the initial fluid density, gradW is the Spiky kernel function, and k is the total number of neighboring particles within the smooth kernel radius; The calculated corrected displacement will be added to the predicted position calculated in the previous step. The following formula PredictedPos[i] is the predicted position of the fluid particle; Corrected predicted position PredictedPos[i] = predicted position after surface tension PredictedPos[i] + corr. At the same time, update the fluid particle position attributes of the next frame: Positon[i] = Corrected predicted position PredictedPos[i] PredictedPos[i] is the predicted position of the fluid particle, and Position[i] corresponds to the position of the fluid particle in the next frame.

10. The real-time smoke simulation system based on Lagrangian perspective according to claim 6, characterized in that: The implementation of the update module is further specifically as follows: in order to simulate the convection effect of air on gas particles, the fluid particles previously subject to density constraints are used to simulate the convection of air, and the motion state of the real smoke particles is determined by the surrounding fluid particles; the number of threads for the total number of particles is turned on, and the calculated fluid particle velocity data is assigned to the velocity of the smoke particles; Where smokeVelocities[i] is the velocity of the smoke particle, Velocities[j] is the velocity of fluid particle j after being affected by drag and eddy forces, Poly6Kernel is the Poly6 kernel function, r is the distance between particle i and particle j, and k is the total number of neighboring particles within the radius of the smooth kernel; According to the speed of smoke particles, the position of smoke particles can be calculated: Where smokePosition[i] is the position of the smoke particle, smokeVelocities[i] is the velocity of smoke particle i, Poly6Kernel is the Poly6 kernel function, r is the distance between fluid particle i and fluid particle j, k is the total number of neighboring particles within the smooth kernel radius, and deltaTime is the time step of each frame; Finally, the position information of all smoke particles is obtained, and the position information is drawn on the screen using the GPU graphics rendering interface to achieve real-time smoke simulation.

Citation Information

Patent Citations

  • SPH fluid simulation method based on variable smooth length

    CN110781632A

  • Position based fluid dynamics simulation

    US20150161810A1