Search

CN-122021463-A - Fluid simulation method and related device

CN122021463ACN 122021463 ACN122021463 ACN 122021463ACN-122021463-A

Abstract

The application discloses a fluid simulation method and a related device, wherein a simulator is further modularized, a solving process is decomposed into executable minimum units, namely operators and solvers, each operator or solver is used for solving to obtain simulation parameters, and different operators and solvers are connected in series to form the simulator. The simulation parameters are all parameters obtained by solving in the process of sequentially solving the control equation and the parallel flow diffusion equation. There are a number of options for solvers of target parameters in the simulation parameters, and the solver of target parameters in the simulator is determined from a plurality of candidate solvers based on simulation influencing factors. When fluid simulation is carried out, a historical speed field of the fluid at a historical moment is obtained, and based on the historical speed field, a control equation and a advection diffusion equation are sequentially solved through the simulator, so that a advection post-density field of the fluid at the current moment is obtained. The fluid simulation method has stronger expansibility and can well adapt to the business requirements of complexity, variability and sensitive performance.

Inventors

  • LV YUANFENG

Assignees

  • 深圳市腾讯网络信息技术有限公司

Dates

Publication Date
20260512
Application Date
20260409

Claims (16)

  1. 1. A method of fluid simulation, the method comprising: acquiring a historical speed field of the fluid at a historical moment, wherein the historical moment is the moment before the current moment; Based on the historical speed field at the historical moment, sequentially solving a control equation and a advection diffusion equation through a simulator to obtain a advection post-density field of the fluid at the current moment; The simulator consists of different operators and solvers which are used for obtaining simulation parameters in series, each operator or solver is used for solving to obtain the simulation parameters, in the process of solving to obtain the advection post-density field, the solver used for solving the target parameters in the simulation parameters is determined from a plurality of candidate solvers based on simulation influence factors, and the simulation parameters are all parameters obtained through solving in sequence through the simulator in the process of solving the control equation and the advection diffusion equation.
  2. 2. The method according to claim 1, wherein the sequentially solving, by a simulator, a control equation and a advection diffusion equation based on the historical speed field at the historical moment to obtain a advection post-density field of the fluid at the current moment includes: And when the interactive object enters the interactive detection range, sequentially solving the control equation and the advection diffusion equation by the simulator based on the historical speed field to obtain the advection post-density field.
  3. 3. The method of claim 2, wherein the acquiring the historical velocity field of the fluid at the historical moment comprises: and when the interactive object enters an activation detection range, acquiring the historical speed field.
  4. 4. The method according to claim 1, wherein the sequentially solving, by a simulator, a control equation and a advection diffusion equation based on the historical speed field at the historical moment to obtain a advection post-density field of the fluid at the current moment includes: solving the control equation by the simulator based on the historical speed field; In the process of solving the control equation, updating the historical speed field through a speed field solver in the simulator to obtain an updated speed field, and carrying out advection on the updated speed field through a first advection operator in the simulator to obtain an advection speed field; solving the advection diffusion equation through the simulator based on the non-dispersion velocity field to obtain the advection post-density field; and carrying out advection on the initial density field by a second advection operator in the simulator based on the non-dispersion speed field to obtain the advection post-density field.
  5. 5. The method of claim 4, wherein updating the historical speed field by a speed field solver in the simulator results in an updated speed field, comprising: And updating the historical speed field through a speed field solver in the simulator based on the interactive external force generated by the interactive object at the current position to obtain an updated speed field.
  6. 6. The method of claim 5, wherein the number of interactive objects is a plurality, wherein the updating the historical speed field by the speed field solver in the simulator based on the interactive external force generated by the interactive objects at the current location to obtain the updated speed field comprises: Aiming at the interaction external force generated by each interaction object at the current position, calculating the change of a speed field corresponding to the interaction external force; Superposing the speed field changes corresponding to each interaction external force to obtain comprehensive changes; And updating the historical speed field by using the comprehensive change through a speed field solver in the simulator to obtain the updated speed field.
  7. 7. The method of claim 4, wherein updating the historical speed field by a speed field solver in the simulator results in an updated speed field, comprising: And mixing the historical speed field, the input speed field at the current moment and collision drawing information to obtain the updated speed field, wherein the collision drawing information is data for drawing a collision effect when an interactive object collides with the fluid.
  8. 8. The method of claim 4, wherein the projecting by the simulator based on the advection velocity field results in a non-dispersion velocity field, comprising: Based on the advection speed field, solving by a divergence operator in the simulator to obtain a divergence field; executing a reverse poisson process on the divergence field through a pressure solver in the simulator to obtain a pressure field; And projecting the advection speed field through the gradient field of the pressure field to obtain the non-dispersion speed field.
  9. 9. The method according to claim 1, wherein the method further comprises: displaying a simulation setting interface, wherein the simulation setting interface comprises a plurality of candidate solvers of the target parameters; in response to a selected operation on a target solver of the plurality of candidate solvers, the target solver is determined to be a solver of the target parameters in the simulator.
  10. 10. The method according to any one of claims 1-9, wherein the method further comprises: Dividing the fluid into a plurality of grid cells; the acquiring the historical velocity field of the fluid at the historical moment comprises: for each grid cell in the plurality of grid cells, acquiring the historical speed of the grid cell in parallel to obtain a historical speed field of the fluid; the historical speed field based on the historical moment is obtained by sequentially solving a control equation and a advection diffusion equation through a simulator, and the advection post-density field of the fluid at the current moment is obtained, and the method comprises the following steps: And solving the control equation and the advection diffusion equation sequentially through the simulator based on the historical speeds of the grid cells in parallel for each grid cell in the grid cells to obtain an advection post-density value of the grid cells at the current moment, wherein the advection post-density values respectively corresponding to the grid cells form the advection post-density field, and the historical speeds respectively corresponding to the grid cells form the historical speed field.
  11. 11. The method according to claim 10, wherein the method further comprises: and storing the post-advection density field at the current moment in a texture, wherein each texel of the texture is used for storing the post-advection density value of the grid unit corresponding to the texel in the post-advection density field.
  12. 12. The method of any one of claims 1-9, wherein the acquiring a historical velocity field of the fluid at a historical time comprises: The historical speed field is read from on-chip storage.
  13. 13. A fluid simulation device, the device comprising a memory management unit and a solving unit: The memory management unit is used for acquiring a historical speed field of the fluid at a historical moment, and the historical moment is the moment before the current moment; The solving unit is used for sequentially solving a control equation and a advection diffusion equation through a simulator based on the historical speed field at the historical moment to obtain a advection post-density field of the fluid at the current moment; The simulator consists of different operators and solvers which are used for obtaining simulation parameters in series, each operator or solver is used for solving to obtain the simulation parameters, in the process of solving to obtain the advection post-density field, the solver used for solving the target parameters in the simulation parameters is determined from a plurality of candidate solvers based on simulation influence factors, and the simulation parameters are all parameters obtained through solving in sequence through the simulator in the process of solving the control equation and the advection diffusion equation.
  14. 14. A computer device, the computer device comprising a processor and a memory: the memory is used for storing a computer program and transmitting the computer program to the processor; The processor is configured to perform the method of any of claims 1-12 according to instructions in the computer program.
  15. 15. A computer readable storage medium for storing a computer program which, when executed by a processor, causes the processor to perform the method of any one of claims 1-12.
  16. 16. A computer program product comprising a computer program which, when executed by a processor, implements the method of any of claims 1-12.

