A fluid simulation method and apparatus

By setting up perturbation packets and optimizing particle rendering methods in fluid simulation, the problems of realistic fluid effects and computational resource consumption were solved, resulting in more natural fluid display and more efficient resource utilization, thus improving the user experience.

CN122265480APending Publication Date: 2026-06-23HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-12-20
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing fluid simulation technologies are insufficient in terms of the realism of fluid effects and computational resource consumption, resulting in poor user experience and wasted computational resources.

Method used

By setting perturbation packets within the space where the fluid object resides, each perturbation packet contains fluid particles with the same initial velocity, the perturbation packets are used to generate a gravitational field effect on external particles, update the velocity of external particles, and utilize some particles for rendering processing. Combined with the random distribution and division of fluid particles, the fluid model data generation and rendering process is optimized.

Benefits of technology

It improves the naturalness and realism of fluid motion, reduces computational resource consumption, enhances user experience, and saves memory resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122265480A_ABST
    Figure CN122265480A_ABST
Patent Text Reader

Abstract

The application relates to a fluid simulation method and device, and relates to the technical field of computer graphics. The method comprises the following steps: setting one or more disturbance packages in a space where a fluid object is located, each of the one or more disturbance packages comprising at least one fluid particle, and the initial velocities of the fluid particles in the same disturbance package being the same; and updating the initial velocities of fluid particles outside the one or more disturbance packages according to the gravitational action of the fluid particles in the one or more disturbance packages on the fluid particles outside the one or more disturbance packages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer graphics technology, and in particular to a fluid simulation method and apparatus. Background Technology

[0002] With the development of computer graphics technology, more and more businesses are involved in rendering three-dimensional (3D) virtual scenes, such as 3D games and 3D animations. The requirements for real-time scene physics simulation in 3D virtual scenes are becoming increasingly demanding, and realistic physics simulation is particularly important for enhancing the realism and immersion of 3D virtual scenes. Among these, fluid simulation is a crucial component of 3D virtual scenes. Fluid simulation technology can be used to achieve 3D representation of fluids.

[0003] Currently, fluid simulation technology still needs improvement in terms of the realism of fluid effects and computational resource consumption. Summary of the Invention

[0004] Some embodiments of this application provide a fluid simulation method and apparatus to improve the realism of fluid effects, thereby enhancing the user experience.

[0005] Firstly, a fluid simulation method is provided, which can be applied to electronic devices. The method includes: setting one or more perturbation packets within the space containing the fluid object, each of the one or more perturbation packets including at least one fluid particle, the fluid particles within the same perturbation packet having the same initial velocity; updating the initial velocity of the fluid particles outside the one or more perturbation packets based on the gravitational effect of the fluid particles within the one or more perturbation packets on fluid particles outside the one or more perturbation packets.

[0006] In the above implementation, since perturbation packets are set in the space where the flowing object is located, the fluid particles in these perturbation packets generate a gravitational field on the fluid particles outside the perturbation packets. The fluid particles outside the perturbation packets will be affected by this gravitational field, causing changes in their initial properties (including initial velocity, etc.). This avoids the simplification and mechanization of fluid particle initialization, thereby improving the naturalness and realism of the fluid motion effect and enhancing the visual experience.

[0007] Other embodiments of this application provide a fluid simulation method and apparatus to reduce the computational resource overhead of fluid simulation.

[0008] Secondly, a fluid simulation method is provided, which can be applied to electronic devices. The method includes: acquiring initial attribute information of fluid particles within the space where a fluid object resides; generating fluid model data based on the initial attribute information of the fluid particles within the space, the fluid model data including motion state information of the fluid particles within the space; performing physical calculations on the fluid model data to obtain fluid model solution data; and generating rendering data of the fluid object based on the fluid model solution data of a portion of the fluid particles within the space.

[0009] In the above implementation, by using some fluid particles within the space where the fluid object is located for rendering, a small number of fluid particles can be used to simulate a large number of fluid particles to achieve a dynamic fluid display effect, reducing computational and storage overhead.

[0010] In one possible implementation, before generating the rendering data of the fluid object based on the fluid model solution data of a portion of the fluid particles in the space, the method further includes: dividing the fluid particles in the space into a first particle set and a second particle set according to a first ratio; generating the rendering data of the fluid object based on the fluid model solution data of a portion of the fluid particles in the space includes: generating the rendering data of the fluid object based on the fluid model solution data of the fluid particles in the first particle set.

[0011] Optionally, the value of this first ratio can be preset. By setting the value of the first ratio, it can be ensured that while reducing computational overhead, the number of fluid particles involved in rendering can meet the requirements of the fluid motion effect display.

[0012] In one possible implementation, the partial fluid particles are fluid particles randomly selected from all fluid particles in the space where the fluid object is located; or, the partial fluid particles are fluid particles selected from all fluid particles in the space where the fluid object is located according to a specified fluid particle identifier.

[0013] Optionally, the fluid particles corresponding to the specified fluid particle identifier are distributed randomly within the space where the fluid object is located. Based on the above implementation, since the fluid particles selected for rendering have a certain degree of random distribution within the space where the fluid object is located, the dynamic display effect of the fluid can be guaranteed.

[0014] In one possible implementation, after completing the rendering process based on the rendering data, the method further includes: randomly adding fluid particles in the space where the fluid object is located based on the number of fluid particles in the second particle set, wherein the fluid particles in the second fluid particle set are a part of the fluid particles in the space, and the fluid model solution data of the fluid particles in the second particle set is not used to generate the rendering data of the fluid object.

[0015] By employing the above implementation method, the total number of fluid particles in the fluid object can be kept constant or change only slightly. Thus, when generating each image frame using this method, the total number of fluid particles participating in initialization and physical calculations can be guaranteed to remain constant or change only slightly, thereby ensuring the display effect of the fluid object.

[0016] In one possible implementation, since the fluid particles participating in the rendering process are fluid particles with a specified identifier, it means that the fluid particles selected for the rendering process are fixed each time. Correspondingly, the fluid particles not selected for the rendering process are also fixed each time. Therefore, the content space used to store the relevant data of these unselected fluid particles is also fixed. Thus, this memory space can be left unreclaimed. In this way, when adding fluid particles, the relevant data of the newly added fluid particles can be stored in this memory space, thereby saving the overhead of memory resource allocation.

[0017] In one possible implementation, the fluid particles randomly added within the space where the fluid object is located include a first fluid particle, the initial velocity of which is determined based on the velocity of at least one fluid particle surrounding the first fluid particle.

[0018] The above implementation method allows the motion state of the added fluid particles to adapt to the motion state of the surrounding fluid particles, thereby ensuring the display effect of the fluid object.

[0019] In one possible implementation, the initial velocity of the first fluid particle is determined based on the average velocity of at least one fluid particle surrounding the first fluid particle; or, the initial velocity of the first fluid particle is obtained by interpolating the velocity of at least one fluid particle surrounding the first fluid particle; or, the initial velocity of the first fluid particle is obtained using finite element analysis based on the velocity of at least one fluid particle surrounding the first fluid particle.

[0020] In one possible implementation, obtaining the initial attribute information of fluid particles within the space where the fluid object is located includes: setting one or more perturbation packets within the space where the fluid object is located, each of the one or more perturbation packets including at least one fluid particle, and the initial velocities of the fluid particles within the same perturbation packet being the same; and updating the initial velocities of the fluid particles outside the one or more perturbation packets based on the gravitational effect of the fluid particles within the one or more perturbation packets on the fluid particles outside the one or more perturbation packets.

[0021] Based on the first and second aspects above, in one possible implementation, the one or more disturbance packets are randomly distributed within the space where the fluid object is located; or, the distribution of the one or more disturbance packets within the space where the fluid object is located matches the flow tendency of the fluid object.

[0022] In the above implementation method, since the perturbation packet can also be set according to the needs of the virtual scene, such as setting the density distribution of the perturbation packet according to the needs of the scene, the initial state of the fluid can be matched with the characteristics of the virtual scene, meeting the needs of complex scenes and improving the naturalness and realism of the fluid motion effect.

[0023] Based on the first and second aspects above, in one possible implementation, the space where the fluid object is located includes a first space and a second space, and the flow tendency of the fluid object is from the first space to the second space; the distribution of the one or more disturbance packets in the space where the fluid object is located matches the flow tendency of the fluid object, including: the number or density of disturbance packets in the first space is less than the number or density of disturbance packets in the second space.

