A fluid simulation method and related apparatus
Patent Information
- Application Number
- CN202610459631.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-04-09
AI Technical Summary
[0003]相关技术针对不同的物理场景的流体模拟,往往需要不同的模拟技术或求解模型,因此需要针对不同场景开发专有程序,扩展性较弱
[0010]As can be seen from the above technical solution, the embodiments of this application further modularize the simulator used for fluid simulation, decomposing the solution process into the smallest executable units, namely operators and solvers. Each operator or solver is used to solve for simulation parameters, and different operators and solvers used to obtain simulation parameters are connected in series to form a simulator. The simulation parameters are all parameters obtained by the simulator in the process of solving the governing equations and the advection-diffusion equations sequentially. There are multiple choices for the solver of the target parameters in the simulation parameters. Based on the simulation influencing factors, the solver for the target parameters in the simulator is determined from multiple candidate solvers. Thus, when fluid simulation is required, the historical velocity field of the fluid at a historical moment is obtained, where the historical moment is the moment before the current moment. Based on the historical velocity field at a historical moment, the simulator sequentially solves the governing equations and the advection-diffusion equations to obtain the post-advection density field of the fluid at the current moment. In this way, the entire fluid simulation process can be completed by a series of operators and solvers executed sequentially. Because the simulator adopts a modular encapsulation approach, fluid simulations of different complexities and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This makes it easy to extend the simulator to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method has strong scalability and can well adapt to complex, ever-changing, and performance-sensitive business requirements.
Smart Images