Description

Fluid simulation method and related device Technical Field The application relates to the technical field of computers, in particular to a fluid simulation method and a related device. Background Fluid simulation is used as a core technology in the fields of computer graphics and engineering computation, and plays an irreplaceable role in a plurality of fields such as film and television special effects, game development, industrial design, biomedicine, energy management and the like. The related technology aims at fluid simulation of different physical scenes, often needs different simulation technologies or solution models, and therefore, needs to develop proprietary programs aiming at different scenes, and has weak expansibility. Disclosure of Invention In order to solve the technical problems, the application provides a fluid simulation method and a related device, wherein a simulator used by the method adopts a modularized packaging mode, so that fluid simulation of different complexity and different scenes can be adapted only by connecting operators and solvers of different numbers and types in series, and the variable requirements of input data sources and detail addition under different application scenes can be easily expanded and solved. The embodiment of the application discloses the following technical scheme: in one aspect, embodiments of the present application provide a fluid simulation method, the method including: acquiring a historical speed field of the fluid at a historical moment, wherein the historical moment is the moment before the current moment; Based on the historical speed field at the historical moment, sequentially solving a control equation and a advection diffusion equation through a simulator to obtain a advection post-density field of the fluid at the current moment; The simulator consists of different operators and solvers which are used for obtaining simulation parameters in series, each operator or solver is used for solving to obtain the simulation parameters, in the process of solving to obtain the advection post-density field, the solver used for solving the target parameters in the simulation parameters is determined from a plurality of candidate solvers based on simulation influence factors, and the simulation parameters are all parameters obtained through solving in sequence through the simulator in the process of solving the control equation and the advection diffusion equation. In one aspect, an embodiment of the present application provides a fluid simulation apparatus, where the apparatus includes a memory management unit and a solving unit: The memory management unit is used for acquiring a historical speed field of the fluid at a historical moment, and the historical moment is the moment before the current moment; The solving unit is used for sequentially solving a control equation and a advection diffusion equation through a simulator based on the historical speed field at the historical moment to obtain a advection post-density field of the fluid at the current moment; The simulator consists of different operators and solvers which are used for obtaining simulation parameters in series, each operator or solver is used for solving to obtain the simulation parameters, in the process of solving to obtain the advection post-density field, the solver used for solving the target parameters in the simulation parameters is determined from a plurality of candidate solvers based on simulation influence factors, and the simulation parameters are all parameters obtained through solving in sequence through the simulator in the process of solving the control equation and the advection diffusion equation. In one aspect, an embodiment of the present application provides a computer device including a processor and a memory: the memory is used for storing a computer program and transmitting the computer program to the processor; the processor is configured to perform the method of any of the preceding aspects according to instructions in the computer program. In one aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the method of any one of the preceding aspects. In one aspect, embodiments of the present application provide a computer program product comprising a computer program which, when executed by a processor, implements the method of any of the preceding aspects. According to the technical scheme, the simulator for fluid simulation is further modularized, the solving process is decomposed into the executable minimum units, namely the operators and the solvers, each operator or the solver is used for solving to obtain simulation parameters, and different operators and solvers used for obtaining the simulation parameters are connected in series to form the simulator. The simulation parameters are all parameters obtained through solving i