[0024] Based on the first and second aspects described above, in one possible implementation, the number of fluid particles contained within the one or more perturbation packets is the same. This reduces the computational complexity when updating the initial velocities of fluid particles outside the perturbation packets.

[0025] Based on the first and second aspects above, in one possible implementation, each of the one or more perturbation packets is the same size.

[0026] Based on the first and second aspects above, in one possible implementation, before setting one or more disturbance packets in the space where the fluid object is located, the method further includes: dividing the space where the fluid object is located into at least two subspaces; the fluid particles in the disturbance packets located in the same subspace have the same initial velocity.

[0027] In the above - mentioned manner, on the one hand, the operation of setting the perturbation packet (or the fluid particles within the perturbation packet) can be simplified; on the other hand, since the fluid particles within the perturbation packets located in the same subspace have the same initial velocity, the computational complexity when updating the initial velocity of the fluid particles outside the perturbation packets subsequently can be reduced.

[0028] Based on the above - mentioned first and second aspects, in a possible implementation, the fluid particles outside the one or more perturbation packets include first fluid particles, and the updated initial velocity of the first fluid particles is related to the initial velocity of the one or more perturbation packets and the distance between the one or more perturbation packets and the first particles.

[0029] Based on the above - mentioned first and second aspects, in a possible implementation, there are K fluid particles outside the one or more perturbation packets, where K is an integer greater than 1. The first fluid particle is the k - th fluid particle among the K fluid particles, 1 < k << K, and the updated initial velocity of the k - th fluid particle satisfies the following formula:

[0030]

[0031] where, represents the updated initial velocity of the k - th fluid particle; v i represents the initial velocity of the i - th perturbation packet; impact ik is the gravitational influence factor of the i - th perturbation packet on the k - th fluid particle, and the gravitational influence factor is used to characterize the magnitude of the gravitational force of the i - th perturbation packet on the k - th fluid particle.

[0032] Based on the above - mentioned first and second aspects, in a possible implementation, the gravitational influence factor impact ik of the i - th perturbation packet on the k - th fluid particle satisfies the following formula:

[0033]

[0034] where, R ik is the distance between the i - th perturbation packet and the k - th fluid particle; ρ is the density of the one or more perturbation packets in the space where the fluid object is located; C is a constant.

[0035] In a third aspect, a device is provided, including units or modules for executing the method described in any item of the first aspect, or units or modules for executing the method described in any item of the second aspect.

[0036] Fourthly, an apparatus is provided, comprising: one or more processors configured to perform the method as described in any one of the first aspects, or to perform the method as described in any one of the second aspects.

[0037] Fifthly, a readable storage medium is provided, the readable storage medium storing a program or instructions that, when the program or instructions are executed on a device, cause the device to perform the method as described in any one of the first aspects, or to perform the method as described in any one of the second aspects.

[0038] In a sixth aspect, a chip or chip system is provided, including a processor for enabling a computer device to implement the method as described in any one of the first aspects, or to implement the method as described in any one of the second aspects.

[0039] In a seventh aspect, a program product is provided, the program product comprising a program; when the program is run on a computer, the computer performs the method as described in any one of the first aspects, or performs the method as described in any one of the second aspects. Attached Figure Description

[0040] Figure 1 This is a schematic diagram illustrating application scenarios of fluid simulation technology.

[0041] Figure 2 This is a schematic diagram of a general process for fluid simulation methods;

[0042] Figure 3 This is a schematic diagram of fluid particles in an embodiment of this application;

[0043] Figure 4 This is a schematic diagram illustrating the fluid simulation process completed by the CPU and GPU in cooperation in an embodiment of this application;

[0044] Figure 5 A schematic flowchart of a fluid simulation method provided in an embodiment of this application;

[0045] Figure 6 This is a schematic diagram illustrating the division of the space where the flowing object is located in an embodiment of this application;

[0046] Figure 7 This is a schematic diagram illustrating the setting of a disturbance packet in the space where a fluid object is located, according to an embodiment of this application.

[0047] Figure 8 A flowchart illustrating another fluid simulation method provided in this application embodiment;

[0048] Figure 9 A schematic diagram of the structure of an apparatus provided in an embodiment of this application;

[0049] Figure 10A schematic diagram of another device provided in an embodiment of this application;

[0050] Figure 11 This is a schematic diagram of another device provided in an embodiment of this application. Detailed Implementation

[0051] The following explanations of some terms used in the embodiments of this application are provided to facilitate understanding by those skilled in the art.

[0052] The embodiments of this application involve at least one, including one or more; where "multiple" means two or more. Furthermore, it should be understood that in the description of this specification, terms such as "first" and "second" are used only for descriptive purposes and should not be construed as indicating relative importance or order. For example, the first operation and the second operation do not represent their relative importance or order, but are merely for descriptive distinction. In the embodiments of this application, "and / or" merely describes an association relationship, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0053] In the description of the embodiments of this application, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation" and "connection" should be interpreted broadly. For example, "connection" can be a detachable connection or a non-detachable connection; it can be a direct connection or an indirect connection through an intermediate medium. The directional terms mentioned in the embodiments of this application, such as "upper," "lower," "left," "right," "inner," and "outer," are only for reference to the directions in the accompanying drawings. Therefore, the directional terms used are for better and clearer explanation and understanding of the embodiments of this application, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.

[0054] References to "one embodiment" or "some embodiments" as used in this specification mean that one or more embodiments of this specification include a particular feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0055] Fluid simulation, also known as fluid dynamics simulation, is a computer simulation technique that simulates the motion and deformation of fluids (such as gases, liquids, and solids) under the influence of fluid dynamics. It combines fluid mechanics, computer graphics, and computer simulation techniques to visualize the motion of fluids by simulating their flow, pressure, velocity, and other physical quantities.

[0056] Figure 1 The application scenario of the fluid simulation technology applicable to the embodiments of this application is illustrated, with 3D games as an example.

[0057] Figure 1 Scenario a is a single-player scenario. In a single-player scenario, device 110 can execute fluid simulation methods and display the simulated fluid motion effects. For example, device 110 runs a 3D game. Some scenes in this 3D game include fluid objects such as rivers, lakes, and seas. Device 110 can use fluid simulation methods to generate rendering data for these fluid objects and perform rendering operations based on this rendering data to obtain a dynamic display of the flowing objects in the scene. Device 110 then displays the generated image on its screen.

[0058] Fluid objects can be understood as models that resemble liquid flow within a virtual scene, such as rivers, lakes, seas, fountains, lava, wind, and rain. Virtual scenes can be game scenes, animation scenes, movie scenes, etc.

[0059] For example, in a game scene, there is a square with a fountain in the center. In the rendering of the game scene, the fountain is a fluid object. As another example, in a virtual animation scene, there is a river flowing from the top of a mountain to the bottom. When rendering the virtual animation, the river is a fluid object.

[0060] Device 110 can be a non-foldable screen phone, a foldable screen phone, a wearable device (such as a smartwatch, smart bracelet, etc.), a tablet computer, a laptop computer, a smart screen, an in-vehicle terminal, a computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a virtual reality (VR) device / augmented reality (AR) device, an artificial intelligence (AI) device, or any other device with computing and display functions. It can also be a server or other similar device; this application does not limit the scope. Among these, a smart screen is also called a large-screen device, such as an intuitive color TV or a rear-projection TV with a large screen.

[0061] Figure 1 Scenario b in the diagram is a multi-device scenario, which includes server 120. Server 120 can connect to one or more terminals via a network. The diagram illustrates this using multiple terminals (130a, 130b, 130c) as an example. A multiplayer 3D game runs on the terminals (130a, 130b, 130c). Some scenes in this 3D game include fluid objects such as rivers, lakes, and seas. Server 120 can generate rendering data for these fluid objects using fluid simulation methods, perform rendering operations based on this data, obtain a dynamic display of the flowing objects in the scene, and send this display to the terminals (130a, 130b, 130c). The terminals (130a, 130b, 130c) then display the generated image on their screens. In another possible implementation, after the server 120 generates the rendering data of the fluid object using a fluid simulation method, it sends the rendering data to the terminals (130a, 130b, 130c). The terminals (130a, 130b, 130c) perform rendering operations based on the rendering data to obtain the dynamic display screen of the flowing object in the scene and display the screen.