Figure CN122021463B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a fluid simulation method and related apparatus. Background Technology
[0002] Fluid simulation, as a core technology in the fields of computer graphics and engineering computing, plays an irreplaceable role in many fields such as film and television special effects, game development, industrial design, biomedicine, and energy management.
[0003] The related technologies often require different simulation techniques or solution models for fluid simulation in different physical scenarios. Therefore, it is necessary to develop proprietary programs for different scenarios, which has weak scalability. Summary of the Invention
[0004] To address the aforementioned technical issues, this application provides a fluid simulation method and related apparatus. The simulator used in this method employs a modular encapsulation approach. Therefore, fluid simulations of varying complexity and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This allows for easy expansion to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method exhibits strong scalability and can effectively adapt to complex, ever-changing, and performance-sensitive business requirements.
[0005] The embodiments of this application disclose the following technical solutions: On one hand, embodiments of this application provide a fluid simulation method, the method comprising: Obtain the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment; Based on the historical velocity field at the historical moment, the governing equation and the advection diffusion equation are solved sequentially by the simulator to obtain the advection density field of the fluid at the current moment. The simulator is composed of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the governing equation and the advection diffusion equation in sequence through the simulator.
[0006] On one hand, embodiments of this application provide a fluid simulation device, the device including a memory management unit and a solution unit: The memory management unit is used to acquire the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment; The solution unit is used to solve the governing equations and advection diffusion equations sequentially using a simulator based on the historical velocity field at the historical moment, so as to obtain the advection density field of the fluid at the current moment. The simulator is composed of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the governing equation and the advection diffusion equation in sequence through the simulator.
[0007] On one hand, embodiments of this application provide a computer device, the computer device including a processor and a memory: The memory is used to store computer programs and to transfer the computer programs to the processor; The processor is configured to execute the method described in any of the foregoing aspects according to instructions in the computer program.
[0008] In one aspect, embodiments of this application provide a computer-readable storage medium for storing a computer program that, when executed by a processor, causes the processor to perform the methods described in any of the foregoing aspects.
[0009] On one hand, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the foregoing aspects.
[0010] As can be seen from the above technical solution, the embodiments of this application further modularize the simulator used for fluid simulation, decomposing the solution process into the smallest executable units, namely operators and solvers. Each operator or solver is used to solve for simulation parameters, and different operators and solvers used to obtain simulation parameters are connected in series to form a simulator. The simulation parameters are all parameters obtained by the simulator in the process of solving the governing equations and the advection-diffusion equations sequentially. There are multiple choices for the solver of the target parameters in the simulation parameters. Based on the simulation influencing factors, the solver for the target parameters in the simulator is determined from multiple candidate solvers. Thus, when fluid simulation is required, the historical velocity field of the fluid at a historical moment is obtained, where the historical moment is the moment before the current moment. Based on the historical velocity field at a historical moment, the simulator sequentially solves the governing equations and the advection-diffusion equations to obtain the post-advection density field of the fluid at the current moment. In this way, the entire fluid simulation process can be completed by a series of operators and solvers executed sequentially. Because the simulator adopts a modular encapsulation approach, fluid simulations of different complexities and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This makes it easy to extend the simulator to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method has strong scalability and can well adapt to complex, ever-changing, and performance-sensitive business requirements. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 An architecture diagram of a computer system provided in this application embodiment; Figure 2 An application scenario architecture diagram of a fluid simulation method provided in this application embodiment; Figure 3 A flowchart illustrating a fluid simulation method provided in this application embodiment; Figure 4 An example diagram of a simulator provided in an embodiment of this application; Figure 5 An example diagram of a simulated settings interface provided in an embodiment of this application; Figure 6 An example image illustrating the effect of a character passing through dry ice fog, provided in an embodiment of this application; Figure 7This application provides a schematic diagram illustrating the effect of parameters involved in a 2D simulation process. Figure 8 A visual schematic diagram of an extrusion function provided for an embodiment of this application; Figure 9 An example diagram illustrating the complete spatial characteristics of dry ice flow after 3D simulation, provided as an embodiment of this application; Figure 10 This application provides an example diagram illustrating the effects of fluid simulation in different scenarios. Figure 11 An example diagram illustrating the solution of the governing equations and advection diffusion equations provided in this application embodiment; Figure 12 An example diagram illustrating fluid simulation in a scenario where multiple interactive objects interact with a fluid, as provided in this application embodiment; Figure 13 An example diagram of a checkerboard pattern alternation provided in this application embodiment; Figure 14 An example diagram illustrating the algorithm steps of a Multi Grid solver provided in this application embodiment; Figure 15 An interactive footprint diagram displayed using a visualization tool, as provided in this application embodiment; Figure 16 An illustration of various field information provided in an embodiment of this application; Figure 17 An example diagram illustrating the real-time generation of distance field information for a skeleton mesh using JFA, provided in this application embodiment; Figure 18 Another rendering of various field information provided in the embodiments of this application; Figure 19a An example diagram of a 2D solution loop provided in an embodiment of this application; Figure 19b An example diagram of a 3D solver loop provided in an embodiment of this application; Figure 20 This application provides an example diagram illustrating the effect of applying a fluid simulation method to three scenarios in an embodiment of this application. Figure 21 A structural diagram of a fluid simulation device provided in an embodiment of this application; Figure 22 A structural diagram of a terminal provided in an embodiment of this application; Figure 23 This is a structural diagram of a server provided in an embodiment of this application. Detailed Implementation
[0013] The embodiments of this application will now be described with reference to the accompanying drawings.
[0014] To facilitate understanding of the methods provided in the embodiments of this application, the terms involved in the embodiments of this application will first be explained.
[0015] Fluid: refers to a substance that can continuously deform and cannot maintain a fixed shape, characterized by easy flow, compressibility, and viscosity, including liquids and gases. Its core characteristic is the weak intermolecular forces, which allow the substance to flow freely to adapt to the shape of the container. In the embodiments of this application, the fluid to be simulated is mainly gas, such as clouds, fog, smoke, and fire.
[0016] Fluid simulation refers to the technique of simulating natural fluid phenomena such as ocean waves and smoke by combining computer graphics with physical equations. In fluid simulation, the fundamental equations of fluid mechanics can be solved to obtain the fluid's motion state.
[0017] Stable Fluids: This can be a stable fluid model, an unconditionally stable model for simulating complex fluid behavior over large time steps. It combines physical fluid dynamics with texture animation and introduces user interaction, making it ideal for computational graphics applications (especially gaming applications). Based on the Stable Fluids model, this paper improves the iterative solver for pressure and extends the advection and diffusion processes of matter by customizing the Navier-Stokes (NS) equations.
[0018] The related technologies often require different simulation techniques or solution models for fluid simulation in different physical scenarios. Therefore, it is necessary to develop proprietary programs for different scenarios, which has weak scalability.
[0019] To address the aforementioned technical issues, this application provides a fluid simulation method. The simulator used in this method employs a modular encapsulation approach. Therefore, fluid simulations of varying complexity and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This makes it easy to extend the method to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method has strong scalability and can well adapt to complex, ever-changing, and performance-sensitive business requirements.
[0020] It should be noted that the fluid simulation method provided in this application can be applied to various fluid simulation scenarios, such as film and television special effects, game development, virtual reality, scientific research and engineering applications, industrial design, and special environment simulation. This application mainly focuses on the game development scenario. The following is a brief introduction to the following scenario: (a) Film and television special effects scenes: Fluid simulation technology can create lifelike natural fluid phenomena such as ocean waves and smoke, providing powerful visual representation for special effects in movies and advertisements. For example, if smoke and dust are needed in a movie, the fluid simulation method provided in this application can be used to simulate smoke and dust to showcase the effect of smoke and dust in the movie.
[0021] (II) Game Development Scenarios: Fluid simulation technology can simulate effects such as water surfaces and smoke in games, enhancing the realism and immersion of the game. For example, in game development, if it is necessary to design smoke generated when a skill is released, the fluid simulation method provided in this application can be used to simulate smoke, thereby achieving the smoke effect. In addition, it can also simulate fluids such as clouds and fog in virtual scenes.
[0022] (III) Scientific Research and Engineering Application Scenarios: The fluid simulation method provided in this application can be used to study the motion state of fluids under different conditions, providing strong support for scientific research and engineering applications. For example, in the field of aircraft design, the fluid simulation method provided in this application can be used to optimize aircraft design; in the field of weather forecasting, the fluid simulation method provided in this application can be used to predict weather changes.
[0023] It should be noted that the fluid simulation method provided in this application embodiment is mainly applicable to the simulation of gaseous fluids. Of course, the simulator designed based on the concept of "micro solver" in this application embodiment, that is, the simulator composed of different numbers and types of operators and solvers connected in a modular packaging method, can be easily extended to the simulation of any material as needed, such as water, dust, and snow dynamics.
[0024] It should be noted that the fluid simulation method provided in this application embodiment can be executed by a computer device, which can be a terminal, a server, or both. In some possible implementations, if front-end visualization is required, it can be executed through a terminal.
[0025] To facilitate understanding of the fluid simulation method provided in the embodiments of this application, the computer system used to implement the fluid simulation method will be described exemplarily below.
[0026] See Figure 1 , Figure 1 An architecture diagram of a computer system provided in an embodiment of this application. Figure 1 The computer system 100 described herein is a system architecture for implementing the fluid simulation method in the embodiments of this application. The computer system 100 includes a terminal 120 and a server 140.
[0027] A fluid simulation client can be installed and run on terminal 120, through which fluid simulation can be performed. The fluid simulation client may be, for example, an application (App) or a mini-program on terminal 120, or it may be in the form of a web page. This embodiment of the application does not limit the form of the fluid simulation client in any way.
[0028] Terminal 120 can be a user terminal. The fluid simulation client running in terminal 120 can be used to select a solver or to input some known simulation parameters, thereby constructing a simulator based on the user-selected solver.
[0029] Terminal 120 can refer to one of multiple terminals, and this application embodiment only uses terminal 120 as an example. The device types of terminal 120 include, but are not limited to, at least one of the following: in-vehicle terminal, smartphone, tablet computer, computer, intelligent voice interaction device, smart home appliance, aircraft, wearable device, personal computer (PC), laptop computer, and desktop computer. Those skilled in the art will understand that the number of terminals 120 can be more or less. For example, there may be only one terminal 120, or there may be multiple or more terminals 120. This application embodiment does not limit the number or device type of terminal 120.
[0030] Terminal 120 can connect to server 140 via a network for network communication. This network can be a wireless network or a wired network. The network uses standard communication technologies and / or protocols, typically the Internet, but can also be any network, including but not limited to Bluetooth, a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), mobile, private networks, or any combination of virtual private networks. In some embodiments, customized or dedicated data communication technologies may be used to replace or supplement the aforementioned data communication technologies.
[0031] Server 140 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud servers, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0032] For example, server 140 is used to provide background services for a fluid simulation client running on terminal 120. Server 140 includes processor 144 and memory 142. Memory 142 is used to store relevant computer programs, such as computer programs related to the background services to be provided. Processor 144 is used to execute the computer programs stored in memory 142 to provide corresponding background services to the client. For example, processor 144 is used to execute the fluid simulation method provided in the embodiments of this application, using a simulator constructed by a selected solver, and then using known simulation parameters to solve for the advection density field during the solution process.
[0033] Optionally, server 140 undertakes the main computing work and terminal 120 undertakes the secondary computing work; or, server 140 undertakes the secondary computing work and terminal 120 undertakes the main computing work; or, server 140 and terminal 120 adopt a distributed computing architecture for collaborative computing.
[0034] The application scenarios of the fluid simulation method provided in the embodiments of this application will be described below with reference to the accompanying drawings. For example... Figure 2 As shown, Figure 2 An application scenario architecture diagram of a fluid simulation method is shown. This application scenario may include a terminal 21 and a server 22.
[0035] Terminal 21 can be a user terminal on which a fluid simulation client can be run. Users can select a solver on the fluid simulation client. When it is necessary to select a solver for the target parameters, a simulation settings interface can be displayed on the fluid simulation client of terminal 21. This interface includes multiple candidate solvers for the target parameters. The simulation settings interface can be found in [reference needed]. Figure 2 As shown in Figure 211, multiple candidate solvers include candidate solver 1, candidate solver 2, candidate solver 3, ... If a specific solver, such as the target solver, is needed to construct the simulator, the user can perform a selection operation on the target solver among the candidate solvers, thereby determining the target solver as the solver for the target parameters in the simulator. For example, if the target solver is candidate solver 1, the user can select candidate solver 1 as the target solver, thus obtaining the solver for the target parameters. See also... Figure 2 The solver for the objective parameters can be, for example, a... Figure 2 The simulator includes solver 1.
[0036] After determining the solver for the target parameters, the determined solver and operators are cascaded to form a simulator. For example... Figure 2 As shown, the simulator includes operator 1, operator 2, operator 3, ..., and solver 1, solver 2, solver 3, ...
[0037] When fluid simulation is required, server 22 can obtain the historical velocity field of the fluid at a historical moment, which is the moment before the current moment. Then, based on the historical velocity field at a historical moment, server 22 can solve the governing equations and the advection-diffusion equations sequentially through the simulator to obtain the post-advection density field of the fluid at the current moment.
[0038] The simulator consists of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the density field after advection, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the control equation and the advection diffusion equation in sequence through the simulator.
[0039] It should be noted that in the specific implementation of this application, the entire process may involve user information and other related data. When the above embodiments of this application are applied to specific products or technologies, separate consent or permission from the user is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0040] Next, with reference to the accompanying drawings and using a computer device as the terminal as an example, the fluid simulation method provided in the embodiments of this application will be described in detail. See also Figure 3 , Figure 3 A flowchart of a fluid simulation method is shown, which may include steps S301-S302, as detailed below: S301. Obtain the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment.
[0041] In this embodiment, fluid simulation can be performed at certain intervals. Therefore, the time mentioned in this embodiment can be the time when the fluid simulation is performed. The current time can refer to the time when the fluid simulation needs to be performed this time, and the historical time is the time before the current time, that is, the time when the fluid simulation was performed last time. The historical velocity field can refer to the velocity field obtained during the previous fluid simulation. The velocity field can be a mathematical tool that describes the velocity distribution of each point (e.g., a grid cell) in the fluid, representing the velocity of all points in the fluid at a certain moment. The velocity field is a vector field, that is, each point corresponds to a velocity vector, reflecting the magnitude and direction of the velocity of each point.
[0042] Fluid motion follows Newton's second law and the principle of conservation of momentum. Under the assumption of a continuous medium, the fluid's velocity field is a direct reflection of its momentum. Fluid motion is continuous, essentially transferring momentum from the previous moment to the current moment. Therefore, to satisfy physical laws and achieve the effect of fluid continuity, when performing fluid simulations, we can first obtain the historical velocity field of the fluid at previous moments.
[0043] S302. Based on the historical velocity field at the historical moment, the control equation and the advection-diffusion equation are solved sequentially by a simulator to obtain the post-advection density field of the fluid at the current moment; wherein, the simulator is composed of different operators and solvers connected in series for obtaining simulation parameters, each operator or solver is used to solve for simulation parameters, and in the process of solving for the post-advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on simulation influencing factors, and the simulation parameters are all parameters obtained by solving the control equation and the advection-diffusion equation sequentially by the simulator.
[0044] This application further modularizes the simulator used for fluid simulation, decomposing the solution process into the smallest executable units, namely operators and solvers. Each operator or solver is used to solve for simulation parameters, and different operators and solvers used to obtain simulation parameters are connected in series to form a simulator. The simulation parameters are all parameters obtained by the simulator in the process of sequentially solving the governing equations and the advection-diffusion equations. Multiple solvers can be selected for the target parameters in the simulation; the solver for the target parameters in the simulator is determined from multiple candidate solvers based on simulation influencing factors. Thus, when fluid simulation is required, the simulator can be used to sequentially solve the governing equations and the advection-diffusion equations based on the historical velocity field at a historical moment, obtaining the post-advection density field of the fluid at the current moment.
[0045] Understandably, solving the governing equations and advection-diffusion equations sequentially may involve many simulation parameters, including intermediate parameters and the advection-diffusion density field itself. Target parameters can be specific parameters from the simulation parameters, and these parameters can be solved using multiple methods, thus having multiple candidate solvers. Specifically, target parameters can be all simulation parameters or only some of them; that is, in the entire solution process, some or all steps may use multiple candidate solvers to choose from.
[0046] Operator: An operator can be understood as a specific and singular mathematical operation or description of a field structure, such as the "divergence operator," which is calculated by subtracting the left from the right, the bottom from the top, and the back from the front—a fixed "mathematical operation." Each cell in the entire fluid grid has its own divergence descriptor, which describes the "structural characteristics" of the field. Similarly, there are the "Laplace operator," the "advection operator," etc. The source term in the Navier-Stokes equations can also be understood as an operator used to inject data into the system.
[0047] Solver: Unlike operators, solvers describe the active computation process and are an explicit numerical method. Active computation or numerical methods refer to how to solve systems of linear equations. For example, the inverse Poisson process in Navier-Stokes solvers, and the application of iterative methods, are essentially about solving large systems of linear equations or performing sparse matrix operations from a discrete perspective. Iterative methods are a numerical approach for solving complex linear problems. Complex solvers consist of a series of operators or basic solvers.
[0048] Iterative methods are a numerical approach for solving large sparse linear systems of equations. There are different iterative methods, such as the Jacobi method, the Gauss-Seidel method and its GPU variant, the Red-Black Gauss-Seidel method, the Preconditioned Conjugate Gradient (PCG), and the Multi Grid method.
[0049] Simulators: Operators and solvers are cascaded together to form a simulator, which guides how a complete solution loop is performed. In practical applications, especially in game development, simulators can also include game play logic and auxiliary applications.
[0050] In one possible implementation, an example diagram of the simulator can be found here. Figure 4 As shown. In Figure 4In this application, the simulator can include two-dimensional (2D) simulators and three-dimensional (3D) simulators. That is, the fluid simulation method provided in this embodiment can be used for both 2D and 3D simulations. Both 2D and 3D simulators can be composed of operators and solvers connected in series. The operators can include advection operators, divergence operators, source injection operators, residual operators, prolongation operators, and correction operators. The solvers can include Jacobian solvers, multigrid solvers, Gaussian-Seidel solvers, convolutional precomputation filtering (CPF), precomputation conjugate gradient solvers, and viscosity solvers. Appropriate operators and solvers are selected to construct the simulator based on the actual application scenario.
[0051] Different candidate solvers use different algorithms. For example, the Jacobi solver uses the Jacobi algorithm, the Red-Black Gauss-Seidel solver uses the Red-Black Gauss-Seidel algorithm, and the multigrid solver uses the multigrid algorithm.
[0052] Simulation influencing factors refer to factors that affect the performance of fluid simulations, and these factors can serve as the basis for determining the solver in the simulator. Simulation influencing factors may include, for example, at least one of the accuracy and efficiency of the fluid simulation. Depending on the application scenario, the simulation influencing factors may vary. In some applications, accuracy is paramount, so accuracy can be used as a simulation influencing factor to select the candidate solver with the highest accuracy as the solver for the target parameters in the simulator. In other applications, efficiency is paramount, so efficiency can be used as a simulation influencing factor to select the candidate solver with the highest efficiency as the solver for the target parameters in the simulator. In still other applications, a balance between accuracy and efficiency is crucial, so both accuracy and efficiency can be used as simulation influencing factors. For each candidate solver, the overall performance is determined based on its accuracy and efficiency, and the candidate solver with the highest overall performance is selected as the solver for the target parameters in the simulator.
[0053] Through this encapsulation, the simulator can be composed of different operators and solvers chained together. Simulations of varying complexity can be adapted simply by chaining together different numbers and types of operators and solvers. Each type of operator and solver corresponds to an efficient resource binding and thread allocation mechanism, and more complex solvers can be constructed by combining basic solvers and operators. This mechanism provides great scalability and flexibility. Each type of operator and solver, as a target, has its own aggregated computation shader class. These classes are derived from a common base class and hold independent control methods, compilation conditions, and macro branches according to their own characteristics and needs.
[0054] It should be noted that the embodiments of this application do not limit the method of determining the solver of the target parameters in the simulator. In one possible implementation, it can be automatically selected during the solving process. That is, when the solver of the target parameters is needed, a solver is automatically selected from multiple candidate solvers as the solver of the target parameters in the simulator.
[0055] In another possible implementation, the user can pre-configure the solver for the target parameters in the simulator before the fluid simulation method is executed. Specifically, a simulation settings interface can be displayed on a terminal running the fluid simulation client. This interface includes multiple candidate solvers for the target parameters. If the user selects a candidate solver, a selection operation can be performed on that candidate solver. The selected candidate solver can be called the target solver. Therefore, in response to the selection operation of the target solver among multiple candidate solvers, the terminal can determine the target solver as the solver for the target parameters in the simulator.
[0056] The simulation settings interface is used to configure the fluid simulation before it begins. These configurations can include the solver, relevant parameters, etc.
[0057] The simulation settings interface can be found here. Figure 5 As shown, multiple candidate solvers include candidate solver 1, candidate solver 2, candidate solver 3, and so on. If a specific solver, such as the target solver, is needed to construct the simulator, the user can perform a selection operation on the target solver among the candidate solvers, thereby determining the target solver as the solver for the target parameters in the simulator. For example, if the target solver is candidate solver 1, the user can select candidate solver 1 as the target solver, thus obtaining the solver for the target parameters.
[0058] This application provides users with a simulation settings interface, which then determines the solver for the target parameters in the simulator based on the user's selected operation. This allows for intuitive operation and facilitates user customization. Furthermore, the user's selection of the solver for the target parameters in the simulator before fluid simulation allows for personalized settings based on user needs, satisfying customized requirements while ensuring fluid simulation efficiency.
[0059] The governing equations (NS equations) are fundamental to fluid dynamics, describing the conservation of momentum in viscous, incompressible fluids (i.e., the application of Newton's second law to fluids). In one possible implementation, the governing equations can be as follows:
[0060] in, Let t represent the velocity field of the fluid, t represent time, and f represent the external force. Indicates the density of the fluid. Indicates the kinematic viscosity of a fluid. Represents the pressure field of a fluid. It is the gradient operator.
[0061] The governing equations can be decomposed into the following terms: Convection term : Describes the momentum transfer caused by the fluid's own motion (nonlinear term, leading to complex phenomena such as turbulence); pressure gradient term : The force generated by the pressure difference (driving fluid flow); diffusion term Viscous force (which makes fluid flow smoother); External force term f: External forces (such as gravity) ).
[0062] Understandably, if the fluid is a gas, the diffusion term does not provide significant benefits in most experiments because gases are farther away than liquids, have a larger free path, and the viscosity effect caused by friction is very weak. Therefore, in one possible implementation, if the fluid is a gas, the diffusion term can be eliminated when using the above governing equations, thereby reducing the overhead of numerically solving a large linear system (the other large linear system in the governing equations is the inverse Poisson process, which is necessary to ensure the system is incompressible; that is, the inverse Poisson process can eliminate the divergence of the intermediate velocity field by adjusting the pressure field, thereby forcing the fluid to meet the incompressibility condition. Without the inverse Poisson process term, the velocity field will become compressible due to numerical errors or the nonlinear effects of the convection term).
[0063] The advection-diffusion equation describes the transport of scalar fields (such as density, temperature, and concentration) in a fluid, combining convection (carried by fluid motion) and diffusion (caused by random molecular motion). In one possible implementation, the advection-diffusion equation can be shown below:
[0064] in, This represents a physical quantity, such as concentration, temperature, density, etc. It is the attenuation coefficient. It is the diffusion coefficient.
[0065] The advection diffusion equation can be decomposed into the following terms: Source Item : Indicates external... Contribution or generation rate; convection term : Describes the momentum transfer caused by the fluid's own motion (nonlinear term, leading to complex phenomena such as turbulence); dissipation term or decay term :express Linear decrease over time; diffusion term : Indicates that due to diffusion, the scalar The smoothing process in space.
[0066] Based on the above reasons, in one possible implementation, if the fluid is a gas, the consumable and diffusion terms can be taken when using the above advection diffusion equation, thereby reducing the overhead of numerical solution of a large linear system.
[0067] A density field is a physical field used to describe the density distribution in a fluid or substance. It is a scalar field, meaning that each point (grid cell) in the fluid has a corresponding density value. The density field after advection can refer to the new spatial distribution of density after an advection process. Advection refers to the process by which fluid motion (such as wind or water flow) carries matter (such as density, temperature, and concentration) throughout space. Essentially, it is the passive transport of matter due to the macroscopic motion of the fluid, contrasting with diffusion (caused by random molecular motion).
[0068] As can be seen from the above technical solution, the embodiments of this application further modularize the simulator used for fluid simulation, decomposing the solution process into the smallest executable units, namely operators and solvers. Each operator or solver is used to solve for simulation parameters, and different operators and solvers used to obtain simulation parameters are connected in series to form a simulator. The simulation parameters are all parameters obtained by the simulator in the process of solving the governing equations and the advection-diffusion equations sequentially. There are multiple choices for the solver of the target parameters in the simulation parameters. Based on the simulation influencing factors, the solver for the target parameters in the simulator is determined from multiple candidate solvers. Thus, when fluid simulation is required, the historical velocity field of the fluid at a historical moment is obtained, where the historical moment is the moment before the current moment. Based on the historical velocity field at a historical moment, the simulator sequentially solves the governing equations and the advection-diffusion equations to obtain the post-advection density field of the fluid at the current moment. In this way, the entire fluid simulation process can be completed by a series of operators and solvers executed sequentially. Because the simulator adopts a modular encapsulation approach, fluid simulations of different complexities and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This makes it easy to extend the simulator to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method has strong scalability and can well adapt to complex, ever-changing, and performance-sensitive business requirements.
[0069] Because the simulators used in fluid simulation methods have strong scalability, when dry ice mist and fireworks need to match different detailed features in different application scenarios, such as turbulence, wind field, drag force, curling signal (vorticity), system lift generated by changes in thermal conditions, and some additional features that do not exist in reality but need to be added for artistic expression, the solver in the simulator can be changed to adapt to complex, variable and performance-sensitive business needs.
[0070] Specifically, because the simulator uses a modular encapsulation approach, for tasks with frequently changing requirements (such as adjusting algorithm parameters), operators or solvers can be replaced or added / removed without refactoring the entire solution process. For example, in fluid simulation, if it's necessary to switch the fluid from incompressible to compressible flow, only the pressure solver needs to be replaced (from the Poisson equation solver to the state equation solver), while other solvers or operators (such as convection and diffusion terms) can be reused. Furthermore, for performance-sensitive tasks (such as those with high real-time requirements), performance analysis tools can be used to pinpoint time-consuming operators or solvers, allowing for individual optimization of those operators or solvers (such as algorithm improvements, hardware acceleration, and caching strategies) without needing to optimize the entire solution process.
[0071] Improved fluid simulation performance
[0072] It should be noted that the fluid simulation methods provided by related technologies are generally only used for 2D simulations, while 3D simulations have high computational complexity, large data volume, and high real-time requirements, making them more challenging. Therefore, the embodiments of this application improve simulation performance. Improving fluid simulation performance is mainly achieved in two ways: one is by executing fluid simulation methods in parallel.
[0073] (a) Parallel execution fluid simulation method
[0074] Understandably, the fluid can be divided into multiple grid cells, which are the basic units that discretize the continuous fluid computational domain into a finite number of small regions (usually cubes or rectangles). Each grid cell represents a local region of the fluid in space. Fluid dynamics equations (such as mass conservation and momentum conservation equations) are difficult to solve directly in continuous space. By dividing the fluid into grid cells, the equations can be discretized within each grid cell, transforming them into a system of algebraic equations, which facilitates numerical solutions. This application does not limit the type of grid cell; for example, it can be a uniform or non-uniform cube or rectangle.
[0075] In fluid simulation, each grid cell needs to obtain its corresponding post-advection density field. Therefore, the fluid simulation method is executed in parallel for each grid cell. The fluid simulation method provided in this application includes steps S301 and S302. Therefore, steps S301 and S302 are executed in parallel for each grid cell. Specifically, in S301, the method of obtaining the historical velocity field of the fluid at a historical moment can be to obtain the historical velocity of each grid cell in parallel for each of the multiple grid cells, thus obtaining the historical velocity field of the fluid. In S302, based on the historical velocity field at a historical moment, the method of solving the governing equation and the advection diffusion equation sequentially through the simulator to obtain the post-advection density field of the fluid at the current moment can be to solve the governing equation and the advection diffusion equation sequentially through the simulator for each of the multiple grid cells, thus obtaining the post-advection density value of the grid cell at the current moment. The post-advection density values corresponding to multiple grid cells constitute the post-advection density field, and the historical velocities corresponding to multiple grid cells constitute the historical velocity field.
[0076] The fluid contains a large number of mesh cells. Fluid simulation is performed in parallel for each mesh cell. This allows each computational unit to handle the fluid simulation of its corresponding mesh cell, improving the utilization of computational units. Simultaneously, because the fluid simulation is performed on all mesh cells in parallel, the computation speed for large-scale data is increased, simulation time is shortened, and simulation efficiency and real-time performance are improved, making this simulation method suitable for application in 3D simulations.
[0077] It is understandable that after obtaining the current advection density field, the post-advection density field may have other uses, such as further analysis of the post-advection density field, or rendering to visualize fluid effects. Therefore, in order to facilitate the provision of the post-advection density field to subsequent processes, embodiments of this application may also store the current post-advection density field.
[0078] This application does not limit the storage method of the post-advection density field in its embodiments. Storage methods may include, for example, texture storage, structured data storage, and array storage. In one possible implementation, a suitable storage method can be selected based on the application scenario. For example, in applications requiring real-time rendering, such as game development and virtual reality, texture storage can be used to fully leverage hardware acceleration and achieve smooth rendering effects. Conversely, in applications such as scientific research and engineering, the storage and access of the density field may prioritize data accuracy and integrity over real-time performance; therefore, array storage or structured data storage can be chosen for more refined data analysis and processing.
[0079] Based on this, if the post-advection density field is obtained by performing a fluid simulation method in parallel for each grid cell, then in one possible implementation, the post-advection density field at the current moment can be stored in a texture, and each texel of the texture is used to store the post-advection density value of the grid cell corresponding to the texel.
[0080] A texture is an image or data structure used to describe the details of an object's surface. It can simulate the microstructure, color variations, roughness, and other features of an object's surface, making virtual objects look more realistic and lifelike. A texel is the smallest data unit that constitutes a texture in computer graphics. It is the basic unit of texture and has a mapping relationship with screen pixels, jointly determining the detail and realism of the final rendered image. As the basic unit of a texture image, a texel provides the attribute information required for texture mapping. Through texture mapping techniques, texels are mapped to appropriate locations on the surface of a 3D model, thereby giving the model rich surface details and realism.
[0081] In fluid simulation, texels can be used to represent fluid attributes such as color, density, and velocity. In this embodiment, fluid is simulated using a post-advection density field; therefore, texels can be used to represent the density values of corresponding mesh cells in the fluid. Furthermore, texture mapping technology is used to map the post-advection density field onto the fluid surface, thereby enhancing the realism and detail of the fluid simulation.
[0082] This application embodiment stores the advection density field using texture storage, which fully utilizes the powerful parallel computing capabilities of the GPU to perform parallel calculations on each texel in the texture, significantly reducing computation time. Furthermore, the texture has a specific storage layout and access method in GPU memory, which facilitates efficient data access. Therefore, texture storage improves data orientation efficiency and is convenient for subsequent rendering processes.
[0083] (ii) Parameters required during the solution process are stored using on-chip storage.
[0084] Another way to improve simulation performance is to use on-chip memory to store the parameters needed during the solution process. On-chip memory is memory integrated inside the chip, tightly coupled with the processing units on the chip (such as the GPU core, CPU cache, etc.), and has high-speed, low-latency access characteristics. Common on-chip memory includes registers, shared memory (common in GPU architecture), L1 cache, and L2 cache. Located inside the chip, these memories can provide data to the processing units faster and reduce data access latency compared to external video memory (such as the GPU's global memory) or main memory (such as the CPU's main memory).
[0085] In parallel computing, multiple threads run concurrently. If each thread frequently needs to read data from external storage, the slow access speed of external storage will cause threads to often be in a waiting state, resulting in low parallel efficiency. On-chip storage, on the other hand, has extremely fast access speed, allowing threads to quickly obtain the required data, reducing waiting time and enabling more time to be used for actual computation operations, thereby improving thread utilization and parallel efficiency.
[0086] The parameters required during the solution process may include historical velocity fields. Therefore, in one possible implementation, the historical velocity fields can be stored on-chip. Thus, the historical velocity fields of the fluid at a historical moment can be obtained by reading them from on-chip storage. It should be noted that the solution process may also involve many intermediate parameters, such as temporary data or spatial neighborhood data. These intermediate parameters can also be stored on-chip, and then read from on-chip storage when needed.
[0087] This application embodiment uses on-chip storage to store historical velocity fields and intermediate parameters generated during the solution process. Since on-chip storage has extremely fast access speed, threads can quickly obtain the required data, reducing waiting time and allowing more time to be used for actual calculation operations. This improves thread utilization and parallel efficiency, enhances fluid simulation performance, and facilitates the application of this simulation method in 3D simulation.
[0088] It should be noted that in some application scenarios, such as film and television special effects and game development, obtaining the density field after advection through fluid simulation may not be the final goal. The final goal may be to present a more accurate fluid effect. Therefore, after obtaining the density field after advection, it can also be used for rendering to obtain the fluid effect.
[0089] In one possible implementation, the fluid simulation client can focus on efficient GPU simulation of the fluid and does not provide rendering capabilities itself. Therefore, by exporting the advection density field, users can flexibly choose the rendering mechanism. They can use the engine's built-in fog rendering, the engine's built-in cloud rendering, or a custom volumetric rendering pipeline. The advection density field can be exported by storing it in a texture, and then using the texture for rendering.
[0090] Improving the performance of fluid simulation through the aforementioned methods facilitates its application in 3D simulation. In one possible implementation, this embodiment employs a self-developed renderer, which can be a plug-in engine volumetric content production tool. This embodiment, through the combination of a fluid simulation client and a renderer, can achieve common 2D fluid solving + 2.5D volumetric rendering or 3D fluid solving + 3D volumetric rendering. This essentially covers the needs of common smoke and flame visual effects.
[0091] The following describes the performance of the fluid simulation method provided in the embodiments of this application in 2D simulation and 3D simulation, respectively.
[0092] (a) 2D simulation
[0093] Taking dry ice fog as an example, a 2D simulation is performed using the fluid simulation method provided in this application embodiment to obtain the density field after advection. The rendered fluid is then obtained using the density field after advection. See also Figure 6 , Figure 6An example image showing the effect of a character passing through dry ice fog is provided. In this fluid simulation, the simulation area is 30m × 30m × 1m in size, using a 2D simulation mode with a 256 × 256 simulation resolution. The clock system is set to solve 60 times per second, and the pressure solver uses the Jacobi solver iterating 5 times. Ray detection is applied as the basis for collision rendering to control interactive objects (e.g., Figure 6 The influence of the character shown in Figure 601 (the character's skeleton mesh) on the fluid fog is limited to the detection target being two arm bones and two shin bones of the skeleton mesh. To eliminate interference from the ray direction, this embodiment uses a custom ray source, emitting rays from 2000 meters directly above the simulated area. Figure 6 Taking 4-point X-ray detection as an example, see [link / reference]. Figure 6 The ray shown in Figure 602. With this configuration, the solver's GPU overhead is only 0.3ms ± . Although the system diverges due to the limited number of Jacobi iterations, and the vortex information disappears quickly, clear turbulence can still be observed while interactively traversing the flow field, for example... Figure 6 The turbulence generated along the direction of the arrow.
[0094] The simulator used in the fluid simulation process will adjust and process the user's parameters, such as the input velocity field and input density field information (usually a certain pattern of texture), then mix the interactive footprint map (which will be introduced later, and will not be repeated here), and finally output the advection density field for rendering after solving the loop, which is then given to the renderer (usually a volume renderer). For 2D simulation, the density field can be conveniently stored in a 4-channel texture.
[0095] In one possible implementation, debugging can refer to the physical process of stimulating the natural motion patterns of the fluid by introducing a noise field or a specific mode of perturbation to break the symmetry or homogeneity of the initial field (e.g., the input velocity field). This avoids numerical problems caused by overly idealized input velocity or density fields and accelerates the simulator's convergence to the true physical state.
[0096] The effect diagram of the parameters involved in the 2D simulation can be shown as follows: Figure 7 As shown, Figure 7 Figure (a) shows the input velocity field. If the fluid simulation has just started, the input velocity field can be used as the historical velocity field. The input velocity field is relatively uniform or symmetrical. Figure 7Figure (b) shows the input noise field. In some cases, to avoid numerical problems caused by an overly idealized (symmetric or homogeneous) input velocity field, a noise field can be introduced. Noise fields are commonly used disturbance sources in debugging. This non-uniformity is simulated using mathematical methods (such as Perlin noise or fractal noise). The input velocity field is then debugged using the noise field to obtain a debugged velocity field that is closer to physical reality. The debugged velocity field can be found in [reference needed]. Figure 7 As shown in Figure (c). After an interactive object disturbs the fluid, such as a character passing through dry ice fog, an interaction footprint map can be generated during the process. The interaction footprint map can be found in [reference needed]. Figure 7 As shown in Figure (d), the density field after advection can be obtained by mixing the adjusted velocity field with the interactive footprint map and then solving the problem. During the solution process, the positions of the characters at different times in the interactive footprint map can be used for calculation. For example, the velocity field at the previous moment can be updated to obtain the updated velocity field. At the start of the solution, the velocity field at the previous moment can be the adjusted velocity field. Intermediate parameters, such as the divergence field, can also be obtained during the solution process. The divergence field can be found in [reference needed]. Figure 7 As shown in Figure (e), the final calculated density field after advection can be found in [reference]. Figure 7 As shown in (f). In Figure 7 In order to illustrate the problem, the brightness and contrast of the interactive footprint map and divergence field were enhanced in the later stage.
[0097] The advection density field obtained from fluid simulation may not be directly used for volumetric rendering because it remains in 2D, while volumetric rendering requires ray Marching in 3D space. To map 2D data to 3D data, an extrusion operation can be performed. The extrusion process is empirical and lacks a fixed algorithm. Therefore, extrusion can also be considered a nonlinear fitting process.
[0098] Extrusion follows the principle of minimal control, and extrusion operations can be performed using extrusion functions. Figure 8A visualization of the extrusion function is shown. This function involves several parameters: Extrude Height, Extrude Falloff, and Density Offset. Extrude Height controls the extrusion height along the plane; it's a uniform quantity that raises the field information upwards according to its value. Therefore, the higher the density, the greater the rise, and the lower the density, the smaller the rise. Extrude Falloff refers to the phenomenon where parameters such as height or density gradually decrease with distance or time during extrusion. The overall rise depends on the density field value, meaning that rapid changes in the signal can create steep transitions in height information, affecting visual perception. Therefore, Extrude Falloff provides a smoothing effect, making height fluctuations more gentle. Density Offset allows for secondary adjustments to the output of the physical simulation, thereby controlling the perceived thickness of the fluid. Figure 8 The Plane ExtrudeOutput is the output of the extrusion function, representing the 3D data generated after the extrusion operation. When using the extrusion function, the values of ExtrudeHeight, ExtrudeFalloff, and Density Offset are set, and then the extrusion operation is performed to output the 3D advection density field. In one possible implementation, Density Offset can be 0.
[0099] (II) 3D Simulation
[0100] The fluid simulation method provided in this application supports fully 3D fluid solving. 3D simulation faces new challenges; experiments show that even adding a single axis exponentially increases performance overhead. Another difference in 3D simulation lies in collision handling. Ray detection cannot be used in this case. To address collision issues, an additional distance field generation system can be developed. Velocity field updates are no longer evaluated through simple position interpolation. Considering the variable shape of mesh cells and the potentially large number of triangles, especially after enabling mesh cells in Unreal Engine (UE), the method can be changed to updating drag forces based on collisions, and then updating the velocity field based on forces and mass.
[0101] The fluid simulation method provided in this application is used to perform 3D simulation, obtain the density field after advection, and then use the density field after advection to render the rendered fluid. See also Figure 9 , Figure 9An example diagram illustrating the spatial characteristics of complete dry ice flow after a 3D simulation is shown. In this fluid simulation, the simulation region is 10m × 10m × 3m in size, with a voxel size of 10 voxels / m, i.e., a voxel size of 0.1m. The cylinder used as a reference (which can also be used as an exchange object) has dimensions of 2m × 2m × 2m, and the cuboid has dimensions of 0.8m × 1.5m × 0.2m. The Jacobi solver was used iteratively 5 times.
[0102] Figure 10 Several typical scenarios are given. Figure 10 The middle (a) figure shows the collision turbulence caused by the character moving in the dry ice fog. Figure 10 Figure (b) shows the vortex swirling generated by the movement of a larger cylinder (i.e., the interactive object). It can be seen that the larger the interactive object, the greater its momentum, and the more obvious its influence on the velocity field. Figure 10 Figure (c) shows the turbulence caused by the cuboid falling from a low altitude and then rising. The introduction of momentum will change the velocity distribution within the cell, resulting in a change in divergence. Under the setting of an incompressible fluid, the change in divergence will form a negative pressure, thereby affecting the fluid's advection and diffusion process. Figure 10 Figure (d) shows the trajectory of a cuboid passing low over the upper surface of fog. Based on the fluid simulations of the above scenarios, it can be seen that theoretically, the lower the deviation in solving the Poisson equation, the longer the vorticity signals of different frequencies and scales can persist. However, in practical applications, the vortices are often intentionally made to remain for a shorter period because the interacting objects may move rapidly back and forth within the simulation domain. In this case, it is desirable for the simulator to have sufficient dissipation to quickly come to a stop after a brief disturbance, preparing for the next interaction. This visually striking expression contradicts natural physics, yet it is of great significance. In other words, the control of fluid simulations should fully balance the needs of physical conservation laws and artistic expression.
[0103] In this embodiment, an interactive object can refer to an object located in a fluid, interacting with the fluid, and capable of influencing the fluid's motion state, morphological distribution, or physical properties. Interactive objects can be of various types, such as characters or various objects.
[0104] Solve the governing equations and the advection-diffusion equations in sequence.
[0105] In the process of solving the governing equations and advection-diffusion equations sequentially using a simulator based on historical velocity fields to obtain the post-advection density field, the historical velocity field from the previous moment serves as the simulator's input, and the post-advection density field serves as its output. The simulator consists of different operators and solvers connected in series. In the process of obtaining the output based on the input, various operators and solvers participate in solving for intermediate parameters and the final advection density field. The specific solution process is described below.
[0106] In one possible implementation, the fluid density field at the current moment is obtained by solving the governing equations and advection-diffusion equations sequentially using a simulator based on the historical velocity field at a historical moment. This can be achieved by solving the governing equations using a simulator based on the historical velocity field. Specifically, during the solution process, the historical velocity field is updated using a velocity field solver in the simulator, resulting in an updated velocity field. The updated velocity field is then adsorbed using a first advection operator in the simulator to obtain an advection velocity field. Based on this advection velocity field, a divergence-free velocity field is obtained by projection using the simulator. Then, based on this divergence-free velocity field, the advection-diffusion equations are solved using the simulator to obtain the post-advection density field. Specifically, during the solution process, the initial density field is calculated using a source injection operator in the simulator. Based on the divergence-free velocity field, the initial density field is adsorbed using a second advection operator in the simulator to obtain the post-advection density field.
[0107] In other words, the solution process can be divided into two stages: solving the governing equations and solving the advection-diffusion equations. See [link to relevant documentation]. Figure 11 As shown in the figure. S1101-S1103 are the steps for solving the governing equations, and S1104-S1105 are the steps for solving the advection-diffusion equations.
[0108] In S1101, the historical velocity field can be represented as w_0(x), and the updated velocity field can be represented as w_1(x).
[0109] In S1102, the updated velocity field is adsorbed using the first adsorption operator in the simulator to obtain the adsorption velocity field. The particle position can be determined by using the reverse method. The position of the particle before the time step Δt is found using the function p(x,-Δt), and the value of w_1 at that position is assigned to w_2 at the current position, thus realizing the adsorption calculation of the velocity field and simulating the transmission of fluid velocity over time to obtain the adsorption velocity field w_2(x). Based on this, the formula for adsorbing the updated velocity field using the first adsorption operator in the simulator to obtain the adsorption velocity field can be w_2(x) = w_1(p(x,-Δt)).
[0110] In S1103, the divergence-free velocity field can be represented as w_3(x).
[0111] In S1104, based on the given source term function Sa, the source term value a_0(x,t) at the current position x at time t is calculated, which is used to describe the generation or consumption of substances in the fluid.
[0112] In S1105, similar to the advection calculation of the velocity field, the method of determining particle position by inversion is used. The position of the particle before the time step Δt is found through the function p(x,-Δt), and the value of a_0 at that position is assigned to a_1 at the current position. This simulates the transport process of matter moving with the fluid, and the advection density field a_1(x,t) is obtained. Based on this, based on the divergence-free velocity field, the initial density field is adducted through the second advection operator in the simulator, and the formula for the advection density field can be a_1(x,t) = a_0(p(x,-Δt)).
[0113] This application's embodiments separate the different physical processes (velocity field update, advection, projection, source term calculation, and mass advection) in fluid simulation, making the physical meaning of each step clear and easy to understand and analyze the impact of each process on fluid motion. Furthermore, this step-by-step processing allows for the selection of appropriate numerical methods for each physical process, contributing to improved numerical stability of the calculations.
[0114] In this embodiment of the application, the historical velocity field is updated by the velocity field solver in the simulator. There are several ways to obtain the updated velocity field. One way is to perform simple calculations according to basic physical laws such as Newton's second law to obtain the updated velocity field.
[0115] The updating of the velocity field is usually caused by external forces. Updating the velocity field based on external forces follows the basic principles of Newtonian mechanics and conforms to the laws of motion in the real physical world. Therefore, in S1101, the updated velocity field can be obtained by updating the historical velocity field through the velocity field solver in the simulator. This can be based on the interactive external force generated by the interactive object at the current position, and the updated velocity field can be obtained by updating the historical velocity field through the velocity field solver in the simulator. The interactive external force on the fluid will cause the fluid to accelerate, thereby changing the fluid's velocity field. In one possible implementation, w_1(x) = w_0(x) + Δt·f(x,t), where Δt is the time interval between the current moment and the historical moment, and f(x,t) is the acceleration generated by the interactive external force at the current position at the current moment.
[0116] The embodiments of this application update the velocity field based on external force, which follows the basic principles of Newtonian mechanics and conforms to the laws of motion in the real physical world, thus obtaining a more accurate updated velocity field.
[0117] It should be noted that the fluid simulation method provided in this application embodiment supports the simultaneous participation of multiple interactive objects, that is, multiple interactive objects are in the fluid, interact with the fluid, and cause disturbance to the fluid.
[0118] If there are multiple interactive objects generating external forces at the current location, there are several ways to update the historical velocity field using the velocity field solver in the simulator based on the external forces generated by these objects at the current location. One possible implementation is to add the external forces generated by all interactive objects at the current location to obtain the resultant force, and then use the simulator's velocity field solver to update the historical velocity field to obtain the updated velocity field.
[0119] The above method, by accurately calculating the net external force and updating the velocity field according to physical laws, can more realistically reflect the motion of the fluid when multiple interactive objects act simultaneously, making the simulation results closer to the actual physical phenomena.
[0120] In another possible implementation, based on the interactive forces generated by the interactive objects at their current positions, the historical velocity field is updated using the velocity field solver in the simulator to obtain the updated velocity field. This can be achieved by calculating the velocity field change corresponding to each interactive force generated at the current position; summing these velocity field changes for each force to obtain a composite change; and then using this composite change to update the historical velocity field using the simulator's velocity field solver to obtain the updated velocity field. Alternatively, the updated velocity field can be obtained by summing the historical velocity field with the composite change.
[0121] Understandably, when calculating the velocity field change corresponding to the external force generated by each interactive object at its current position, different interactive objects may have their own characteristics. Therefore, different numerical methods or physical models can be used to calculate their corresponding velocity field changes. For example, more precise processing can be performed for external forces with complex boundary conditions or special physical properties.
[0122] The above method calculates the velocity field change corresponding to the external force generated by each interactive object at its current position. Then, it sums these velocity field changes for each external force to obtain a comprehensive change. This comprehensive change is then used to update the historical velocity field through the velocity field solver in the simulator, resulting in the updated velocity field. This method calculates the velocity field change corresponding to the external forces generated by different interactive objects separately. Therefore, different numerical methods or physical models are used to calculate the corresponding velocity field change for each interactive object, taking into account its characteristics. Since the processing of each external force is relatively independent, it is easier to locate and solve problems during the debugging and optimization of the simulation program, allowing for optimization of the calculation process for each external force separately.
[0123] For scenarios involving multiple interactive objects interacting with the fluid, please refer to [reference needed]. Figure 12 As shown. In Figure 12 In the simulation, the area is 10m × 10m × 1m in size and includes three interactive objects: a character (see 1201), a large spherical light source moving at a low speed like a sine wave (see 1202), which has high brightness, and a smaller spherical light source moving at a relatively high speed along a circuit (see 1203), which has low brightness. The simulation resolution is 720 × 720 × 1, the Tick system is set to solve 60 times per second, and a convolutional filter-based pressure solver is used, requiring only one sub-iteration.
[0124] In another possible implementation, the historical velocity field is updated by the velocity field solver in the simulator. The updated velocity field can be obtained by mixing the historical velocity field, the current input velocity field, and collision rendering information. The collision rendering information is the data generated when the interactive object collides with the fluid and is used to render the collision effect.
[0125] The input velocity field at the current moment may include the influence of various external forces (such as gravity, wind, and force applied by the user) on the fluid velocity, enabling the fluid to respond to external interventions. Collision rendering information can accurately simulate the collision interaction process between the fluid and its surrounding environment (i.e., interactive objects), preventing the fluid from penetrating objects or exhibiting unreasonable movement.
[0126] Collision rendering information can be obtained in several ways. One method is geometric detection, which determines collision information by detecting the geometric relationships between the fluid and interactive objects in the surrounding environment. For example, simple geometric shapes such as bounding boxes and bounding spheres can be used to approximate the fluid and interactive objects, and then the overlap or intersection between them can be detected. Another method is physical simulation, which simulates the interaction process between the fluid and interactive objects based on a physics engine, calculates the force and energy changes during collision according to physical laws, and thus obtains collision rendering information. For example, the finite element method can be used to discretize the fluid and interactive objects, establish a physical model, and simulate the collision process by solving the equations of motion and contact.
[0127] In updating the historical velocity field, this application's embodiments comprehensively consider various physical factors, resulting in a mixed velocity field that better reflects the actual motion of the fluid in complex environments. This provides better initial conditions for subsequent processes and helps to satisfy physical constraints such as the fluid's incompressibility at the current moment, ensuring the physical rationality of the fluid simulation.
[0128] In one possible implementation, the divergence-free velocity field can be obtained by projecting the advection velocity field onto a simulator. This can be achieved by solving the divergence field using a divergence operator in the simulator, obtaining the pressure field by performing an inverse Poisson process on the divergence field using a pressure solver in the simulator, and then projecting the advection velocity field onto the gradient field of the pressure field to obtain the divergence-free velocity field.
[0129] To obtain a divergence-free velocity field, the gradient field of the pressure field can be calculated. p Then, the gradient field of the pressure field is subtracted from w_2(x). p This yields the divergence-free velocity field w_3(x). This step typically requires solving a pressure Poisson equation to obtain the pressure field. p Then, the gradient field of the pressure field is calculated based on the pressure field.
[0130] It should be noted that, in the embodiments of this application, there may be multiple candidate solvers for the target parameter to choose from. In one possible implementation, the target parameter includes a pressure field. The embodiments of this application provide various types of pressure solvers, which can then serve as candidate solvers for solving the pressure field.
[0131] (1) Jacobi solver: The advantage of the Jacobi solver is that it is naturally suitable for GPU parallelism and the calculation is simple and direct. However, it requires multiple iterations to converge and requires twice the memory for Ping-Pong read and write. The Jacobi iteration implementation used by the Jacobi solver is very simple.
[0132] When calculating the pressure field for a specific grid cell (i.e., the current grid cell), since the current grid cell may have other adjacent grid cells (e.g., above, below, to the left, to the right, in front of, and behind the current grid cell), in one possible implementation, the formula for calculating the pressure field for the current grid cell could be:
[0133] in, This represents the pressure field of the current grid cell. This represents the pressure field of the grid cell to the left of the current grid cell. This represents the pressure field of the grid cell to the right of the current grid cell. This represents the pressure field of the grid cell below the current grid cell. This represents the pressure field of the grid cell above the current grid cell. This represents the pressure field of the grid cells behind the current grid cell. This represents the pressure field of the grid cell in front of the current grid cell. This represents the size of the current mesh cell, and d represents the coefficient. If the number of mesh cells is limited or the current mesh cell is located at a boundary, resulting in no adjacent mesh cells in any of the following directions: above, below, to the left, to the right, in front, or behind the current mesh cell, then the corresponding pressure field can be zero.
[0134] (2) Red-Black-Gauss-Seidel Solver: The Red-Black-Gauss-Seidel solver uses a checkerboard pattern with alternating iterations, providing neighborhood information sequentially to solve the parallel problem. The Red-Black-Gauss-Seidel solver only requires one texture, saving more memory and increasing efficiency.
[0135] In one possible implementation, an example diagram of the chessboard-like alternating iterations can be found here. Figure 13 As shown. To achieve iterative chessboard grid interaction, the grid cells can be divided into two colors, red and black. Figure 13 In this context, because it's inconvenient to represent red, white is used instead. The colors of other grid cells adjacent to the current grid cell are different from the current grid cell's color. If the current grid cell is black, then the colors of other grid cells adjacent to the current grid cell are red (in...). Figure 13 The middle part is indicated in white; see also... Figure 13 (As shown in Figure (c)). If the current grid cell is red, then the other grid cells adjacent to the current grid cell are black. Figure 13 In the first half of the iteration, the black mesh cells are mainly processed. See [link to related documentation]. Figure 13As shown in Figure (a), the second-half iteration mainly processes the red areas (in...). Figure 13 Mesh cells (represented in white in the image), see [link / reference]. Figure 13 As shown in Figure (b).
[0136] Because it is implemented through a compute shader, when using it, you only need to pass in an integer mask to perform bitwise operations with the thread identity (ID) to distinguish between "parity" and "oddness", which avoids the overhead of a volumetric texture required by the traditional rasterization pipeline.
[0137] (3) Multi Grid solver: The multi grid method used by the Multi Grid solver is not a method exclusive to the field of fluid dynamics. It was originally proposed to solve the problem of "elliptic partial differential equations". It just so happens that the solution of the Poisson equation belongs to this type of problem.
[0138] In one possible implementation, the algorithm steps of the Multi Grid solver can be found in [reference needed]. Figure 14 As shown. The algorithm steps of the MultiGrid solver include: pre-smoothing, performing a small number of relaxation iterations on the fine grid cells to converge high-frequency errors (see...). Figure 14 As shown in S1401, the calculation formula can be... , Here is the coefficient matrix, and k is the number of iterations. For the pressure field on the fine grid cell, For the velocity field on the fine grid cells; calculate the residual (see...). Figure 14 As shown in S1402), the residual represents the low-frequency error that has not yet been eliminated, and the calculation formula can be... , For residuals; the restriction operation maps the residuals to coarse mesh cells through downsampling (see Restriction). Figure 14 As shown in S1403, the calculation formula can be... R represents the constraint operator, used to downsample data from fine-grid cells to coarse-grid cells. It is the residual of the coarse mesh element; Coarse mesh element iteration performs relaxation iteration on the residual projection on the coarse mesh element to eliminate low-frequency errors (see...). Figure 14 As shown in S1404), the calculation formula can be... , The coefficient matrix is on the coarse mesh element. This is the error correction vector on the coarse mesh cells; the prolongation operation extends the low-frequency correction from the coarse mesh cells to the fine mesh cells through linear interpolation upsampling (see...). Figure 14 As shown in S1405, the calculation formula can be... P is the extension operator, used to upsample data from coarse grid cells to fine grid cells. This is the error correction vector on the fine mesh element obtained through interpolation; the correction operation uses the extended low-frequency correction to correct the fine mesh element solution (see...). Figure 14 As shown in S1406), the calculation formula is: , The pressure field on the corrected fine mesh cells; post-smoothing, then another relaxation iteration is performed to smooth out the newly introduced high-frequency errors (see...). Figure 14 As shown in S1407), the calculation formula is: .
[0139] It should be noted that in the Multi Grid solver, fine grid cells can refer to grid cells with high solution accuracy, while coarse grid cells can refer to grid cells with low solution accuracy.
[0140] Unlike the Jacobian and Red-Black-Gauss-Seidel solvers, the multigrid solver generally only needs to be called once, but its internal V-Cycle has its own number of iterations. The hierarchy of grid cells is controllable, depending on the problem being addressed. The solver provided in this embodiment only uses two levels of grid cells, namely full resolution and half resolution. Another point is that the solver is configurable for the three relaxation iterations of the Multi Grid solver, similar to the Jacobian and Red-Black-Gauss-Seidel solvers; this embodiment directly reuses the lighter Red-Black-Gauss-Seidel solver. Finally, the residual operator and constraint operator can be combined into one computational step, as can the extension operator and correction operator, thereby reducing the number of executions and memory usage.
[0141] It should be noted that the fluid simulation method provided in this application can be applied to game development scenarios. In games, fluid effects (such as smoke) need to be linked in real-time with player actions (such as attacking, moving, and skill release). For example, a fire skill might trigger an explosion smoke, or a character's movement might create a trail. This strong interactivity requires the fluid simulation to have low-latency response capabilities. Therefore, this application requires timely detection of interactions to trigger fluid simulation. Thus, in one possible implementation, based on the historical velocity field at a historical moment, the method of solving the control equation and the advection diffusion equation sequentially using a simulator to obtain the post-advection density field of the fluid at the current moment can be achieved when an interactive object enters the interaction detection range. In other words, this application triggers the execution of the fluid simulation method promptly when an interactive object is detected entering the interaction detection range.
[0142] The interaction detection range can be a specific spatial area in a fluid simulation or game physics engine used to accurately detect the interaction behavior between external interactive objects and fluids. Its core function is to trigger real-time collision detection and physical response when an interactive object approaches the fluid to a certain extent, thereby achieving dynamic interactive effects (such as dragging, impact, splashing, etc.). The interaction detection range is a predefined geometric area (such as a circle, rectangle, sphere, etc.) set around the fluid or its key parts (such as the surface, center).
[0143] Interaction detection range is a key mechanism for achieving efficient and dynamic interaction in fluid simulation. In this embodiment, fluid simulation is performed only when the interaction object enters the interaction detection range, based on whether the interaction object has entered the interaction detection range. This ensures that complex calculations are triggered only when necessary, thereby avoiding the high-performance overhead of global real-time detection while maintaining visual effects. Interactions are calculated only when necessary, balancing effects and efficiency, and optimizing performance overhead.
[0144] It is understandable that fluid simulation may require various resources and data, such as historical velocity fields and even textures. Loading these resources and data takes time. Therefore, in one possible implementation, the relevant resources and data can be loaded before the fluid simulation method is executed. Taking the historical velocity field as an example, the historical velocity field of the fluid at a historical moment can be obtained when the interactive object enters the activation detection range. In other words, in this embodiment, an activation detection range is set. When the interactive object enters the activation detection range, the system starts a warm-up program to prepare relevant texture resources and data, and fluid simulation and volume rendering begin. However, at this time, only the fluid's own field signal is present, and no interactive behavior has yet occurred, so that fluid simulation can be performed as soon as subsequent interactive behavior occurs.
[0145] The activation detection range can be the area that initiates the warm-up process. It is a large area surrounding the fluid object, usually circular, rectangular, or spherical. When external and interactive objects (such as characters or props) enter this activation detection range, it is considered that the interactive object may be approaching the fluid, and the warm-up process is initiated to prepare relevant texture resources and data.
[0146] Understandably, the activation detection range can cover all potential interaction areas that the fluid might affect, ensuring that resource preheating is triggered promptly when an object approaches. The interaction detection range can cover the fluid surface or core interaction areas, ensuring detection accuracy and computational efficiency. Therefore, the activation detection range typically wraps around the interaction detection range, forming a hierarchical structure of "outer layer pre-detection, inner layer precise detection." For example, in a 2D game, the activation detection range might be a large circle centered on the fluid, while the interaction detection range is a small circle within the activation detection range or an area close to the fluid surface.
[0147] This application embodiment determines whether the interactive object has entered the activation detection range. When the interactive object enters the activation detection range, the textures and data required for fluid simulation are loaded in advance, avoiding the delay caused by real-time memory allocation. By predicting potential interactions, the delay of real-time fluid simulation startup is reduced, and the smoothness of user experience is improved.
[0148] Based on the above introduction to the activation detection range and interaction detection range, for 2D simulation, raycasting can be used to execute the physical process. This process occurs within a dedicated channel and therefore does not affect other physical processes. In addition to the core component responsible for fluid simulation, the fluid also has two collision components used for "activation detection" and "interaction detection," respectively. When an interactive object enters the activation detection range, the system initiates a warm-up program, preparing relevant textures and data. Fluid simulation and volume rendering begin, but at this time only the fluid's own field signal is present, and no interactive behavior has occurred. When an interactive object enters the interaction detection range, the system begins to perform raycasting to find collision points and execute trajectory drawing. This application provides a set of memory visualization tools to display the changes in field information during key steps of fluid solution, facilitating debugging and effect adjustment.
[0149] The interactive footprint diagram displayed through visualization tools can be seen in [reference needed]. Figure 15 As shown, the effect diagrams for various field information can be found in [reference needed]. Figure 16 As shown. Figure 16 The middle (a) figure is a rendering of the collision painting information, which is the painting process related to collision detection. In fluid simulation or game physics engines, it is used to visualize collision effects or mark collision areas. Figure 16 Figure (b) shows the effect of the composite velocity and density fields. Figure 16 Figure (c) shows the effect of advection on the velocity and density fields in Figure (b). Figure 16 The middle (d) figure shows the effect of the divergence field. Figure 16 Figure (e) shows the effect of the pressure field. Figure 16 Figure (f) shows the effect of the pressure field that needs to be temporarily stored during the iterative process.
[0150] For 3D simulations, ray detection is no longer applicable; therefore, this application provides a collision detection method based on a distance field. There are multiple ways to generate the distance field. For dynamic mesh cells, there is a low-frequency distance field generated by the GPU-based 3D Jump Flooding Algorithm (JFA), or it can be extracted from the global distance field streamed within the UE's internal paging process. This depends on the application scenario and the performance and accuracy requirements. See also... Figure 17 As shown, Figure 17 An example diagram is shown showing the use of JFA to generate distance field information in real time for a skeleton mesh. The bounding box can be shared with the simulated mesh cells or used as a subset of the simulated mesh cells.
[0151] Similar to 2D memory visualization tools, 3D solvers also have a set of visualization tools, which are essentially small volumetric renderers that render field information through a separate Ray Marching process. See also Figure 18 As shown, Figure 18 Figure (a) shows the rendered velocity field. Figure 18 Figure (b) shows the rendered density field.
[0152] Based on the solver encapsulation approach described above, this application illustrates a standard 2D and 3D solution process and data flow in a fluid simulation method. The entire fluid simulation process is completed sequentially by a series of computation queues representing operators and solvers. Figure 19aThe 2D solution loop is demonstrated. In this loop, advection is first performed on the input velocity field, using a first-order Runge-Kutta integral from a Lagrange perspective. Next, the advection velocity field is used to calculate the divergence field, where divergence is the source of internal pressure. Then, an inverse Poisson process is initiated, calculating the pressure field using a configurable pressure solver. In this embodiment, the pressure solver can be a red-black-Gauss-Seidel solver, with the iteration process divided into a first half and a second half. Finally, with the pressure field, a projection process is performed to obtain the divergence-free velocity field. In the synthesis stage, this embodiment can mix the historical velocity field, the current input velocity field, and the collision rendering information output by the collision renderer. It is important to note that for the 2D process, the advection process of the density field is integrated into the solution process of the governing equations in engineering implementation, which reduces dispatch and memory usage.
[0153] The execution order of the solution loop in 3D simulation is slightly different from that in 2D simulation, and it is closer in form to the standard StableFluids model. Figure 19b The 3D solution loop is demonstrated. First, it allows solving for various force field generators (such as gravity, wind, etc.) in the connected system to update the velocity field. Then, it performs advection on the velocity field using the first advection operator. In 3D simulation, the velocity field advection process is the second largest performance overhead after solving the Poisson equation. This application provides the standard 3rd-order Runge-Kutta integral and the faster MacCormack advection. Then, the advection velocity field is also calculated by the divergence operator to obtain the divergence field. Next, with the divergence field, the inverse Poisson process is performed to calculate the pressure field. Here, multiple iterative solvers are also provided for selection. Finally, a projection process is performed on the pressure field to obtain a relatively divergence-free velocity field. This completes the first stage of Stable Fluids: solving the governing equations. Then, it enters the second stage: solving the advection-diffusion equations. Based on the divergence-free velocity field, the density field is advectioned using the second advection operator. The advection-transported density field can then be passed to the volume renderer for rendering.
[0154] The fluid simulation method provided in this application fills the gap in the current Unreal Engine ecosystem, such as game engines, which lacks production-ready 3D fluid (especially gas) simulation tools. Its modular solver design can well adapt to the complex, ever-changing, and performance-sensitive needs of game applications, further unleashing the performance potential of real-time volumetric effects. The fluid simulation method provided in this application has been implemented in PC and console projects, demonstrating its practical value. (See reference for results.) Figure 20 As shown in the statistics. Figure 20This demonstrates the effectiveness of applying fluid simulation methods to three scenarios: from top to bottom, a scenario where a character traverses dry ice fog, a scenario with multiple interactive objects, and a scenario involving collisions and turbulence caused by a character moving through dry ice fog. In the scenario where the character traverses dry ice fog, 2D fluid dynamics and 2.5D volumetric rendering were implemented, with a simulation resolution of 256×256, a simulation area size of 30m×30m×1m, 5 Jacobi iterations, and a simulation cost of 0.3ms. In the scenario with multiple interactive objects, 2D fluid dynamics and 2.5D volumetric rendering were implemented, with a simulation resolution of 720×720, a simulation area size of 10m×10m×1m, 5 Jacobi iterations, and a simulation cost of 0.6ms. In the scenario involving collisions and turbulence caused by a character moving through dry ice fog, 3D fluid dynamics and 3D volumetric rendering were implemented, with a simulation resolution of 64×64×64, a simulation area size of 10m×10m×3m, 5 Jacobi iterations, and a simulation cost of 1.16ms.
[0155] It should be noted that, based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods.
[0156] Based on the fluid simulation method provided in the foregoing embodiments, this application also provides a fluid simulation device 2100. See also... Figure 21 As shown, the fluid simulation device 2100 includes a memory management unit 2101 and a solution unit 2102: The memory management unit 2101 is used to acquire the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment. The solution unit 2102 is used to solve the control equation and the advection diffusion equation sequentially through a simulator based on the historical velocity field at the historical moment, so as to obtain the advection density field of the fluid at the current moment. The simulator is composed of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the governing equation and the advection diffusion equation in sequence through the simulator.
[0157] In one possible implementation, the solving unit 2102 is used for: When the interactive object enters the interaction detection range, based on the historical velocity field, the simulator is used to solve the control equation and the advection diffusion equation in sequence to obtain the post-advection density field.
[0158] In one possible implementation, the memory management unit 2101 is used for: When the interactive object enters the activation detection range, the historical velocity field is obtained.
[0159] In one possible implementation, the solving unit 2102 is used for: Based on the historical velocity field, the control equations are solved using the simulator; In the process of solving the governing equations, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field; the updated velocity field is then adsorbed by the first adsorption operator in the simulator to obtain the adsorption velocity field; and based on the adsorption velocity field, a divergence-free velocity field is obtained by projection through the simulator. Based on the divergence-free velocity field, the advection diffusion equation is solved using the simulator to obtain the post-advection density field; In the process of solving the advection-diffusion equation, the initial density field is calculated by the source injection operator in the simulator; based on the divergence-free velocity field, the initial density field is adsorbed by the second advection operator in the simulator to obtain the adsorbed density field.
[0160] In one possible implementation, the solving unit 2102 is used for: Based on the interactive external force generated by the interactive object at its current position, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field.
[0161] In one possible implementation, the number of interactive objects is multiple, and the solving unit 2102 is used for: For each of the interactive objects at the current position, calculate the change in the velocity field corresponding to the interactive force; The velocity field changes corresponding to each of the aforementioned interactive external forces are superimposed to obtain the comprehensive change; Using the comprehensive changes, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field.
[0162] In one possible implementation, the solving unit 2102 is used for: The historical velocity field, the current input velocity field, and the collision rendering information are mixed to obtain the updated velocity field. The collision rendering information is the data generated when the interactive object collides with the fluid, which is used to render the collision effect.
[0163] In one possible implementation, the solving unit 2102 is used for: Based on the advection velocity field, the divergence field is obtained by solving the divergence operator in the simulator; The pressure field is obtained by performing an inverse Poisson process on the divergence field using the pressure solver in the simulator. The divergence-free velocity field is obtained by projecting the gradient field of the pressure field onto the advection velocity field.
[0164] In one possible implementation, the device further includes a display unit and a determination unit: The display unit is used to display the simulation settings interface, which includes multiple candidate solvers for the target parameters. The determining unit is configured to, in response to a selection operation of a target solver among the plurality of candidate solvers, determine the target solver as the solver for the target parameters in the simulator.
[0165] In one possible implementation, the device further includes a partitioning unit: The dividing unit is used to divide the fluid into multiple grid units; The memory management unit 2101 is used for: For each of the plurality of grid cells, the historical velocity of the grid cell is acquired in parallel to obtain the historical velocity field of the fluid. The solving unit 2102 is used for: For each of the plurality of grid cells, the governing equations and the advection-diffusion equations are solved sequentially by the simulator based on the historical velocity of the grid cell to obtain the post-advection density value of the grid cell at the current moment. The post-advection density values corresponding to the plurality of grid cells constitute the post-advection density field, and the historical velocities corresponding to the plurality of grid cells constitute the historical velocity field.
[0166] In one possible implementation, the device further includes a storage unit: The storage unit is used to store the current post-advection density field in the texture, and each texel of the texture is used to store the post-advection density value of the mesh cell corresponding to the texel in the post-advection density field.
[0167] In one possible implementation, the memory management unit 2101 is used for: The historical velocity field is read from on-chip memory.
[0168] As can be seen from the above technical solution, the embodiments of this application further modularize the simulator used for fluid simulation, decomposing the solution process into the smallest executable units, namely operators and solvers. Each operator or solver is used to solve for simulation parameters, and different operators and solvers used to obtain simulation parameters are connected in series to form a simulator. The simulation parameters are all parameters obtained by the simulator in the process of solving the governing equations and the advection-diffusion equations sequentially. There are multiple choices for the solver of the target parameters in the simulation parameters. Based on the simulation influencing factors, the solver for the target parameters in the simulator is determined from multiple candidate solvers. Thus, when fluid simulation is required, the historical velocity field of the fluid at a historical moment is obtained, where the historical moment is the moment before the current moment. Based on the historical velocity field at a historical moment, the simulator sequentially solves the governing equations and the advection-diffusion equations to obtain the post-advection density field of the fluid at the current moment. In this way, the entire fluid simulation process can be completed by a series of operators and solvers executed sequentially. Because the simulator adopts a modular encapsulation approach, fluid simulations of different complexities and scenarios can be adapted simply by connecting different numbers and types of operators and solvers. This makes it easy to extend the simulator to address the variable needs for input data sources and added details in different application scenarios. This fluid simulation method has strong scalability and can well adapt to complex, ever-changing, and performance-sensitive business requirements.
[0169] This application also provides a computer device capable of executing fluid simulation methods. The computer device may be a terminal. Figure 22 This diagram illustrates the structure of a terminal according to an embodiment of this application. Figure 22 In this example, using a smartphone as the terminal: refer to Figure 22 A smartphone includes components such as: radio frequency (RF) circuitry 2210, memory 2220, input unit 2230, display unit 2240, sensor 2250, audio circuitry 2260, Wi-Fi module 2270, processor 2280, and power supply 2290. The input unit 2230 may include a touch panel 2231 and other input devices 2232, the display unit 2240 may include a display panel 2241, and the audio circuitry 2260 may include a speaker 2261 and a microphone 2262. It is understood that... Figure 22 The smartphone structure shown does not constitute a limitation on smartphones and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0170] The memory 2220 can be used to store software programs and modules. The processor 2280 executes various functions and data processing of the smartphone by running the software programs and modules stored in the memory 2220. The memory 2220 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, phonebook, etc.). In addition, the memory 2220 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0171] The processor 2280 is the control center of the smartphone, connecting various parts of the smartphone via various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 2220, and by accessing data stored in the memory 2220. Optionally, the processor 2280 may include one or more processing units; preferably, the processor 2280 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 2280.
[0172] In this embodiment, the processor 2280 in the smartphone can execute the methods provided in the various embodiments of this application.
[0173] The computer device provided in this application embodiment can also be a server. Please refer to [link / reference]. Figure 23 As shown, Figure 23 This is a structural diagram of the server 2300 provided in this application embodiment. The server 2300 can vary significantly due to different configurations or performance. It may include one or more processors, such as a central processing unit (CPU) 2322, and a memory 2332, and one or more storage media 2330 (e.g., one or more mass storage devices) for storing application programs 2342 or data 2344. The memory 2332 and storage media 2330 can be temporary or persistent storage. The program stored in the storage media 2330 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 2322 may be configured to communicate with the storage media 2330 and execute the series of instruction operations in the storage media 2330 on the server 2300.
[0174] Server 2300 may also include one or more power supplies 2326, one or more wired or wireless network interfaces 2350, one or more input / output interfaces 2358, and / or one or more operating systems 2341, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0175] In this embodiment, the central processing unit 2322 in the server 2300 can execute the methods provided in the embodiments of this application.
[0176] According to one aspect of this application, a computer-readable storage medium is provided for storing a computer program for performing the methods described in the foregoing embodiments.
[0177] According to one aspect of this application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.
[0178] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0179] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0181] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0182] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0183] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a terminal, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing computer programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0184] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0185] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A fluid simulation method, characterized in that, The method includes: Obtain the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment; Based on the historical velocity field at the historical moment, the governing equation and the advection diffusion equation are solved sequentially by the simulator to obtain the advection density field of the fluid at the current moment. The simulator is composed of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the control equation and the advection diffusion equation in sequence through the simulator. The historical velocity field based on the historical moment is used to solve the governing equations and advection-diffusion equations sequentially using a simulator to obtain the post-advection density field of the fluid at the current moment, including: Based on the historical velocity field, the control equations are solved using the simulator; In the process of solving the governing equations, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field; the updated velocity field is then adsorbed by the first adsorption operator in the simulator to obtain the adsorption velocity field; and based on the adsorption velocity field, a divergence-free velocity field is obtained by projection through the simulator. Based on the divergence-free velocity field, the advection diffusion equation is solved using the simulator to obtain the post-advection density field; In the process of solving the advection-diffusion equation, the initial density field is calculated by the source injection operator in the simulator; based on the divergence-free velocity field, the initial density field is adsorbed by the second advection operator in the simulator to obtain the adsorbed density field. The process of projecting the advection velocity field onto the simulator to obtain a divergence-free velocity field includes: Based on the advection velocity field, the divergence field is obtained by solving the divergence operator in the simulator; The pressure field is obtained by performing an inverse Poisson process on the divergence field using the pressure solver in the simulator. The divergence-free velocity field is obtained by projecting the gradient field of the pressure field onto the advection velocity field.
2. The method according to claim 1, characterized in that, The historical velocity field based on the historical moment is used to solve the governing equations and advection-diffusion equations sequentially using a simulator to obtain the post-advection density field of the fluid at the current moment, including: When the interactive object enters the interaction detection range, based on the historical velocity field, the simulator is used to solve the control equation and the advection diffusion equation in sequence to obtain the post-advection density field.
3. The method according to claim 2, characterized in that, The acquisition of the historical velocity field of the fluid at a historical moment includes: When the interactive object enters the activation detection range, the historical velocity field is obtained.
4. The method according to claim 1, characterized in that, The step of updating the historical velocity field using the velocity field solver in the simulator to obtain the updated velocity field includes: Based on the interactive external force generated by the interactive object at its current position, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field.
5. The method according to claim 4, characterized in that, The number of interactive objects is multiple. Based on the interactive external force generated by the interactive objects at their current positions, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field, including: For each of the interactive objects at the current position, calculate the change in the velocity field corresponding to the interactive force; The velocity field changes corresponding to each of the aforementioned interactive external forces are superimposed to obtain the comprehensive change; Using the comprehensive changes, the historical velocity field is updated by the velocity field solver in the simulator to obtain the updated velocity field.
6. The method according to claim 1, characterized in that, The step of updating the historical velocity field using the velocity field solver in the simulator to obtain the updated velocity field includes: The historical velocity field, the current input velocity field, and the collision rendering information are mixed to obtain the updated velocity field. The collision rendering information is the data generated when the interactive object collides with the fluid, which is used to render the collision effect.
7. The method according to claim 1, characterized in that, The method further includes: The simulation settings interface is displayed, which includes multiple candidate solvers for the target parameters; In response to the selection operation of the target solver among the plurality of candidate solvers, the target solver is determined as the solver for the target parameters in the simulator.
8. The method according to any one of claims 1-7, characterized in that, The method further includes: The fluid is divided into multiple grid cells; The acquisition of the historical velocity field of the fluid at a historical moment includes: For each of the plurality of grid cells, the historical velocity of the grid cell is acquired in parallel to obtain the historical velocity field of the fluid. The historical velocity field based on the historical moment is used to solve the governing equations and advection-diffusion equations sequentially using a simulator to obtain the post-advection density field of the fluid at the current moment, including: For each of the plurality of grid cells, the governing equations and the advection-diffusion equations are solved sequentially by the simulator based on the historical velocity of the grid cell to obtain the post-advection density value of the grid cell at the current moment. The post-advection density values corresponding to the plurality of grid cells constitute the post-advection density field, and the historical velocities corresponding to the plurality of grid cells constitute the historical velocity field.
9. The method according to claim 8, characterized in that, The method further includes: The post-advection density field at the current moment is stored in a texture, and each texel of the texture is used to store the post-advection density value of the mesh cell corresponding to the texel in the post-advection density field.
10. The method according to any one of claims 1-7, characterized in that, The acquisition of the historical velocity field of the fluid at a historical moment includes: The historical velocity field is read from on-chip memory.
11. A fluid simulation device, characterized in that, The device includes a memory management unit and a solution unit: The memory management unit is used to acquire the historical velocity field of the fluid at a historical moment, where the historical moment is the moment before the current moment; The solution unit is used to solve the governing equations and advection diffusion equations sequentially using a simulator based on the historical velocity field at the historical moment, so as to obtain the advection density field of the fluid at the current moment. The simulator is composed of different operators and solvers connected in series to obtain simulation parameters. Each operator or solver is used to solve for the simulation parameters. In the process of solving for the advection density field, the solver used to solve for the target parameters in the simulation parameters is determined from multiple candidate solvers based on the simulation influencing factors. The simulation parameters are all the parameters obtained by solving the control equation and the advection diffusion equation in sequence through the simulator. The solving unit is used to solve the governing equations based on the historical velocity field using the simulator; wherein, during the process of solving the governing equations, the historical velocity field is updated by the velocity field solver in the simulator to obtain an updated velocity field; the updated velocity field is adsorbed by the first adsorption operator in the simulator to obtain an adsorption velocity field; and a divergence-free velocity field is obtained by projecting the adsorption velocity field through the simulator. Based on the divergence-free velocity field, the advection-diffusion equation is solved using the simulator to obtain the post-advection density field; wherein, during the solution of the advection-diffusion equation, the initial density field is calculated using the source injection operator in the simulator; based on the divergence-free velocity field, the initial density field is adducted using the second advection operator in the simulator to obtain the post-advection density field; The solution unit is used to obtain a divergence field based on the advection velocity field by using the divergence operator in the simulator; to obtain a pressure field by performing an inverse Poisson process on the divergence field using the pressure solver in the simulator; and to obtain the divergence-free velocity field by projecting the advection velocity field onto the gradient field of the pressure field.
12. A computer device, characterized in that, The computer device includes a processor and memory: The memory is used to store computer programs and to transfer the computer programs to the processor; The processor is configured to execute the method according to any one of claims 1-10 according to instructions in the computer program.
13. A computer-readable storage medium for storing a computer program that, when executed by a processor, causes the processor to perform the method of any one of claims 1-10.
14. A computer program product comprising a computer program that, when executed by a processor, implements the method of any one of claims 1-10.
Citation Information
Patent Citations
Pressure field determination method and device
CN112560326A
System and cloud platform for simulating fluid mechanics problem based on quantum computing
CN117634331A
Method and system for performing computer graphic simulation of a fluid using target-driven control
US20050253854A1