Method and device for rendering virtual fluid
By improving the LBM-SWE method and utilizing higher-order mechanical models and higher-order relaxation times, the problem of inaccurate dynamic water flow simulation in existing technologies has been solved, and efficient and accurate fluid simulation in complex scenarios has been achieved.
Patent Information
- Application Number
- CN202410765522.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2025-12-16
AI Technical Summary
Existing technologies struggle to accurately simulate dynamic water flow at low cost or with low data volume, especially in complex scenarios where turbulence and laminar flow simulations are not precise enough.
The traditional LBM-SWE method is modified by forcing a higher-order mechanical model. By improving the calculation of fluid velocity parameters and updating the distribution function, and combining higher-order relaxation time and rotationally symmetric gradient approximation, the accuracy and stability of fluid simulation are improved.
It generates more accurate flow maps with lower computational cost in complex scenarios, improving the accuracy of turbulence and laminar flow simulations and reducing computational resource requirements.
Smart Images

Figure CN121147367A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of simulation, and in particular, to a method and apparatus for rendering virtual fluid, a storage medium and a computer device. BACKGROUND
[0002] Currently, in the fields of games and virtual reality, it is required to realize real-time simulation of dynamic water flow for some scenes. Specifically, through the real-time simulation technology of dynamic water flow, realistic water surface rendering can be realized, which can significantly enhance the user's sense of immersion and realism experience, and contribute to creating a virtual environment that is as real as life.
[0003] For example, in the game industry, by simulating a realistic water surface to represent scenes in real natural environments such as rivers, waterfalls, oceans, etc., the realism of the game world can be improved, and the overall game experience can be improved. In the field of virtual reality, accurate simulation of water surface state also helps to create an immersive experience, making users feel as if they are in a realistic environment. In the field of film and television special effects, fine water surface rendering can also create realistic ocean and river scenes for movies and TV series. In the field of digital twinning, by accurately simulating hydrological environment, more accurate modeling of the real world can also be achieved.
[0004] However, there is still no effective solution to accurately simulate dynamic water flow at low cost or low data volume. It is necessary to improve the existing technology. SUMMARY
[0005] The present disclosure provides a method and apparatus for rendering virtual fluid, a storage medium and a computer device.
[0006] According to a first aspect of the present disclosure, a method for rendering virtual fluid is disclosed, wherein the virtual fluid includes at least one virtual fluid particle, and the method comprises: determining a second distribution function corresponding to the virtual fluid particle based on a first distribution function corresponding to the virtual fluid particle, wherein the first distribution function corresponds to a current time step, and the second distribution function corresponds to a next time step; estimating a fluid depth parameter of the virtual fluid and a fluid velocity parameter of the virtual fluid at the next time step based on the first distribution function and the second distribution function; adjusting the fluid velocity parameter of the virtual fluid at the current time step and the fluid velocity parameter of the virtual fluid at the next time step based on an external force parameter term corresponding to the virtual fluid; updating the first distribution function based on the fluid velocity parameter of the virtual fluid at the current time step and the fluid velocity parameter of the virtual fluid at the next time step; and rendering the virtual fluid based on the updated first distribution function.
[0007] According to a second aspect of the present disclosure, a device for rendering virtual fluid is disclosed, comprising: one or more processors; and one or more memories having stored therein computer-executable programs that, when executed by the processors and the display, perform the method according to the second aspect of the present disclosure.
[0008] According to a third aspect of the present disclosure, a computer device is disclosed, comprising: one or more processors; and one or more memories having stored therein computer-executable programs that, when executed by the processors and the display, perform the method as described above.
[0009] According to a fourth aspect of the present disclosure, a computer program product is disclosed, stored in a computer-readable storage medium, and comprising computer instructions that, when executed by a processor, cause a computer device to perform the method as described above.
[0010] According to a fifth aspect of the present disclosure, a computer-readable storage medium is disclosed, having stored thereon computer-executable instructions for implementing the method as described above when executed by a processor.
[0011] Embodiments of the present disclosure improve the conventional real-time simulation method of dynamic water flow to achieve more accurate simulation of turbulent flow and laminar flow. The improvements of embodiments of the present disclosure include adjusting the conventional real-time simulation method of dynamic water flow by using a forced high-order mechanics model, thereby improving the accuracy and reliability of the simulation results. By using embodiments of the present disclosure, more accurate flow graphs can be generated in complex situations with lower computational effort. BRIEF DESCRIPTION OF DRAWINGS
[0012] The accompanying drawings, which are included to provide a further understanding of the present disclosure and constitute a part of the present disclosure, illustrate certain illustrative embodiments of the present disclosure and together with the description, serve to explain the present disclosure, but do not limit the present disclosure in any way.
[0013] Figure 1 A schematic diagram of an application scenario according to an embodiment of the present disclosure is shown.
[0014] Figure 2 A schematic diagram of nine velocity directions based on a virtual lattice structure is shown.
[0015] Figure 3 A flowchart of a method for rendering virtual fluid according to an embodiment of the present disclosure is shown.
[0016] Figure 4 A schematic diagram of boundary processing according to an embodiment of the present disclosure is shown.
[0017] Figure 5A rendering of an effect diagram is shown in accordance with an embodiment of the present disclosure.
[0018] Figure 6 A schematic diagram of an electronic device is shown in accordance with an embodiment of the present disclosure.
[0019] Figure 7 A schematic diagram of an architecture of an exemplary computing device is shown in accordance with an embodiment of the present disclosure.
[0020] Figure 8 A schematic diagram of a storage medium is shown in accordance with an embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] In order to make the objects, technical solutions and advantages of the present disclosure more obvious, the following will describe the example embodiments according to the present disclosure in detail with reference to the drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the example embodiments described herein.
[0022] In the present specification and drawings, the operations and elements with substantially the same or similar functions and elements are denoted by the same or similar reference numerals, and repeated description of these operations and elements will be omitted. Meanwhile, in the description of the present disclosure, the terms "first", "second", and the like are used to distinguish the same items or similar items with substantially the same functions and operations, and it should be understood that there is no logical or chronological dependency between "first", "second", "nth", and the like, and the number and execution order are not limited. It should also be understood that although the following description uses the terms first, second, and the like to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of various examples, first data can be referred to as second data, and similarly, second data can be referred to as first data. First data and second data can both be data, and in some cases, can be separate and distinct data. The term "at least one" in this application means one or more, and the term "multiple" in this application means two or more.
[0023] It should be understood that the terms used in the description of various examples herein are only for the purpose of describing specific examples, and are not intended to be limiting. As used in the description of various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0024] It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. The term "and / or", is a descriptive association relationship of associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, the character " / " in the present application generally represents an "or" relationship between the front and rear associated objects.
[0025] It should also be understood that in various embodiments of the present application, the size of the sequence number of each process does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. It should also be understood that according to (based on) A to determine B does not mean that B is determined only according to (based on) A, but B can also be determined according to (based on) A and / or other information.
[0026] It should also be understood that the term "includes" (also referred to as "includes", "including", "comprises" and / or "comprising") when used in the specification specifies the presence of the stated features, integers, operations, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, operations, operations, elements, components, and / or groups thereof.
[0027] It should also be understood that the term "if" can be interpreted to mean "when" or "upon" or "in response to a determination" or "in response to detecting". Similarly, the phrase "if it is determined" or "if [a stated condition or event] is detected" can be interpreted to mean "upon determining" or "in response to determining" or "upon detecting [the stated condition or event]" or "in response to detecting [the stated condition or event]".
[0028] To facilitate the description of the present disclosure, the concepts related to the present disclosure are introduced as follows.
[0029] Before the present disclosure is described in detail, in order to help the understanding of the technical solutions of the present disclosure, the following first explains the terms to be used in the present disclosure.
[0030] Cloud computing: Cloud computing is an Internet-based computing method, through which server-side software and hardware resources and information can be provided to terminal devices according to demand. Cloud computing is a comprehensive computing technology, which mainly involves distributed computing, utility computing, load balancing, parallel computing, network storage, hot backup redundancy and virtualization, etc.
[0031] Cloud gaming: Cloud gaming, also known as gaming on demand, is an online gaming technology based on cloud computing. Cloud gaming technology enables thin clients with relatively limited graphics processing and data processing capabilities to run high-quality games. In the cloud gaming scenario, the game is not run on the player's game terminal (i.e., the user terminal), but is run in the cloud game server, and the cloud game server renders the game scene into an audio and video stream and transmits it to the player's game terminal through the network. The player's game terminal does not need to have powerful graphics processing and data processing capabilities, but only needs to have basic streaming media playback capabilities and the ability to obtain game player input instructions and send them to the cloud game server. The cloud game server can carry multiple GPU devices and be used for graphics computing. Here, GPU refers to a microprocessor used to perform image and graphics-related operation work.
[0032] Physics engine: A physics engine is used to simulate the physical properties of objects in the real world. For example, an example of a background physics engine can be a computing module for simulating a Newtonian mechanics model, which calculates motion, rotation, and collision reflection by giving real physical properties to rigid objects. Specifically, the physics engine can use variables such as mass, velocity, friction, and air resistance to predict the effects of various complex object collisions, rolling, sliding, or bouncing. It is mainly used in computational physics, electronic games, and computer animation. There are two types of physics engines: real-time physics engines and high-precision physics engines. High-precision physics engines require more processing power to calculate very precise physics and are usually used in scientific research (computational physics) and computer animation film production. Real-time physics engines are usually used in electronic games and simplify calculations to reduce accuracy to reduce calculation time to obtain acceptable processing speed in electronic games. The real-time simulation technology of dynamic water flow implemented according to the embodiments of the present disclosure can be carried on the physics engine to achieve higher precision and faster speed of dynamic water flow simulation.
[0033] Real-time simulation of dynamic water flow: Real-time simulation of dynamic water flow is a technology based on computer graphics and physics that generates and displays dynamic changes in water flow in a virtual environment in real time. It uses physical models and fluid mechanics equations to simulate the natural behavior of water flow, including flow, waves, and collisions, and achieves real-time calculation through efficient algorithms and powerful computing power, and generates realistic water surface effects using graphics processing technology. This technology allows users to interact with water flow, enhancing the liveliness and immersion of virtual environments. Application fields include games, virtual reality, film special effects, and engineering simulation, which can enhance realism and user experience in these fields.
[0034] Lattice Boltzmann Method (LBM): LBM is a computational fluid dynamics method based on mesoscopic simulation scale. It simulates the motion of macroscopic fluid in discrete grid space by simulating the motion and interaction of particles. Specifically, LBM defines a set of particle velocity models on discrete grid, describing the motion of particles in different directions. By constructing simple linear operators, the flow, collision and other processes of particles are simulated, and the solution of fluid system dynamics equation is realized. LBM has the advantages of high computational efficiency, flexible boundary condition processing, suitable for parallel computing, etc., and is widely used in complex flow, heat and mass transfer, multiphase flow, turbulent flow simulation and other fields. The core of LBM is to convert complex fluid mechanics equations into simplified calculation format through statistical mechanics principle, which provides an intuitive and efficient tool for fluid dynamics simulation.
[0035] Shallow Water Equations (SWE): Shallow water equations are a set of partial differential equations describing the motion of fluid in shallow water, used to simulate the flow of water depth much smaller than the horizontal scale. These equations are derived from the conservation laws of fluid mechanics, including mass conservation and momentum conservation, and are usually applicable to long wave phenomena in oceans, lakes, rivers and atmosphere. Shallow water equations assume that water is uniformly distributed in the vertical direction and ignore vertical acceleration, simplifying three-dimensional flow to two-dimensional flow on the plane. The main forms of shallow water equations include continuity equation and momentum equation, describing the changes of water depth and horizontal velocity respectively. Shallow water equations are widely used in hydrology, water conservancy engineering, environmental science and meteorology, etc., to simulate and predict floods, tides, tsunamis and other shallow water wave phenomena.
[0036] Flow Map: Flow map technology is a visualization technique that represents the flow trajectory and direction of fluid (such as water, air, etc.) in space. It generates a large number of trace particles along the streamline by densely sampling the flow field, and renders intuitive flow images based on the position, velocity and other information of these particles, thus visualizing the invisible fluid motion.
[0037] Relaxation: Relaxation is used to describe the process of a system transitioning from an unstable state to a stable state. This includes the gradual adjustment of energy, momentum or other physical quantities, so that the system reaches equilibrium.
[0038] Figure 1 An application scenario diagram is shown according to an embodiment of the present disclosure.
[0039] The physical engine for rendering the virtual fluid method of the embodiments of the present disclosure can be integrated on various computer devices, such as terminals or servers, which can be directly or indirectly connected through wired or wireless communication.
[0040] The server can obtain operation information of each virtual entity (for example, operation information of a controlled game character) and / or change information of the virtual environment (for example, based on the input of the game developer or the information provided by the terminal), and then predict and calculate the effects of collision, rolling, sliding or bouncing that various complex virtual objects can present in real time, and finally present these effects on the game screen of the terminal.
[0041] In addition, the effects of collision, rolling, sliding or bouncing that various complex virtual objects can present can also be completed only by the terminal, that is, the terminal obtains the operation information of each virtual entity and / or the change information of the virtual environment, and uses the physical engine built-in the terminal, and predicts and calculates the effects of collision, rolling, sliding or bouncing that various complex virtual objects can present in real time, so that similar effects can be presented in the game screen displayed on the terminal.
[0042] The terminal can include a smart game console, a smart phone, a tablet computer, a notebook computer, a personal computer, and a wearable smart device, and the like, which has a storage unit and is installed with a microprocessor. The server can be a background server of any terminal (or an application deployed in the terminal), which is used to interact with the terminal running the any terminal (or the application deployed in the terminal) to provide computing and application service support for the any terminal (or the application deployed in the terminal).
[0043] The server can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers, or the server can also be a cloud server. The smart device and the server can be directly or indirectly connected through wired or wireless communication, and the connection mode between the smart device and the server is not limited in the embodiments of the present disclosure.
[0044] The terminal and the server as computer devices can both include a memory and a processor, and the memory is used to store computer programs executable by the processor. Illustratively, the memory can store a virtual environment program for installation and running on, for example, a mobile terminal.
[0045] It should be noted that, Figure 1The application scenario diagram shown is only an example, and the application scenarios described in the embodiments of the present disclosure are used to more clearly illustrate the technical solutions of the present disclosure, and do not constitute a limitation on the technical solutions provided by the present disclosure. Those skilled in the art can know that, as the physical engine evolves and new business scenarios appear, the technical solutions provided by the present disclosure are also applicable to similar technical problems.
[0046] Next, a traditional method of simulating water flow will be introduced. Figure 2
[0047] Figure 2 A schematic diagram of nine velocity directions based on a virtual lattice structure is shown.
[0048] Currently, there are position-based fluid schemes, smoothed particle hydrodynamics-based schemes, and shallow water equation-based schemes to achieve real-time simulation of dynamic water flow. However, these methods still face challenges when dealing with scenarios that require large-scale simulation with high-fidelity results. In these schemes, a large amount of computing resources and time is still required to achieve high-fidelity fluid simulation. Therefore, it is often difficult to use these schemes in real-time applications. Especially when complex large-scale fluid behavior needs to be simulated, these schemes are often not applicable due to the huge computational overhead required.
[0049] In the game industry, to achieve realistic water motion while maintaining efficient computation, developers have adopted a method called Flow Maps. Flow Maps create dynamic fluid motion animations by precomputing 2D velocity field textures and applying them to water surface textures in UV space. This method allows game developers to create visually realistic water effects while significantly reducing the cost of real-time computation during gameplay. However, current Flow Map creation often relies on manual work by artists, which requires a lot of manpower and resources. Artists need to spend a lot of time and effort to manually draw and adjust Flow Maps to ensure that the water motion effect meets expectations. This hand-intensive workflow not only has low efficiency, but also is prone to human error, making it difficult to guarantee the quality and consistency of Flow Maps. In addition, the Flow Map-based method usually ignores the influence of underwater terrain and other factors, resulting in unrealistic simulation results. For example, when simulating water flow in rivers or oceans, changes in underwater terrain will significantly affect the direction and speed of water flow, and ignoring these factors will make the simulated fluid motion appear unnatural.
[0050] Currently, methods based on LBM-SWE have been proposed to calculate flow maps. LBM-SWE is a method to simulate large water bodies (including oceans or large lakes) under the shallow water assumption, which utilizes the lattice Boltzmann model (LBM) and shallow water equations (SWE) introduced above. LBM-SWE can achieve high computational speed and effectively handle underwater topography. However, when simulating turbulent flow conditions, LBM-SWE is too sensitive to instability problems, often leading to inaccurate flow maps. Although LBM-SWE has advantages in terms of computational speed and topography handling, it still does not perform well in accurately capturing turbulent flow phenomena.
[0051] Embodiments of the present disclosure improve the traditional LBM-SWE method to achieve more accurate simulation of turbulent and laminar flow. The improvements of embodiments of the present disclosure include using a mechanical model to adjust the calculation scheme of the traditional LBM-SWE, thereby improving the accuracy and reliability of the simulation results. By using embodiments of the present disclosure, more accurate flow maps can be generated in complex situations with lower computational effort.
[0052] To more clearly illustrate embodiments of the present disclosure, a brief introduction to the 2D shallow water equation (2D-SWE) and the LBM model will be given next in conjunction with Figure 2
[0053] Macroscopically, the tensor form of the 2D shallow water equation can be expressed using Equations (1) and (2).
[0054]
[0055] where x is the Cartesian coordinate, h is the fluid depth parameter, and u is the fluid velocity parameter. The fluid velocity parameter can be characterized by the average velocity component at the fluid depth. g is the acceleration of gravity, v is the kinematic viscosity, and F is the external force parameter term. The external force parameter term is defined as the sum of the hydrostatic pressure and the bed shear stress. Specifically, F can be calculated as follows.
[0056]
[0057] where z is the topography height, τ b is the bed shear stress. Under the BGK (Bhatnagar-Gross-Krook) approximation, the 2D shallow water equation can be rewritten in the form of the LBM equation shown in Equation (4).
[0058]
[0059] where F i (x, t) is the external force parameter term, and f i (x, t) is the distribution function of a virtual fluid particle at position x along velocity direction i at the current time step t. is the local equilibrium distribution function of a virtual fluid particle at position x along velocity direction i at the current time step t. Specifically, as shown in Figure 2 , the motion of a virtual lattice has 9 velocity directions in total, and velocity direction i represents one of the velocity directions. Thus, the velocity vector c i of a virtual lattice can be defined as formula (5).
[0060]
[0061] The relaxation factor τ is determined based on the fluid kinematic viscosity coefficient v, τ = 3v + 0.5, and the time step Δt can be set as 1 according to the habit of LBM, because LBM is carried out in dimensionless space.
[0062] Traditionally, the LBM-based fluid simulation process can be divided into two stages, namely, a streaming stage and a collision stage. In the streaming stage, virtual fluid particles flow from the inside of a virtual lattice to adjacent virtual lattices. At time t, the motion of a virtual fluid particle inside a virtual lattice is subject to the distribution function f i (x, t) in formula (6). At time t + Δt, the motion of a virtual fluid particle at position x is subject to the distribution function f
[0063]
[0064] Based on formula (6), the fluid depth parameter h and the fluid velocity parameter u* at time t + Δt can be updated according to formula (7) and formula (8) as follows.
[0065]
[0066] In the collision stage, the distribution function of a virtual fluid particle is further adjusted in each virtual lattice to simulate the collision and energy transfer between virtual fluid particles. This process is characterized by formula (9) as follows.
[0067]
[0068] In formula (9), the local equilibrium distribution function of a virtual fluid particle at the current time step t along velocity direction i is defined according to formula (10).
[0069]
[0070] In formula (9), the external force parameter term Fi (x, t) can be calculated by considering the external force F = (F x ,F y ) and according to equation (11).
[0071]
[0072] The calculation of the external force F = [F x ,F y ] in equation (11) can refer to equation (3).
[0073] To further improve the accuracy of LBM, a central-moment based MRT model can be used to improve the accuracy of LBM. In the MRT model, the distribution function f = [f0,...,f8] is converted into the central moment m = Mf through a linear transformation. Where M is known and has a closed form, which is a function of the macroscopic fluid velocity u. Specifically, the matrix M = [m0,...,m8] T is a 9x9 matrix space projection matrix. Each row is defined according to equations (12) to (20) as follows.
[0074] m0= [1, 1, 1, 1, 1, 1, 1, 1] (12)
[0075]
[0076] where, is the velocity of the virtual lattice corresponding to the coordinates (x, y) when the virtual fluid moves at the local fluid velocity u*, where and m0is the zeroth moment (equal to the density), m1and m2are vector components representing the first moment, m3,...,m5are components of the symmetric second moment, and the others are components of higher moments.
[0077] Therefore, equation (4) can be rewritten in the form of equation (21).
[0078]
[0079] where R = diag{r0,...,r1}, which is a diagonal matrix. The relaxation rate The other relaxation rates (for example, when i is equal to other values) are all equal to 1.
[0080] As mentioned above, when simulating turbulent flow conditions, LBM-SWE is too sensitive to instability problems, often leading to the inability to generate accurate flow maps, and thus LBM-SWE still has poor effects in accurately capturing turbulent phenomena.
[0081] For example, at a turbulent flow, the above solution of LBM-SWE requires not only a large amount of computation, but also low accuracy. Embodiments of the present disclosure improve the traditional LBM-SWE method to achieve more accurate simulation of turbulent flow and laminar flow. The improvement of embodiments of the present disclosure includes adjusting the calculation scheme of the traditional LBM-SWE using a mechanical model to improve the accuracy and reliability of the simulation results. By using the embodiments of the present disclosure, a more accurate flow map can be generated in a complex situation with less computation.
[0082] The following description is made in conjunction with Figures 3 to 8 A more detailed description of embodiments according to the present disclosure is provided.
[0083] Figure 3 A flowchart of a method 30 of rendering a virtual fluid according to embodiments of the present disclosure is shown.
[0084] Optionally, the LBM method is a mesoscopic method between macroscopic and microscopic. It describes the movement of a distribution function on a virtual lattice node along a discrete direction of mesoscopic velocity, as shown in Figure 2 After the distribution function is passed to the adjacent virtual lattice node in the streaming stage, it can be relaxed to an equilibrium state through a nonlinear collision operation in the collision stage. Then, based on the updated distribution function, the macroscopic physical quantities of the fluid (such as fluid depth parameters and fluid velocity parameters) can be obtained.
[0085] Optionally, the method 30 includes operations S301 to S305. Of course, the method 30 can also include more or fewer operations, which are not limited by the present disclosure.
[0086] In operation S301, a second distribution function corresponding to the virtual fluid particle is determined based on a first distribution function corresponding to the virtual fluid particle, wherein the first distribution function corresponds to a current time step, and the second distribution function corresponds to a next time step. Of course, the present disclosure is not limited thereto.
[0087] Optionally, operation S301 corresponds to the operation of the streaming stage in the LBM-based fluid simulation process. In the streaming stage, the virtual fluid particles move in translation with a specific velocity distribution function on a discrete Euler grid without collision in the predefined velocity direction. The streaming stage simulates the process of the virtual fluid particles flowing and propagating in a collision-free manner between at least one virtual lattice within two time steps.
[0088] Optionally, the first distribution function indicates the probability distribution of the velocity of the virtual fluid particle at the first position flowing along multiple velocity directions at the current time step. The second distribution function indicates the probability distribution of the velocity of the virtual fluid particle at the second position flowing along multiple velocity directions at the current time step. Wherein, during the time interval from the current time step to the next time step, the virtual fluid particle flows from the first position to the second position.
[0089] For example, suppose the current time step corresponds to time t, and the next time step corresponds to time t+Δt. A virtual fluid particle's first position at time t is x, and its second position at time t+Δt is x+Δtc. i Combining Figure 2 In the flow phase, the first distribution function can be denoted as f. i (x,t), the second distribution function can be written as According to formula (6), c i The definition of c is referenced in formula (5). Specifically, c i Refers to reference Figure 2 A set of finite discrete velocity vectors is defined, which describes the direction of motion of the virtual fluid particle on the discrete Euler lattice. Therefore, the first distribution function f i (x,t) represents the virtual fluid particle at the first position x moving along c at time t. i The velocity distribution of directional motion. Similarly, the second distribution function. This indicates the second position x+Δtc i The virtual fluid particle at point c moves along time t+Δt. i The velocity distribution of directional motion.
[0090] In operation S302, based on the first distribution function and the second distribution function, the fluid depth parameter of the virtual fluid and the fluid velocity parameter of the virtual fluid in the next time step are estimated.
[0091] Optionally, the virtual fluid is a shallow water fluid, which can be described using shallow water equations. Shallow water equations are a set of nonlinear partial differential equations used to describe shallow water flow, typically employed to simulate wave variations in rivers, lakes, and oceans. Shallow water equations assume the water depth is much smaller than the horizontal scale, thus simplifying the fluid flow to two dimensions.
[0092] Optionally, the fluid depth parameter and the fluid velocity parameter are macroscopic parameters of the virtual fluid. Specifically, the fluid depth parameter can be denoted by h to indicate the fluid depth (e.g., water depth). The fluid velocity parameter of the virtual fluid at the next time step can be denoted by u* to indicate the velocity vector of the fluid in the horizontal direction. With reference to the description in Figure 2 , the fluid depth parameter h and the fluid velocity parameter u* can be solved according to equation (7) and equation (8). The present disclosure does not limit this.
[0093] In operation S303, the fluid velocity parameter corresponding to the virtual lattice is adjusted based on the external force parameter term corresponding to the virtual fluid.
[0094] Optionally, the external force parameter term corresponding to the virtual fluid is used to introduce external acting forces (e.g., the sum of hydrostatic pressure and bed shear stress). The external force parameter term will affect the motion and state of the virtual fluid. The introduction of the virtual external force term requires modification of the basic equation of LBM so that it can correctly simulate the effect of external forces.
[0095] The conventional modification method is in the form of equation (4) and equation (21) as described with reference to Figure 2 . However, such a modification method involves direct modification of the first distribution function. This modification method will cause the LBM-SWE to be too sensitive to instability problems when simulating turbulent flow conditions, often resulting in the generation of inaccurate flow maps. In contrast, according to the embodiments of the present disclosure, the fluid velocity parameter corresponding to the virtual lattice is adjusted using the external force parameter term corresponding to the virtual fluid, thereby significantly reducing the sensitivity of the LBM-SWE to instability problems.
[0096] Optionally, in operation S303, the following operations can be performed: calculating the product of the fluid velocity parameter corresponding to the virtual fluid and the fluid velocity parameter of the virtual fluid at the current time step; and linearly adding one-half of the external force parameter term corresponding to the virtual fluid to the product to determine the product of the fluid velocity parameter corresponding to the virtual fluid and the fluid velocity parameter of the virtual fluid at the next time step. The principle of this operation is briefly described as follows.
[0097] The external force parameter term F is divided into two parts according to the trapezoidal rule or the Crank-Nicholson discretization method. The trapezoidal rule and the Crank-Nicholson discretization method are both finite difference methods for numerically solving differential equations. They convert differential equations into algebraic equations that can be solved numerically by discretizing the derivative with respect to time.
[0098] After the flow phase, in operation S303, the fluid velocity parameter h corresponding to the virtual fluid and the fluid velocity parameter u of the virtual fluid at the current time step can be calculated first. t The product of hu t Then, take half of the external force parameter terms. The product is linearly added to determine the fluid velocity parameter h corresponding to the virtual fluid and the fluid velocity parameter u of the virtual fluid in the next time step. * The product of hu * This process can be represented by formula (22).
[0099]
[0100] Equation (22) provides a higher-order forced mechanical model. After modifying Equation (22), Equation (21) can be rewritten into the form of Equation (23).
[0101]
[0102] Where K represents the external force parameter projected onto the central moment space. K can be expressed by formula (24).
[0103]
[0104] The revised fluid velocity parameters are more accurate than those in formula (21), better reflecting the influence of external forces on the fluid, and thus more accurately simulating turbulence. Specifically, by taking the first moment of formula (23) as formula (25), the accuracy of the effect of the external force parameters on the virtual fluid according to the embodiments of this disclosure can be verified.
[0105]
[0106] For R, a higher-order relaxation time v is also introduced according to embodiments of this disclosure. i=6,7 =0.1 and v i=8 =0.1, corresponding to the relaxation rate To reduce dissipation error.
[0107] Furthermore, according to embodiments of this disclosure, the first term in formula (3) can also be... Replace with formula (26) Solution format.
[0108]
[0109] Formula (26) is a rotationally symmetric gradient approximation that is more accurate and stable than the traditional central difference method.
[0110] Then, in operation S304, the first distribution function is updated based on the adjusted fluid velocity parameter of the virtual fluid.
[0111] Optionally, operation S304 comprises: determining a third distribution function, the third distribution function indicating a distribution of virtual fluid particles flowing at the first location along the plurality of velocity directions at the current time step, assuming that the virtual fluid is in a state of local equilibrium; and updating the first distribution function based on the third distribution function and the adjusted fluid velocity parameter of the virtual fluid.
[0112] In particular, operation S304 corresponds to a collision phase. The collision phase describes the interaction between virtual fluid particles and how the particle distribution function tends to an equilibrium state. In particular, the collision process refers to, at each time step, the first distribution function f i (x, t) is based on the local equilibrium distribution function is adjusted to simulate the collision effect between particles. This process makes the virtual fluid change towards a state of local equilibrium. The local equilibrium distribution function may be defined according to equation (10).
[0113] Optionally, operation S304 corresponds to a process as shown in equation (9). In particular, in operation S304, the following operations can be performed: adjusting the second distribution function based on the adjusted fluid velocity parameter of the virtual fluid at the next time step; and adjusting the first distribution function based on the third distribution function, the adjusted second distribution function and the external force parameter term.
[0114] Since the fluid velocity parameter u * of the virtual fluid at the next time step has been updated according to the external force parameter term F / 2 in operation S303, the second distribution function is also correspondingly updated. Thus, equation (9) of the first distribution function f (x, t) can obtain a more accurate first distribution function f i (x, t).
[0115] In operation S305, the virtual fluid is rendered based on the updated first distribution function.
[0116] Optionally, the process of rendering the virtual fluid involves extracting macroscopic quantities from the first distribution function again, and then visualizing these macroscopic quantities. The macroscopic quantities include the fluid velocity parameter, the fluid density parameter and the fluid depth parameter mentioned above, etc. The rendering method optionally comprises: 1) drawing a density map based on the fluid density parameter to display the density distribution of the fluid; 2) drawing a vector field or a streamline map based on the fluid velocity parameter to display the velocity of the fluid; etc.
[0117] Optionally, rendering the virtual fluid involves drawing a flow graph based on the aforementioned macroscopic quantities. In operation S305, the velocity vector c of each virtual lattice can be determined based on the updated first distribution function. i Then, based on the velocity vector c of each virtual lattice i Draw a flow diagram. Of course, this disclosure is not limited to this.
[0118] Therefore, according to the embodiments of this disclosure, by adjusting the fluid velocity parameters corresponding to the virtual lattice using the external force parameter terms corresponding to the virtual fluid after the flow stage, the influence of external forces on the fluid can be better reflected, thereby simulating turbulence more accurately. Specifically, according to the embodiments of this disclosure, a higher-order forced mechanical model is used in the central moment space using formulas (22) to (24), and a second-order weighted estimation method is used to calculate the external force parameter terms, thereby making the influence of external forces on the virtual fluid more accurate.
[0119] Next, the detailed processing of potential collisions between virtual fluids and virtual boundaries according to embodiments of this disclosure will be described. Specifically, to more accurately simulate the collision process between virtual fluids and boundaries, the macroscopic quantities of the virtual fluid can be further adjusted for different boundary conditions. Boundary conditions reflect different types of physical boundaries, such as solid walls, inlet and outlet flows, periodic boundaries, etc.
[0120] Figure 4 A schematic diagram of boundary processing according to an embodiment of the present disclosure is shown. Figure 5 A rendered image is shown according to an embodiment of the present disclosure.
[0121] Specifically, some virtual fluid particles in a virtual fluid may collide with virtual solid walls. For example, in Figure 5 In the simulation, a turbulent virtual river (the area marked with a red edge) collides with a virtual cliff (the area marked with a white edge). Method 30 further adjusts the first distribution function based on this possible collision scenario to simulate the collision of virtual fluid particles. Specifically, operation S305 further includes: adjusting the updated first distribution function based on the collision between the virtual fluid particles and the virtual solid boundary; and rendering the virtual fluid based on the adjusted first distribution function.
[0122] In such a scenario, assuming according to Figure 4As shown in the left figure of FIG. 1, the virtual fluid particles bounce back to the original direction when colliding with the virtual solid wall, thereby simulating the no-slip condition. Thus, the updated first distribution function can be adjusted based on the following operations: determining a fourth distribution function based on the collision of the virtual fluid particles with the virtual solid boundary, the fourth distribution function indicating a distribution of the virtual fluid particles flowing at the first location along the plurality of velocity directions at the current time step in a state where the virtual fluid particles collide with the virtual solid boundary; and adjusting the updated first distribution function based on the fourth distribution function. For example, the case where the virtual fluid particles bounce back after colliding with the solid boundary can be handled in formula (27).
[0123] f i (x,t+1)=f i′ (x,t) (27)
[0124] Formula (27) means that the virtual fluid particle located at position x and flowing along the i' direction collides with the virtual solid boundary and then bounces back along the i direction. This process causes the first distribution function corresponding to the virtual fluid particle to be transient from f i′ (x,t) to the fourth distribution function f i (x,t+1).
[0125] However, if formula (27) is used directly, it will lead to unstable results when the virtual fluid collides with complex terrain geometry, because formula (27) will bring high-frequency ghost modes into the low-order velocity moments, thereby destroying the simulation.
[0126] Therefore, according to an embodiment of the present disclosure, the incoming distribution function of the virtual fluid particles from the boundary to the virtual fluid particles along the cross-link l Figure 4 of the blue dashed line in the left figure of FIG. 1) is partially approximated by the equilibrium distribution function of the points where the link and the virtual solid boundary intersect. Specifically, the process includes: determining a fifth distribution function based on the collision of the virtual fluid particles with the virtual solid boundary, the fifth distribution function indicating a distribution of the virtual fluid particles flowing at the first location along the plurality of velocity directions at the current time step in a state where the virtual fluid is assumed to be in local equilibrium at the moment when the virtual fluid particles collide with the virtual solid boundary; and adjusting the updated first distribution function based on the fourth distribution function and the fifth distribution function.
[0127] Specifically, in a shallow water fluid simulation environment with static obstacles, according to an embodiment of the present disclosure, a zero velocity boundary condition (see the right figure of FIG. 1) is imposed on the virtual solid boundary to evaluate the fifth distribution function Figure 4 values, and a fourth distribution function f i′ (x) and a fifth distribution function are weighted and summed. This process can be formulated as shown in equation (28).
[0128]
[0129] Optionally, a is a constant, which can be set to 0.1. By adding the fifth distribution function According to embodiments of the present disclosure, non-physical oscillations in the fourth distribution function f i′ (x, t) can be filtered out after the boundary treatment, which shows better stability in the simulation of turbulent flow.
[0130] According to embodiments of the present disclosure, for the numerical simulation of shallow water wave equations, the Gurevich boundary condition is adopted to treat the macroscopic variables (e.g., the fluid depth parameter and the fluid velocity parameter). This boundary condition directly gives the values of the physical quantities at the boundary. The reason for choosing this method is based on a key assumption in the LBM method: the macroscopic distribution function f of the virtual fluid only slightly deviates from the local equilibrium distribution function f eq . On the basis of this assumption, f eq (x, t) can be approximated by f eq , so as to avoid the large amount of calculation required for directly solving f.
[0131] The way of treating the boundary condition according to embodiments of the present disclosure brings many benefits. First, by only giving the macroscopic quantities - the fluid depth parameter and the fluid velocity parameter at the boundary, the corresponding distribution function f can be determined through f eq , so as to smoothly apply the boundary condition without separately solving f, greatly simplifying the calculation process. Second, this method fully complies with the basic assumption of the relationship between f and f eq in the LBM method, that is, f only slightly deviates from f eq , ensuring the accuracy and reliability of the calculation results. In addition, the complex calculation of solving f is avoided, improving the overall calculation efficiency of the numerical simulation, which is of great significance especially when simulating large-scale complex virtual fluids.
[0132] As Figure 6As shown, the device for rendering virtual fluid described above can be an electronic device 2000 (may also be referred to as: device for rendering virtual fluid 2000). The electronic device 2000 can include one or more processors 2010, and one or more memories 2020. Among them, the memory 2020 stores computer readable code, which when executed by the one or more processors 2010, can perform various methods as described above.
[0133] The processor in the embodiments of the present disclosure can be an integrated circuit chip with a processing capability of signals. The processor can be a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can be any conventional processor or the like, which can be X86 architecture or ARM architecture.
[0134] Generally, various example embodiments of the present disclosure can be implemented in hardware or special-purpose circuitry, software, firmware, logic, or any combination thereof. Certain aspects can be implemented in hardware, while other aspects can be implemented in firmware or software which can be executed by a controller, microprocessor or other computing device. When aspects of the embodiments of the present disclosure are illustrated or described as a block diagram, flow chart or using some other pictorial representation, it will be understood that the blocks, devices, systems, techniques or methods described herein can be implemented in hardware, software, firmware, special-purpose circuitry or logic, general hardware or controller or other computing device, or some combination thereof, as non-limiting examples.
[0135] For example, the method or device according to the embodiments of the present disclosure can also be implemented by means of Figure 7 The architecture of the computing device 3000 as shown can be implemented. As Figure 7 As shown, the computing device 3000 can include a bus 3010, one or more CPUs 3020, a read-only memory (ROM) 3030, a random access memory (RAM) 3040, a communication port connected to a network 3050, an input / output component 3060, a hard disk 3070, etc. The storage device in the computing device 3000, such as the ROM 3030 or the hard disk 3070, can store various data or files used for processing and / or communication of the method for determining the driving risk of the vehicle provided by the present disclosure and the program instructions executed by the CPU. The computing device 3000 can also include a user interface 3080. Of course, Figure 7 The architecture shown is only exemplary, and when implementing different devices, according to actual needs, some Figure 7One or more components of the computing device are shown.
[0136] According to yet another aspect of the present disclosure, a computer-readable storage medium is also provided. Figure 8 A schematic diagram 4000 of a storage medium according to the present disclosure is shown.
[0137] As Figure 8 shown, the computer storage medium 4020 has stored thereon computer readable instructions 4010. The computer readable instructions 4010, when executed by a processor, can perform various methods according to embodiments of the present disclosure as described with reference to the above figures. The computer readable storage medium in embodiments of the present disclosure can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memory. Non-volatile memory can be read only memory (ROM), programmable read only memory (PROM), erasable programmable read only memory (EPROM), electrically erasable programmable read only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM) used as external cache. By way of example, and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double-data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), Synchlink dynamic random access memory (SLDRAM), and direct
[0138] Embodiments of the present disclosure also provide a computer program product or computer program, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs various methods according to embodiments of the present disclosure.
[0139] It should be noted that the flowchart and block diagrams in the drawings are representative of the possible architectures, functions, and operations for systems, methods, and computer program products in accordance with various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or combinations of hardware and software.
[0140] In general, the various example embodiments of the present disclosure can be implemented in hardware or special-purpose circuits, software, firmware, logic, or any combination thereof. Some aspects can be implemented in hardware, while other aspects can be implemented in firmware or software which can be executed by a controller, microprocessor or other computing device, Although the various aspects of embodiments of the present disclosure can be illustrated and described as block diagrams, flow charts, or using some other pictorial representation, it is well understood that these blocks, apparatus, systems, techniques or methods described herein can be implemented in, as non-limiting examples, hardware, software, firmware, special purpose circuits or logic, general purpose hardware or controller or other computing devices, or some combination thereof.
[0141] The example embodiments of the present disclosure described in detail above are merely illustrative, and not restrictive. It should be understood by those skilled in the art that various modifications and combinations can be made to these embodiments or features thereof without departing from the principles and spirit of the present disclosure, and such modifications should fall within the scope of the present disclosure.
Claims
1. A method for rendering virtual fluids, wherein, The virtual fluid includes at least one virtual fluid particle, and the method includes: Based on the first distribution function corresponding to the virtual fluid particle, a second distribution function corresponding to the virtual fluid particle is determined, wherein the first distribution function corresponds to the current time step, and the second distribution function corresponds to the next time step; Based on the first distribution function and the second distribution function, the fluid depth parameter of the virtual fluid and the fluid velocity parameter of the virtual fluid in the next time step are estimated. Based on the external force parameters corresponding to the virtual fluid, adjust the fluid velocity parameters of the virtual fluid in the current time step and the fluid velocity parameters of the virtual fluid in the next time step. Based on the fluid velocity parameters of the virtual fluid at the current time step and the fluid velocity parameters of the virtual fluid at the next time step, update the first distribution function; and The virtual fluid is rendered based on the updated first distribution function.
2. The method as described in claim 1, wherein, The first distribution function indicates the distribution of virtual fluid particles flowing along multiple velocity directions at the first position at the current time step. The second distribution function indicates the distribution of virtual fluid particles flowing along multiple velocity directions at the second position in the next time step. During the time interval from the previous time step to the current time step, it is assumed that the virtual fluid particle flows from the first position to the second position.
3. The method as described in claim 1, wherein, The adjustment of the fluid velocity parameter corresponding to the virtual fluid based on the external force parameter item corresponding to the virtual fluid includes: Calculate the product of the fluid velocity parameter corresponding to the virtual fluid and the fluid velocity parameter of the virtual fluid at the current time step; and Half of the external force parameter corresponding to the virtual fluid is linearly added to the product to determine the product of the fluid velocity parameter corresponding to the virtual fluid and the fluid velocity parameter of the virtual fluid in the next time step.
4. The method of claim 1, wherein, The step of updating the first distribution function based on the adjusted fluid velocity parameters corresponding to the virtual fluid includes: A third distribution function is determined, indicating the distribution of virtual fluid particles flowing along multiple velocity directions at the first position at the current time step, assuming the virtual fluid is in a state of local equilibrium; and The first distribution function is updated based on the third distribution function and the fluid velocity parameters corresponding to the adjusted virtual fluid.
5. The method of claim 4, wherein, The step of updating the first distribution function based on the adjusted fluid velocity parameters corresponding to the virtual fluid includes: Based on the adjusted fluid velocity parameters of the virtual fluid in the next time step, the second distribution function is adjusted; and The first distribution function is adjusted based on the third distribution function, the adjusted second distribution function, and the external force parameter.
6. The method of claim 1, wherein, Rendering the virtual fluid based on the updated first distribution function includes: The updated first distribution function is adjusted based on the collision between the virtual fluid particles and the virtual solid boundary; and The virtual fluid is rendered based on the adjusted first distribution function.
7. The method of claim 6, wherein, Adjusting the updated first distribution function based on the collision between the virtual fluid particles and the virtual solid boundary includes: Based on the collision between the virtual fluid particles and the virtual solid boundary, a fourth distribution function is determined. This fourth distribution function indicates, at the current time step, the distribution of virtual fluid particles flowing along multiple velocity directions at the first position, under the condition that the virtual fluid particles collide with the virtual solid boundary. Based on the fourth distribution function, the updated first distribution function is adjusted.
8. The method of claim 7, wherein, The adjustment of the updated first distribution function based on the fourth distribution function includes: Based on the collision between the virtual fluid particles and the virtual solid boundary, a fifth distribution function is determined. The fifth distribution function indicates the distribution of virtual fluid particles flowing along multiple velocity directions at the first position at the instant the virtual fluid particles collide with the virtual solid boundary, at the current time step, assuming the virtual fluid is in a state of local equilibrium. The updated first distribution function is adjusted based on the fourth and fifth distribution functions.
9. An apparatus for rendering virtual fluids, comprising: One or more processors; as well as One or more memories storing a computer-executable program that, when executed by the processor and the display, performs the method of any one of claims 1-8.
10. A computer program product stored in a computer-readable storage medium and comprising computer instructions that, when executed by a processor, cause a computer device to perform the method of any one of claims 1-8.
11. A computer-readable storage medium having stored thereon computer-executable instructions, which, when executed by a processor, are used to implement the method of any one of claims 1-8.