[0062] Server 120 can be a cloud server. Terminals (130a, 130b, 130c) can be non-foldable screen phones, foldable screen phones, wearable devices (such as smartwatches, smart bracelets, etc.), tablets, laptops, smart screens, in-vehicle terminals, computers, personal computers, super mobile personal computers, netbooks, personal digital assistants, VR / AR devices, AI devices, and other devices with display functions. Terminals (130a, 130b, 130c) can also have computing functions.

[0063] It should be understood that Figure 1 The application scenarios shown are merely some possible examples. This application does not limit the application scenarios of fluid simulation technology. For example, it can also be applied to the following scenarios: displaying dynamic wallpapers containing fluid objects on standalone devices such as mobile phones and tablets, or displaying 3D animations on smart screens. Furthermore, it can also be applied to some numerical calculation and simulation research platforms.

[0064] It should also be understood that fluid simulation methods can be applied to both non-interactive and interactive scenarios. Non-interactive scenarios refer to situations where the movement of fluids in the image is unaffected by user actions; for example, the surface of a lake in a live wallpaper will not change due to the user's gaze or finger press. Interactive scenarios, on the other hand, refer to situations where the movement of fluids in the image is affected by user actions; for example, the surface of a lake in a live wallpaper will change in response to the user's gaze or finger press, creating a dynamic effect such as ripples.

[0065] In summary, such as Figure 2 As shown, the general process of fluid simulation can include the following stages:

[0066] Phase 1: Initialize fluid particles and generate fluid model data based on the initialized fluid particles.

[0067] In fluid simulation, the first step is to initialize the fluid particles to obtain their initial properties. Optionally, the initial properties of the fluid particles may include their initial position, initial velocity, density, lifespan, particle identifier, and material properties.

[0068] Figure 3 An exemplary schematic diagram of fluid particles is shown. (e.g.) Figure 3 As shown, the circles located below the surface of the fluid object represent fluid particles. By calculating the properties and states of the fluid particles, and rendering them based on this information, the fluid object's visual effects can be achieved.

[0069] For example, methods for setting the initial velocity of fluid particles provided by related technologies may include the following:

[0070] Method 1: Set the initial velocity of the fluid particles according to the pre-set configuration information. This configuration information includes the value of the initial velocity of the fluid particles.

[0071] Method 2: Calculate the initial velocity of the fluid particle based on its initial position and a position-dependent function.

[0072] Method 3: Determine the initial velocity of fluid particles based on sensor detection data or touchscreen interaction. For example, when the device's sensors detect a tilt, the fluid object needs to be rendered to create a dynamic flow effect based on the tilt angle. In this case, the initial velocity of the fluid particles can be set based on the tilt direction and angle detected by the sensor. As another example, when a user looks at or clicks on the display area of ​​a fluid object, the fluid object needs to be rendered to create a dynamic ripple effect on the water surface. In this case, the initial velocity of the fluid particles can be set based on the point where the user's gaze falls on the display area of ​​the fluid object or the point of application of the click operation.

[0073] Fluid model data can be generated based on the initial attribute information of fluid particles. Fluid model data can reflect the state of each fluid particle; for example, it can include the motion state information of each fluid particle (e.g., position, velocity, etc.). Optionally, fluid model data can include: the number of fluid particles, the spatial information of the fluid particles (e.g., including the position and size of the fluid particles), the orientation of the fluid particles, the velocity of the fluid particles, and the lifespan of the fluid particles.

[0074] In one possible implementation, the step of generating fluid model data based on the initial attribute information of fluid particles may include: randomly generating the spatial distribution of fluid particles using a random seed based on the initial attribute information of fluid particles, and setting the life cycle of each fluid particle; creating and managing the physical attribute information of the fluid based on the initial attribute information of the fluid particles, such as the density, pressure, viscosity, tension, and other physical attribute information of the fluid particles; solving the motion trajectory of the fluid particles based on the physical attribute information of the fluid, such as the viscosity and pressure of the fluid particles, and obtaining the velocity and position of the fluid particles based on the Euler integral.

[0075] Optionally, the density, pressure, and viscous force of the fluid particles, as well as the pressure of the fluid object, can be solved based on the classical governing equations of fluid dynamics and the smoothed particle hydrodynamics (SPF) method. The embodiments in this application are not limited to these. SPF is a numerical method used to simulate and analyze physical phenomena, particularly in the fields of fluid dynamics and solid mechanics.

[0076] Optionally, the velocity and position of the fluid particles can be solved using Euler integrals. Furthermore, boundary conditions of three-dimensional objects can be handled to ensure that the fluid's behavior at the boundaries of containers or obstacles conforms to physical laws. This application is not limiting.

[0077] This stage can also perform a neighborhood search operation. For example, the neighborhood search operation can include: using a hash table data structure to find all fluid particles whose distance to this fluid particle is less than r. For example, this can be achieved by dividing the area into a grid.

[0078] The second stage involves performing physical calculations on the fluid model data to obtain the fluid model solution data.

[0079] Physics computation refers to the computational process of simulating physical phenomena. This includes the interaction between light and object surfaces, radiometry, ray distribution function (BxDF), and microsurface theory. Microsurface theory posits that an object's surface is composed of many smooth, tiny surfaces with different orientations. The normal distribution function (NDF) and geometric function (GGX) of these microsurfaces are used to estimate the reflection and refraction behavior of light on the surface.

[0080] Iterative physical calculations can be performed on fluid model data to generate fluid model solution data. This solution data can describe the morphology of fluid particles in a virtual scene, including, for example, the reflection and refraction of light on the surface of the fluid particles.

[0081] For example, when performing physical calculations on fluid model data, physical calculations can be performed based on the number of fluid particles, the spatial information of fluid particles, the direction of fluid particles, the velocity of fluid particles, the life cycle of fluid particles, etc.

[0082] Specifically, when performing physical calculations based on the spatial information of fluid particles, the world position information of the fluid particles in the physical scene can be updated according to the world coordinate information of the fluid object in the virtual scene. If the fluid object has already been loaded into the virtual scene, the fluid particles in the virtual scene can be updated.

[0083] When performing physical calculations based on the lifecycle of fluid particles, a corresponding lifecycle is set for each fluid particle. When the lifecycle is not 0, the fluid particle can be displayed in the virtual scene. When the lifecycle is 0, the fluid particle is recycled, and its position, velocity, and other information are set to their initial state.

[0084] The third stage involves generating rendering data based on the fluid model solution data and performing rendering operations based on the rendering data.

[0085] Rendering is the process of converting objects in a 3D scene into 2D images. This process involves multiple aspects, including light calculations, object material properties, and lighting effects.

[0086] In this embodiment, texture information (including depth and thickness textures) of fluid particles can be generated based on fluid model solution data. The depth texture is used to depict depth information, and the thickness texture is used to depict thickness information. During rendering, the texture information corresponding to the fluid particle is used at the corresponding position to achieve a fluid effect.

[0087] For example, rendering operations can be performed using a surface shader.

[0088] It should be understood that "initial velocity" and "velocity" in the embodiments of this application are vector parameters, that is, they include the value of the velocity (i.e., the magnitude of the velocity) and the direction.

[0089] The above Figure 2 The fluid simulation process shown can be completed on a single processor or by multiple processors working together.

[0090] One way to complete the above fluid simulation process using a single processor is to implement the fluid simulation process using a central processing unit (CPU).

[0091] One implementation of the fluid simulation process described above, where multiple processors work together, involves a first processor and a second processor cooperating to complete the simulation. Optionally, the first processor is a CPU, and the second processor is a graphics processing unit (GPU). Leveraging the powerful data processing capabilities of GPUs, this architecture improves the processing performance of the fluid simulation and ensures real-time performance requirements.

[0092] Figure 4 An exemplary diagram illustrates a fluid simulation process completed by the collaboration of a CPU and a GPU. For example... Figure 4 As shown, the CPU and GPU are located in the same device.

[0093] The above can be executed in the CPU. Figure 2 The first stage of the fluid simulation process is shown. Specifically, it involves initializing fluid particles to obtain their initial attribute information. Based on this initial attribute information, fluid model data is generated, including information such as the number of fluid particles, their spatial information (e.g., position and size), orientation, velocity, and lifespan. For example, this first stage can be executed using a physics engine within the CPU. The CPU then sends the processed fluid model data to the GPU.

[0094] The above can be executed in a GPU. Figure 2 The second stage of the fluid simulation process, as shown, involves performing physical calculations on the fluid model data to obtain fluid model solution data. The GPU then sends the fluid model solution data to the CPU.

[0095] Within the CPU, rendering data for fluid particles can be generated based on fluid model solution data, including, for example, texture information of the fluid particles. For instance, rendering data can be generated based on a rendering engine within the CPU. The CPU then sends the rendering data to the GPU.

[0096] On a GPU, rendering operations can be performed based on rendering data. For example, rendering operations can be performed based on the rendering pipeline in the GPU.

[0097] It should be understood that Figure 4 The architecture shown is merely one possible example, and this application does not impose any limitations. In the fluid simulation process, any operation that can improve processing performance by leveraging the computing power of the GPU, such as matrix-based operations, can have the CPU send data to the GPU, execute the operation on the GPU, and then the GPU sends the processed data back to the CPU so that the CPU can continue to execute subsequent processing.

[0098] Based on the above Figure 2 In the fluid simulation process shown, when initializing fluid particles, the initial velocity of all fluid particles is currently set to 0, or the initial velocity of fluid particles is set based on a position-related function. The setting method is too simple and mechanical, resulting in unrealistic fluid effects and a poor user experience.

[0099] Therefore, this application provides a fluid simulation method and related apparatus for implementing the method, in order to improve the realism of fluid effects and thus improve the user experience. The following is in conjunction with... Figure 5 The fluid simulation method provided in the embodiments of this application will be described.

[0100] See Figure 5 This is a schematic flowchart of a fluid simulation method provided in an embodiment of this application. The process can be... Figure 1 The fluid simulation method can be executed by device 110 in the illustrated architecture, or by server 120. Within device 110 or server 120, the fluid simulation method can be executed on the CPU, or by a combination of CPU and GPU.

[0101] Figure 5 The flowchart shown describes a method for setting the initial velocity of fluid particles. Figure 2 The first stage of the fluid simulation process is shown.

[0102] like Figure 5As shown, the fluid simulation process may include the following steps:

[0103] Step 501: Divide the space containing the fluid object into N subspaces. Where N is an integer greater than 1.

[0104] The space in which the fluid object resides is a three-dimensional space, and correspondingly, the resulting subspaces are also three-dimensional spaces.

[0105] In some scenarios, the space containing a fluid object can be divided into N subspaces of equal size. This approach is suitable when the space containing the fluid object is a relatively regular three-dimensional space, such as... Figure 6 As shown, the space containing the fluid object is a regular barrel-shaped space, so it can be divided into 8 subspaces of equal size as illustrated. In other scenarios, the resulting N subspaces can be of different sizes; this approach is suitable for situations where the space containing the fluid object is an irregularly shaped 3D space. This application does not limit the implementation method of subspace division.

[0106] Step 501 is an optional step.

[0107] Step 502: Set up M disturbance packets within the space where the fluid object is located. Each disturbance packet contains at least one fluid particle, and the fluid particles within the same disturbance packet have the same initial velocity. Wherein, M is an integer greater than or equal to 1.

[0108] Within the space containing the fluid object, one or more fluid particles are positioned outside the one or more disturbance packets. In this process, the number of fluid particles outside the disturbance packets is described as K, where K is an integer greater than 1. These K fluid particles have initial attribute information, including initial position and initial velocity. To distinguish them from the updated initial velocities of these K fluid particles, their current initial velocities are referred to as the first initial velocities.

[0109] The spatial distribution of the K fluid particles, as well as the setting of their initial positions and velocities, can be found in [reference needed]. Figure 2 The diagram illustrates the relevant content from the first stage of the fluid simulation process. In some possible scenarios, the initial velocities of K fluid particles within the space containing the fluid object are all the same, denoted as v0. For example, the initial velocities of all K fluid particles are 0, i.e., v0 = 0.

[0110] Typically, the total number of fluid particles contained in a fluid object can be preset. In one possible implementation, considering that other fluid particles will be placed in the space by setting perturbation packets within the space of the fluid object, the value of K can be less than the preset total number of fluid particles. For example, taking the preset total number of fluid particles as Q, and M perturbation packets need to be set in the space, each containing S fluid particles, the relationship between the number of fluid particles inside the perturbation packet and the number of fluid particles outside the perturbation packet can be: K = QM × S, or K is close to the value of (QM × S).

[0111] A perturbation packet can be viewed as a spatial region that encloses multiple fluid particles, and this spatial region may be spherical, for example. In other words, a perturbation packet does not have a physical form like a fluid particle; it can be considered a spatial region containing one or more fluid particles.

[0112] Optionally, each perturbation packet has the same size, that is, each perturbation packet has the same radius.

[0113] Optionally, each perturbation packet contains the same number of fluid particles, for example, each perturbation packet contains S fluid particles, where S is an integer greater than or equal to 1. For example, S = 10. Containing the same number of fluid particles in each perturbation packet can reduce the complexity of subsequent processing. This application does not limit the number of fluid particles contained in each perturbation packet.

[0114] Figure 7 An exemplary diagram illustrates a perturbation packet placed within the space containing the fluid object, as shown in an embodiment of this application. Figure 6 Taking the fluid object space shown as an example, as Figure 7 As shown, these perturbation packets (indicated by black dots in the figure) are randomly distributed within the space, and each perturbation packet contains 10 fluid particles. The fluid particles within perturbation packets in the same subspace have the same velocity; for example, the velocity of the fluid particles in the perturbation packet in the i-th subspace is represented by v. i The velocity here is a vector parameter, including both magnitude and direction. That is, fluid particles within the same perturbation packet in the same subspace have the same magnitude and direction of velocity.

[0115] The following sections will explain the perturbation packets in terms of their total number and size, distribution, and initial velocities of fluid particles within them.

[0116] (1) The total number and size of the disturbance packets

[0117] In one possible implementation, the total number and / or size of the perturbation packets can be preset. For example, for a fluid object in a virtual scene of an application, the total number and / or size parameters (e.g., radius) of the perturbation packets can be included in the configuration information corresponding to that virtual scene. When rendering the virtual scene containing the fluid object, the total number and / or size of the perturbation packets can be obtained from the configuration information corresponding to that virtual scene.

[0118] The total number of perturbation packets can be set according to the device's computing power. Computing power can be understood as the ability to process information or computational performance; it is the ability of the device's hardware and software to work together to execute a certain computational requirement. Computing power metrics can be expressed using processing speed, including million instructions per second (MIPS), floating-point operations per second (FLOPS), etc., representing performance in areas such as fixed-point, half-precision / single-precision / double-precision floating-point, and 8-bit integer operations commonly used in artificial intelligence (AI).

[0119] One way to adjust the total number of perturbation packets based on the device's computing power is as follows: for devices with high computing power, a larger number of perturbation packets can be set to improve the rendering effect of fluid objects; for devices with low computing power, a smaller number of perturbation packets can be set to reduce computational overhead. For a given fluid object space, the larger the number of perturbation packets, the smaller the radius of the perturbation packets.

[0120] The ratio of the number of perturbation packets to the total number of fluid particles, or the ratio between the number of fluid particles within a perturbation packet and the number of fluid particles outside the perturbation packet, can be set according to the needs of the fluid dynamics effect and the computing power of the device. For example, the ratio of the number of perturbation packets to the total number of fluid particles can be in the range of 1:1000 to 1:100.

[0121] (2) Distribution of disturbance packets

[0122] The distribution of a disturbance packet within the space containing the flowing object, or its distribution across N subspaces, can be described by the initial position of the disturbance packet. In other words, the initial position of the disturbance packet reflects its distribution. Based on the initial position of the disturbance packet, the initial positions of the fluid particles contained within it can be obtained.

[0123] In one possible implementation, for each perturbation packet, the fluid particles within the perturbation packet are randomly distributed within that perturbation packet.

[0124] In one possible implementation, for each subspace, the perturbation packets within that subspace are randomly distributed within that subspace.

[0125] In one possible implementation, perturbation packets can be randomly placed within the space containing the fluid object, allowing the packets to be randomly distributed within that space. For example, a custom random distribution or a three-dimensional Gaussian distribution algorithm can be used to achieve this random distribution; this application does not limit the algorithm used. Because the positions of the perturbation packets are random, their density distribution within the space containing the fluid object tends to be uniform; in other words, given that each subspace is roughly the same size, the number of perturbation packets contained within each subspace tends to be the same. This distribution method can be applied to situations where the fluid object has almost no flow tendency within its space, such as scenarios where the water level remains almost horizontal.

[0126] In another possible implementation, for scenarios where the fluid object has a tendency to flow within its space, perturbation packets can be randomly set within the space where the fluid object is located, according to the needs of the scenario. This makes the distribution of perturbation packets within the space where the fluid object is located match the scenario. In other words, the density distribution of perturbation packets within the space where the fluid object is located may not be uniform, or, in other words, when the size of each subspace is roughly the same, the number of perturbation packets contained in each subspace no longer tends to be the same.

[0127] For example, based on the flow tendency of a fluid object within a space, perturbation packets can be placed within that space, such that the distribution of the perturbation packets matches the flow tendency. Taking a space containing a first space and a second space as an example, where the fluid object flows from the first space to the second space, in this scenario, the number or density of perturbation packets in the first space is less than the number or density of perturbation packets in the second space. For instance, if the fluid object flows from left to right within the space, then the number of perturbation packets in the subspace increases from left to right, or the density of fluid particles gradually increases from left to right.

[0128] Optionally, the density distribution (or change in density distribution) of the disturbance packet within the space varies depending on the degree of the fluid object's flow tendency in the space (hereinafter referred to as the degree of inclination). For example, the greater the degree of inclination, the greater the change in density distribution. A pre-defined correspondence between the degree of inclination and the change in density distribution can be established, allowing the corresponding density distribution change to be obtained by querying the correspondence based on the degree of inclination, and then the initial position of the disturbance packet can be set based on this density distribution change.

[0129] (3) Initial velocity of fluid particles within the perturbation packet

[0130] In this embodiment, the fluid particles within the same disturbance packet have the same initial velocity. The initial velocity of the fluid particles within the disturbance packet can be set according to the needs of the fluid dynamics effect. Generally, the initial velocity of the disturbance packet can be set to 5 to 20 times the initial velocity of the fluid particles outside the disturbance packet.

[0131] The “initial velocity” or “velocity” here can be understood as vector velocity, which includes both the velocity value and the velocity direction.

[0132] In one possible implementation, to simplify operations and reduce computational overhead, fluid particles within all perturbation packets in the same subspace have the same initial velocity. That is, for each perturbation packet within the same subspace, the initial velocities of the fluid particles within these perturbation packets are identical. In other words, a corresponding initial velocity can be set for each subspace, and the initial velocity of the fluid particles in all perturbation packets within a subspace is equal to the initial velocity corresponding to that subspace.

[0133] In one possible implementation, the initial velocity corresponding to each subspace can be set according to actual needs, that is, the initial velocity of the fluid particles within the perturbation packet of each subspace can be set. Different subspaces may correspond to different initial velocities. For example, the space where the fluid object is located includes a first spatial region and a second spatial region, and each of the first and second spatial regions contains multiple subspaces. Among them, the fluid movement in the first spatial region is relatively gentle, so the initial velocity corresponding to the subspaces in the first spatial region is v1; the fluid movement in the second spatial region is relatively turbulent, so the initial velocity corresponding to the subspaces in the second spatial region is v2, where v2 is greater than v1.

[0134] In one possible implementation, to further simplify the calculations and reduce computational overhead, all subspaces have the same initial velocity. In other words, all fluid particles within the perturbation packet have the same initial velocity.

[0135] Step 503: Update the initial velocity of the fluid particles outside the perturbation packet based on the gravitational effect of the fluid particles inside the perturbation packet on the fluid particles outside the perturbation packet. The updated initial velocity can be called the second initial velocity.

[0136] Each perturbation packet can be considered a planet, exerting gravity on surrounding objects. For each fluid particle outside the perturbation packet, the gravity of all perturbation packets forms a gravitational field on that fluid particle, causing its initial velocity to change under the influence of this gravitational field. In the embodiments of this application, based on the principle of gravitational field, the velocity of the fluid particle outside the perturbation packet after being affected by the gravitational field can be calculated.

[0137] Based on the principle of gravitational fields, if the distance between two objects is R, and their masses are M1 and M2 respectively, then the gravitational field F between these two objects satisfies the following formula 1:

[0138]

[0139] Where G represents the gravitational constant, its value is approximately 6.67 * 10^6. -11 N·m 2 / kg 2 .

[0140] The second initial velocity of the fluid particles outside the perturbation packet can be calculated based on the gravitational force exerted on the fluid particles by all perturbation packets and the initial velocity of the fluid particles inside the perturbation packets.

[0141] Taking fluid particle k (i.e., the kth fluid particle, 1≤k≤K) outside the perturbation packet as an example, its second initial velocity after being subjected to the gravitational fields of all perturbation packets. The following formula 2 is satisfied:

[0142]

[0143] Among them, impact ik Let v be the gravitational influence factor of perturbation packet i (i.e., the i-th perturbation packet, 1≤i≤M) on fluid particle k. This gravitational influence factor is used to characterize the magnitude of the gravitational force exerted by perturbation packet i on fluid particle k; i Let be the initial velocity of the fluid particles in perturbation packet i.

[0144] Among them, impact ik It can be calculated based on the distance between the perturbation packet i and the fluid particle k, as well as the initial velocity of the fluid particle in the perturbation packet i.

[0145] Taking the case where the number of fluid particles in each perturbation packet is the same, one possible implementation is impact i The following formula 3 is satisfied:

[0146]

[0147] Among them, R ik v is the distance between the center of the i-th perturbation packet and the k-th fluid particle; i ρ is the initial velocity of the fluid particles in the i-th perturbation packet; ρ is the density of the perturbation packet in the space where the fluid object is located; C is a constant, and the value of C can be magnified or reduced according to the specific number of decimal places. Since C is in both the numerator and denominator, it can be canceled out, so its value can be used to prevent the disappearance of decimals or infinite magnification.

[0148] It should be understood that if different perturbation packets contain different numbers of fluid particles, it is equivalent to different masses of different perturbation packets. This can be corrected by introducing the number of fluid particles contained in the perturbation packet into Equation 3, that is, by introducing the influence of the mass of the perturbation packet on the magnitude of the gravitational influence factor.

[0149] The method for setting other initial property information of fluid particles can refer to relevant technologies, and this application does not limit it.

[0150] The above Figure 5 In the illustrated process, step 501 is optional. Dividing the space containing the fluid object into N subspaces, and ensuring that fluid particles falling into the same subspace have the same initial velocity, simplifies the complexity of subsequently updating the initial velocity of fluid particles outside the perturbation packet based on the gravitational effect of the perturbation packet. It also simplifies the complexity of implementing a uniform or non-uniform density distribution of the perturbation packet within the space containing the fluid object.

[0151] At this point, for all fluid particles in the fluid object (including fluid particles inside and outside the perturbation packet), through... Figure 5 The illustrated process can obtain the initial property information of these fluid particles. The initial velocity of the fluid particles outside the perturbation packet is a second initial velocity calculated based on the above process.

[0152] After that, you can refer to Figure 2 The fluid simulation process shown is used for subsequent calculations and rendering operations, which are not restricted in this application.

[0153] The above Figure 5 In the process shown, because perturbation packets are set in the space where the flowing object is located, the fluid particles in these perturbation packets generate a gravitational field on the fluid particles outside the perturbation packets. The fluid particles outside the perturbation packets will be affected by this gravitational field, causing changes in their initial properties (including initial velocity, etc.). This avoids the simplification and mechanization of fluid particle initialization, thereby improving the naturalness and realism of the fluid motion effect and enhancing the visual experience.

[0154] In some embodiments, the perturbation packet can be set according to the needs of the virtual scene, such as setting the initial velocity of the perturbation packet and the density distribution of the perturbation packet according to the needs of the scene, so that the initial state of the fluid can match the characteristics of the virtual scene, meet the needs of complex scenes, and improve the naturalness and realism of the fluid motion effect.

[0155] Based on the above Figure 2In the fluid simulation process shown, all fluid particles participate in the generation of rendering data and the rendering process during rendering. This requires storing relevant data for each fluid particle, resulting in large computational and storage overhead, which leads to reduced computational performance and a poor user experience.

[0156] Therefore, this application provides a fluid simulation method and related apparatus for implementing the method, in order to reduce the computational overhead of fluid simulation, improve the performance of fluid simulation, and thus improve the user experience. The following is in conjunction with... Figure 8 The fluid simulation method provided in the embodiments of this application will be described.

[0157] See Figure 8 This is a schematic flowchart of a fluid simulation method provided in an embodiment of this application. The process can be... Figure 1 The fluid simulation method can be executed by device 110 in the illustrated architecture, or by server 120. Within device 110 or server 120, the fluid simulation method can be executed on the CPU, or by a combination of CPU and GPU.

[0158] like Figure 8 As shown, the fluid simulation process may include the following steps:

[0159] Step 801: Obtain the initial attribute information of the fluid particles in the space where the fluid object is located.

[0160] One possible implementation method can be referenced. Figure 5 The process shown obtains the initial attribute information of fluid particles within the space where the fluid object is located.

[0161] Another possible implementation is to use methods provided by related technologies to obtain the initial attribute information of fluid particles within the space where the fluid object resides, for example, by referring to... Figure 2 The process shown is used for the initialization of fluid particles.

[0162] This application does not impose any restrictions on the specific implementation method of initializing fluid particles.

[0163] Optionally, a neighborhood search can also be performed. For example, a neighborhood search can be performed using a hash table data structure to find all fluid particles that are less than r away from the current fluid particle. This can be achieved, for instance, by dividing the data into a grid.

[0164] Step 802: Generate fluid model data based on the initial attribute information of the fluid particles in the space. The fluid model data includes the motion state information of the fluid particles in the space.

[0165] The implementation method for this step can be found by referring to... Figure 2The relevant content in the illustrated process. This application does not limit the specific implementation method of this step.

[0166] Step 803: Perform physical calculations on the fluid model data to obtain fluid model solution data.

[0167] The fluid model solution data includes the solution data of all fluid particles in the space.

[0168] Fluid model solution data can be used to describe the morphology of fluid particles in the virtual scene, such as the reflection and refraction of light on the surface of fluid particles.

[0169] The implementation method for this step can be found by referring to... Figure 2 The relevant content in the illustrated process. This application does not limit the specific implementation method of this step.

[0170] Step 804: Generate rendering data for the fluid object based on the solution data of some fluid particles in the space.

[0171] In step 804, the method for generating rendering data can be found by referring to... Figure 2 The relevant content in the illustrated process. This application does not limit the specific implementation method of this step.

[0172] In step 804, all fluid particles within the space can be divided into two sets: a first set and a second set. Fluid particles in the first set participate in the rendering process, while fluid particles in the second set do not. In other words, rendering data is generated based on the fluid model solution data of the fluid particles in the first set. Correspondingly, rendering data using this fluid particle rendering data is used for rendering processing to obtain the display image of the fluid object.

[0173] Optionally, the fluid particles in the first and second particle sets are distributed relatively discretely within the space where the fluid object is located, or have a certain random distribution characteristic, in order to ensure the display effect of the fluid object.

[0174] Optionally, the ratio between the number of fluid particles in the first particle set and the number of fluid particles in the second particle set is preset. For example, a first ratio α can be preset, where the number of fluid particles in the first particle set is Q×α, and the number of fluid particles in the second particle set is Q×(1-α). Here, Q represents the total number of fluid particles in the space where the fluid object is located. The first ratio α is greater than 0 and less than or equal to 1.

[0175] Optionally, the value of the first ratio α can be determined based on considerations such as simulation experiments, user requirements for fluid visual effects, and device computing power, and this application does not impose any restrictions. For example, the value range of the first ratio α is [0.1, 0.7].

[0176] In fluid simulation, the number of fluid particles often exceeds 10,000. However, the actual number of fluid particles that play a core role in the rendering effect may be relatively small; sometimes, only one-tenth of the number of fluid particles is needed to completely reproduce the display effect of a fluid object. Figure 8 In the process shown, since some fluid particles are used in the rendering, the storage and computational overhead can be reduced while ensuring the display effect of fluid objects.

[0177] This application provides two methods for dividing the first particle set and the second particle set, which will be described below.

[0178] The first method for partitioning a particle set:

[0179] From all the fluid particles in the space where the fluid object is located, a portion of the fluid particles are randomly selected. This portion of fluid particles forms the first particle set, and the remaining fluid particles form the second particle set.

[0180] Optionally, after randomly selecting a portion of fluid particles to form the first fluid particle set, the remaining fluid particles can be released, which means releasing the memory space storing the data related to these fluid particles.

[0181] When using the first method, when adding fluid particles to the space later, new memory space needs to be allocated to store the relevant data of the newly added fluid particles.

[0182] The second method for partitioning the particle set:

[0183] Based on the pre-specified identifiers of the fluid particles, select the fluid particles with the corresponding identifiers from all the fluid particles in the space where the fluid object is located. These fluid particles form the first particle set, and the remaining fluid particles form the second particle set.

[0184] Since the fluid particles participating in the rendering process are fluid particles with specified identifiers, the selection of fluid particles for rendering is fixed each time. Correspondingly, the number of fluid particles not participating in rendering is also fixed, and thus, the memory space used to store the data of these non-rendered fluid particles is also fixed. Therefore, in one possible implementation, this memory space can be left unreclaimed; that is, the memory space occupied by the fluid particles in the second particle set can be retained, i.e., this memory space will not be reclaimed. Thus, using this second method, when adding fluid particles to this space subsequently, there is no need to allocate new memory space; the memory space occupied by the fluid particles in the second particle set can be used to store the data of the newly added fluid particles.

[0185] In one possible implementation, after rendering is complete, fluid particles can be added to the space where the fluid object resides. The number of added fluid particles is equal to or approximately equal to the number of fluid particles in the second particle set, thus ensuring that the total number of fluid particles in the space where the fluid object resides remains constant or changes only slightly. For example, when the above-mentioned... Figure 8 The method shown involves releasing a portion of the fluid particles, rendering an image frame of the fluid object based on the remaining small number of fluid particles, and then adding some fluid particles within the space where the fluid object resides to ensure that the above-mentioned... Figure 8 During the process of generating the next image frame using the method shown, the total number of fluid particles involved in initialization and physical calculation remains unchanged or changes little, thus ensuring the display effect of the fluid object.

[0186] One possible implementation involves using a particle tessellation method to randomly add fluid particles within the space containing the fluid object. For example, the process of adding fluid particles using the particle tessellation method may include: randomly adding fluid particles to a local spatial region based on the normal direction of the fluid object's surface (or envelope), with the number of added fluid particles being the same as the number of fluid particles in the second particle set; if the added fluid particles do not form an inner normal envelope, it indicates that the fluid particle is located outside the space containing the fluid object, and therefore the fluid particle is released.

[0187] Optionally, if some of the added fluid particles are released, fluid particles can be added again in the manner described above, and the number of added fluid particles can be equal to the number of released fluid particles.

[0188] The initial velocity of the added fluid particle can be determined based on the velocities of the fluid particles surrounding it. Optionally, fluid particles whose distance from the first fluid particle is within a set value can be considered as fluid particles surrounding the first fluid particle.

[0189] For example, taking any one of the added fluid particles, referred to here as the first fluid particle, as an example, the initial velocity of the first fluid particle can be obtained in the following ways:

[0190] Method 1: Determine the average velocity of the fluid particles around the first fluid particle based on their velocities, and use this average velocity as the initial velocity of the first fluid particle.

[0191] Method 2: Determine the initial velocity of the first fluid particle using an interpolation algorithm based on the velocities of the fluid particles surrounding it. This application does not restrict the type of interpolation algorithm.

[0192] Method 3: Determine the initial velocity of the first fluid particle using finite element analysis based on the velocities of the fluid particles surrounding it. For example, the finite element analysis method could be a central difference method within the finite difference method. This application does not limit the type of finite element analysis method.

[0193] The above Figure 8 In the process shown, by using some fluid particles within the space where the fluid object is located for rendering, a small number of fluid particles are used to simulate a large number of fluid particles to achieve a dynamic fluid display effect, reducing computational and storage overhead.

[0194] if Figure 8 Step 801 in the process shown is implemented using the method provided in the embodiments of this application, which can improve the naturalness and realism of the fluid motion effect and enhance the visual experience while reducing computational and storage overhead.

[0195] Figure 9 , Figure 10 and Figure 11 The diagram illustrates the possible structures of devices provided for embodiments of this application. These devices can be used to implement the functions of the electronic devices in the above-described method embodiments, and thus also achieve the beneficial effects of the above-described method embodiments. In the embodiments of this application, the device can be an electronic device or a module (such as a chip) applied to an electronic device.

[0196] like Figure 9 As shown, the device 900 includes a disturbance packet setting unit 901 and a fluid particle initial velocity update unit 902. The device 900 is used to implement the above... Figure 5 The illustrated method embodiment demonstrates the functionality of the electronic device.

[0197] When the communication device 900 is used to achieve Figure 5The electronic device in the illustrated method embodiment functions as follows: a disturbance packet setting unit 901 is used to set one or more disturbance packets in the space where the fluid object is located, each of the one or more disturbance packets includes at least one fluid particle, and the fluid particles in the same disturbance packet have the same initial velocity; a fluid particle initial velocity updating unit 902 is used to update the initial velocity of the fluid particles outside the one or more disturbance packets according to the gravitational effect of the fluid particles in the one or more disturbance packets on the fluid particles outside the one or more disturbance packets.

[0198] Optionally, the one or more disturbance packets are randomly distributed within the space where the fluid object is located; or, the distribution of the one or more disturbance packets within the space where the fluid object is located matches the flow tendency of the fluid object.

[0199] For example, the space where the fluid object is located includes a first space and a second space, and the fluid object tends to flow from the first space to the second space; the number or density of disturbance packets in the first space is less than the number or density of disturbance packets in the second space.

[0200] Optionally, the number of fluid particles contained in the one or more disturbance packets is the same.

[0201] Optionally, each of the one or more perturbation packets is the same size.

[0202] Optionally, before setting the disturbance packet in the space where the fluid object is located, the method further includes: dividing the space where the fluid object is located into at least two subspaces; the fluid particles in the disturbance packet located in the same subspace have the same initial velocity.

[0203] Optionally, the fluid particles outside the one or more perturbation packets include a first fluid particle whose updated initial velocity is related to the initial velocity of the one or more perturbation packets and the distance between the one or more perturbation packets and the first particle.

[0204] Optionally, the updated initial velocity of the first fluid particle can satisfy the aforementioned formulas 2 and 3.

[0205] A more detailed description of the aforementioned disturbance packet setting unit 901 and fluid particle initial velocity update unit 902 can be obtained directly from the descriptions in the method embodiments shown in the relevant figures, and will not be repeated here.

[0206] like Figure 10 As shown, the device 1000 includes an initial attribute setting unit 1001, a fluid model data generation unit 1002, a solution unit 1003, and a rendering unit 1004. The device 1000 is used to implement the above-mentioned... Figure 8 The illustrated method embodiment demonstrates the functionality of the electronic device.

[0207] When the communication device 1000 is used to implement Figure 8 The electronic device in the illustrated method embodiment functions as follows: an initial attribute setting unit 1001 is used to obtain initial attribute information of fluid particles in the space where the fluid object is located; a fluid model data generation unit 1002 is used to generate fluid model data based on the initial attribute information of the fluid particles in the space, the fluid model data including motion state information of the fluid particles in the space; a calculation unit 1003 is used to perform physical calculations on the fluid model data to obtain fluid model calculation data; and a rendering unit 1004 is used to generate rendering data of the fluid object based on the fluid model calculation data of some fluid particles in the space.

[0208] Optionally, the rendering unit 1004 is further configured to: before generating rendering data for the fluid object based on the fluid model calculation data of a portion of the fluid particles in the space, divide the fluid particles in the space into a first particle set and a second particle set according to a first ratio. The rendering unit 1004 generates rendering data for the fluid object based on the fluid model calculation data of the fluid particles in the first particle set.

[0209] Optionally, the partial fluid particles are fluid particles randomly selected from all fluid particles in the space where the fluid object is located; or, the partial fluid particles are fluid particles selected from all fluid particles in the space where the fluid object is located according to a specified fluid particle identifier.

[0210] Optionally, after completing the rendering process based on the rendering data, the initial attribute setting unit 1001 is further configured to: randomly add fluid particles in the space where the fluid object is located based on the number of fluid particles in the second particle set, wherein the fluid particles in the second fluid particle set are a part of the fluid particles in the space, and the fluid model solution data of the fluid particles in the second particle set is not used to generate the rendering data of the fluid object.

[0211] Optionally, the fluid particles randomly added within the space where the fluid object is located include a first fluid particle, the initial velocity of which is determined based on the velocity of at least one fluid particle surrounding the first fluid particle.

[0212] Optionally, the initial velocity of the first fluid particle is determined based on the average velocity of at least one fluid particle surrounding the first fluid particle; or, the initial velocity of the first fluid particle is obtained by interpolating the velocity of at least one fluid particle surrounding the first fluid particle; or, the initial velocity of the first fluid particle is obtained using finite element analysis based on the velocity of at least one fluid particle surrounding the first fluid particle.

[0213] Optionally, the initial attribute setting unit 1001 is specifically used to: set one or more perturbation packets in the space where the fluid object is located, each of the one or more perturbation packets includes at least one fluid particle, and the initial velocities of the fluid particles in the same perturbation packet are the same; and update the initial velocities of the fluid particles outside the one or more perturbation packets according to the gravitational effect of the fluid particles in the one or more perturbation packets on the fluid particles outside the one or more perturbation packets.

[0214] Optionally, the one or more disturbance packets are randomly distributed within the space where the fluid object is located; or, the distribution of the one or more disturbance packets within the space where the fluid object is located matches the flow tendency of the fluid object.

[0215] For example, the space where the fluid object is located includes a first space and a second space, and the fluid object tends to flow from the first space to the second space; the number or density of disturbance packets in the first space is less than the number or density of disturbance packets in the second space.

[0216] Optionally, the number of fluid particles contained in the one or more disturbance packets is the same.

[0217] Optionally, each of the one or more perturbation packets is the same size.

[0218] Optionally, before setting a disturbance packet in the space where the fluid object is located, the initial attribute setting unit 1001 is further configured to: divide the space where the fluid object is located into at least two subspaces; the fluid particles in the disturbance packets located in the same subspace have the same initial velocity.

[0219] Optionally, the fluid particles outside the one or more perturbation packets include a first fluid particle whose updated initial velocity is related to the initial velocity of the one or more perturbation packets and the distance between the one or more perturbation packets and the first particle.

[0220] Optionally, the updated initial velocity of the first fluid particle can satisfy the aforementioned formulas 2 and 3.

[0221] More detailed descriptions of the aforementioned initial attribute setting unit 1001, fluid model data generation unit 1002, solution unit 1003, and rendering unit 1004 can be obtained directly from the descriptions in the method embodiments shown in the relevant figures, and will not be elaborated here.

[0222] like Figure 11 As shown, device 1100 may include: a memory 1101, one or more processors 1102, and one or more computer programs (not shown). These devices may be coupled via one or more communication buses 1103. Optionally, when device 1100 is used to implement the methods performed by the electronic device provided in the embodiments of this application, device 1100 may further include a display screen 1104.

[0223] The memory 1101 stores one or more computer programs (code), and the one or more computer programs include computer instructions; one or more processors 1102 call the computer instructions stored in the memory 1101, causing the device 1100 to execute the method provided in the embodiments of this application. The display screen 1104 is used to display images, videos, application interfaces, and other related user interfaces.

[0224] In a specific implementation, memory 1101 may include high-speed random access memory and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. Memory 1101 may store an operating system (hereinafter referred to as the system), such as embedded operating systems like Android, iOS, Windows, or Linux. Memory 1101 can be used to store implementation programs of the embodiments of this application. Memory 1101 may also store network communication programs, which can be used to communicate with one or more additional devices, one or more user devices, or one or more network devices. One or more processors 1102 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of programs in the scheme of this application.

[0225] It should be noted that, Figure 11 This is merely one implementation of the device 1100 provided in this application embodiment. In actual applications, the electronic device 1100 may include more or fewer components, which is not limited here.

[0226] Based on the above embodiments and the same concept, this application also provides a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the method performed by the electronic device in the above embodiments.

[0227] Based on the above embodiments and the same concept, this application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are run on a computer, the computer causes the computer to perform the method performed by the electronic device in the above embodiments.

[0228] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0229] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0230] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0231] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0232] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A fluid simulation method, characterized in that, Comprising: One or more perturbation packets are set in the space where the fluid object is located, each of the one or more perturbation packets includes at least one fluid particle, and the initial velocities of the fluid particles in the same perturbation packet are the same; According to the gravitational effect of the fluid particles in the one or more perturbation packets on the fluid particles outside the one or more perturbation packets, the initial velocities of the fluid particles outside the one or more perturbation packets are updated.

2. The method as described in claim 1, characterized in that, The one or more perturbation packets are randomly distributed in the space where the fluid object is located; or The distribution of the one or more perturbation packets in the space where the fluid object is located matches the flow tendency of the fluid object.

3. The method as described in claim 2, characterized in that, The space where the fluid object is located includes a first space and a second space, and the flow tendency of the fluid object is to flow from the first space to the second space; The distribution of the one or more perturbation packets in the space where the fluid object is located matches the flow tendency of the fluid object, including: The number or density of the perturbation packets in the first space is less than the number or density of the perturbation packets in the second space.

4. The method according to any one of claims 1-3, characterized in that, The number of fluid particles contained in each of the one or more perturbation packets is the same.

5. The method according to any one of claims 1-4, characterized in that, The size of each of the one or more perturbation packets is the same.

6. The method according to any one of claims 1-5, characterized in that, Before setting one or more perturbation packets in the space where the fluid object is located, it further includes: dividing the space where the fluid object is located into at least two sub-spaces; The fluid particles in the perturbation packets located in the same sub-space have the same initial velocity.

7. The method according to any one of claims 1-6, characterized in that, The fluid particles outside the one or more perturbation packets include first fluid particles, and the updated initial velocity of the first fluid particles is related to the initial velocities of the one or more perturbation packets and the distance between the one or more perturbation packets and the first particles.

8. The method as described in claim 7, characterized in that, There are K fluid particles outside the one or more perturbation packets, K is an integer greater than 1, the first fluid particle is the k-th fluid particle among the K fluid particles, 1 < k << K, and the updated initial velocity of the k-th fluid particle satisfies the following formula: in, v represents the initial velocity of the k-th fluid particle after the update; i Represents the initial velocity of the i-th perturbation packet; impact ik Let be the gravitational influence factor of the i-th perturbation packet on the k-th fluid particle, which is used to characterize the magnitude of the gravitational force exerted by the i-th perturbation packet on the k-th fluid particle.

9. The method as described in claim 8, characterized in that, The gravitational influence factor of the i-th perturbation packet on the k-th fluid particle. ik Satisfy the following formula: Among them, R ik ρ is the distance between the i-th perturbation packet and the k-th fluid particle; ρ is the density of the one or more perturbation packets in the space where the fluid object is located; C is a constant.

10. A fluid simulation method, characterized in that, Comprising: Obtain the initial attribute information of the fluid particles in the space where the fluid object is located; Generate fluid model data according to the initial attribute information of the fluid particles in the space, and the fluid model data includes the motion state information of the fluid particles in the space; Perform physical calculation on the fluid model data to obtain fluid model calculation data; Generate rendering data of the fluid object according to the fluid model calculation data of some of the fluid particles in the space.

11. The method as described in claim 10, characterized in that, Before generating the rendering data of the fluid object according to the fluid model calculation data of some of the fluid particles in the space, it further includes: Divide the fluid particles in the space into a first particle set and a second particle set according to a first ratio; Generating the rendering data of the fluid object according to the fluid model calculation data of some of the fluid particles in the space includes: Generate the rendering data of the fluid object according to the fluid model calculation data of the fluid particles in the first particle set.

12. The method according to any one of claims 10-11, characterized in that, The fluid particles mentioned are randomly selected from all fluid particles within the space where the fluid object is located; or, The fluid particles are selected from all fluid particles in the space where the fluid object is located, based on a specified fluid particle identifier.

13. The method according to any one of claims 10-12, characterized in that, After completing the rendering process based on the rendering data, the process also includes: Based on the number of fluid particles in the second particle set, fluid particles are randomly added within the space where the fluid object is located. The fluid particles in the second particle set are a subset of the fluid particles in the space. The fluid model solution data of the fluid particles in the second particle set is not used to generate the rendering data of the fluid object.

14. The method as described in claim 13, characterized in that, The fluid particles randomly added within the space where the fluid object is located include a first fluid particle, the initial velocity of which is determined based on the velocity of at least one fluid particle surrounding the first fluid particle.

15. The method as described in claim 14, characterized in that, The initial velocity of the first fluid particle is determined based on the average velocity of at least one fluid particle surrounding the first fluid particle; or The initial velocity of the first fluid particle is obtained by interpolating the velocities of at least one fluid particle surrounding the first fluid particle; or The initial velocity of the first fluid particle is obtained using the finite element method based on the velocity of at least one fluid particle surrounding the first fluid particle.

16. The method according to any one of claims 10-15, characterized in that, The process of obtaining the initial attribute information of fluid particles within the space where the fluid object is located includes: One or more disturbance packets are set in the space where the fluid object is located. Each of the one or more disturbance packets includes at least one fluid particle. The fluid particles in the same disturbance packet have the same initial velocity. The initial velocities of the fluid particles outside the one or more perturbation packets are updated based on the gravitational effect of the fluid particles within the one or more perturbation packets on the fluid particles outside the one or more perturbation packets.

17. The method as described in claim 16, characterized in that, The one or more disturbance packets are randomly distributed within the space where the fluid object is located; or The distribution of one or more disturbance packets within the space where the fluid object is located matches the flow tendency of the fluid object.

18. The method as described in claim 17, characterized in that, The space where the fluid object is located includes a first space and a second space, and the fluid object tends to flow from the first space to the second space. The distribution of one or more disturbance packets within the space where the fluid object is located matches the flow tendency of the fluid object, including: The number or density of disturbance packets in the first space is less than the number or density of disturbance packets in the second space.

19. The method according to any one of claims 16-18, characterized in that, Each of the one or more disturbance packets contains the same number of fluid particles.

20. The method according to any one of claims 16-19, characterized in that, Each of the one or more perturbation packets is the same size.

21. The method according to any one of claims 16-20, characterized in that, Before setting one or more disturbance packets in the space where the fluid object is located, the method further includes: dividing the space where the fluid object is located into at least two subspaces; Fluid particles within the same subspace of a disturbance packet have the same initial velocity.

22. The method according to any one of claims 16-21, characterized in that, The fluid particles outside the one or more perturbation packets include first fluid particles, and the updated initial velocity of the first fluid particles is related to the initial velocity of the one or more perturbation packets and the distance between the one or more perturbation packets and the first particles.

23. The method as described in claim 22, characterized in that, Outside the one or more perturbation packets, there are K fluid particles, where K is an integer greater than 1. The first fluid particle is the k-th fluid particle among the K fluid particles, 1 < k << K. The updated initial velocity of the k-th fluid particle satisfies the following formula: in, v represents the initial velocity of the k-th fluid particle after the update; i Represents the initial velocity of the i-th perturbation packet; impact ik Let be the gravitational influence factor of the i-th perturbation packet on the k-th fluid particle, which is used to characterize the magnitude of the gravitational force exerted by the i-th perturbation packet on the k-th fluid particle.

24. The method as described in claim 23, characterized in that, The gravitational influence factor of the i-th perturbation packet on the k-th fluid particle. ik Satisfy the following formula: Among them, R ik ρ is the distance between the i-th perturbation packet and the k-th fluid particle; ρ is the density of the one or more perturbation packets in the space where the fluid object is located; C is a constant.

25. An apparatus, characterized in that, It includes a unit or module for executing the method according to any one of claims 1-9, or a unit or module for executing the method according to any one of claims 10-24.

26. An apparatus, characterized in that, It includes: One or more processors are configured to execute the method according to any one of claims 1-9, or to execute the method according to any one of claims 10-24.

27. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions. When the program or instructions run on the device, the device is caused to execute the method according to any one of claims 1-9, or to execute the method according to any one of claims 10-24.

28. A chip system, characterized in that, It includes a processor for supporting a computer device to implement the method according to any one of claims 1-9, or to implement the method according to any one of claims 10-24.

29. A program product, characterized in that, The program product contains a program; when the program runs on a computer, the computer is caused to execute the method according to any one of claims 1-9, or to execute the method according to any one of claims 10-24.