Fluid simulation method, apparatus, storage medium, and electronic device
By simulating the fluid changes of particles in a grid-based manner and calculating the physical forces between grids, the problem of large computational load and high performance consumption in fluid simulation is solved, achieving accurate simulation and improved realism of fluid dynamics.
Patent Information
- Application Number
- CN202411808208.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-12-09
AI Technical Summary
Existing fluid simulation methods have significant problems in terms of computational load and performance consumption, making it difficult to accurately simulate fluid dynamics, especially in applications such as games where real-time calculations are challenging.
The algorithm simulates the fluid changes of particles using a grid as the unit. By obtaining the initial fluid parameters and velocity parameters in the grid, the physical forces between the grids are calculated to generate fluid dynamic effects, reducing the amount of computation and improving realism.
It significantly reduces computational load and performance consumption, while accurately simulating fluid dynamics and enabling interaction between fluids and other objects, thus improving the realism of fluid simulation.
Smart Images

Figure CN119740512B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a fluid simulation method, a fluid simulation device, a computer storage medium, and an electronic device. Background Technology
[0002] In some top-down games, dynamic fluid effects are often present on the large map, such as floods, mudslides, and waterfalls. Existing technical solutions commonly employ Smoothed Particle Hydrodynamics (SPH) and FlowMap techniques to simulate fluid flow. The SPH algorithm simulates realistic 3D water bodies using microscopic particles, requiring rapid iteration of a large amount of water information, resulting in high computational demands and performance limitations, making real-time calculations difficult. FlowMap, on the other hand, uses flow maps to control texture offset direction and speed to achieve flow effects; however, due to the fixed nature of flow maps, it struggles to accurately simulate dynamic fluid flow.
[0003] Therefore, there is an urgent need for a fluid simulation method that can accurately simulate the dynamic effects of fluids while ensuring low performance consumption to meet the needs of practical applications. Summary of the Invention
[0004] This disclosure provides a fluid simulation method, a fluid simulation device, a computer storage medium, and an electronic device, which can significantly reduce the amount of computation and thus reduce performance consumption to meet the actual needs of real-time fluid simulation, while also improving the accuracy of the simulated fluid dynamics.
[0005] In a first aspect, one embodiment of this disclosure provides a fluid simulation method, which includes: obtaining initial fluid parameters and initial velocity parameters of fluid sub-models in each grid of the region to be simulated at the current iteration number, wherein the initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number based on the current iteration number; determining the physical quantity value of the physical force acting on the fluid sub-model in each grid according to the initial fluid parameters; determining the target velocity parameter of the target grid at the current iteration number based on the initial velocity parameter of the fluid sub-model in the target grid and the physical quantity value of the physical force acting on the target grid for a target grid among multiple grids; and generating the fluid dynamic effect of the fluid model in the region to be simulated based on the target velocity parameter of the fluid sub-model in each grid at each iteration number.
[0006] Secondly, one embodiment of this disclosure provides a fluid simulation apparatus, comprising: a fluid parameter acquisition module, configured to acquire initial fluid parameters and initial velocity parameters of fluid sub-models in each grid of the region to be simulated at the current iteration number, wherein the initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number; a physical quantity value determination module, configured to determine the physical quantity value of the physical force acting on the fluid sub-models in each grid based on the initial fluid parameters; a velocity parameter determination module, configured to determine the target velocity parameter of a target grid at the current iteration number based on the initial velocity parameter of the fluid sub-model in the target grid and the physical quantity value of the physical force acting on the target grid; and a fluid simulation module, configured to generate the fluid dynamic effect of the fluid model in the region to be simulated based on the target velocity parameter of the fluid sub-models in each grid at each iteration number.
[0007] Thirdly, one embodiment of this disclosure provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the fluid simulation method described above.
[0008] Fourthly, one embodiment of this disclosure provides an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the fluid simulation method described above by executing the executable instructions.
[0009] Fifthly, one embodiment of this disclosure provides a computer program product, including a computer program that is executed by a processor to implement the fluid simulation method described above.
[0010] The technical solution disclosed herein has the following beneficial effects:
[0011] The aforementioned fluid simulation method obtains the initial fluid parameters and initial velocity parameters of the fluid sub-models in each grid of the region to be simulated at the current iteration number. The initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number. Based on the initial fluid parameters, the physical quantity values of the physical forces acting on the fluid sub-models in each grid are determined. For the target grid among multiple grids, the target velocity parameters of the target grid at the current iteration number are determined based on the initial velocity parameters of the fluid sub-models in the target grid and the physical quantity values of the physical forces acting on the target grid. Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, the fluid dynamics effect of the fluid model in the region to be simulated is generated.
[0012] On the one hand, this method simulates fluid changes of particles using a mesh-based approach, significantly reducing computational load compared to existing particle simulation methods. Furthermore, since the simulation area is a two-dimensional plane, it only needs to simulate fluid effects within a three-dimensional scene, thus reducing performance consumption. On the other hand, by using a mesh as the simulation unit and calculating the forces between meshes, this method simulates dynamic fluid effects. Compared to existing methods using flow mapping, it allows for interaction with other objects, such as objects floating on fluid, thus accurately representing fluid effects and improving the realism of fluid simulation.
[0013] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0014] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0015] Figure 1 This schematic diagram illustrates the architecture of one of the fluid simulation systems in this exemplary embodiment.
[0016] Figure 2 This schematically illustrates a flowchart of one of the fluid simulation methods of this exemplary embodiment;
[0017] Figure 3 This schematic diagram illustrates one type of mesh effect in this exemplary embodiment.
[0018] Figure 4 This schematic diagram illustrates the simulation effect of one of the advection methods in this exemplary embodiment.
[0019] Figure 5A This schematic diagram illustrates the physical force conversion under fluid data between meshes in the first exemplary embodiment of this invention.
[0020] Figure 5B This schematic diagram illustrates the physical force conversion under fluid data between the second type of meshes in this exemplary embodiment.
[0021] Figure 6 This schematic diagram illustrates the physical force conversion under fluid data between third-type meshes in this exemplary embodiment.
[0022] Figure 7This schematic diagram illustrates the physical force conversion under fluid data between meshes in the fourth exemplary embodiment of this invention.
[0023] Figure 8 This schematic diagram illustrates the structure of a fluid simulation device in this exemplary embodiment.
[0024] Figure 9 The schematic diagram illustrates the structure of an electronic device in this exemplary embodiment. Detailed Implementation
[0025] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0026] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0027] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0028] In the relevant technical background, some top-down games often need to simulate the dynamic artistic effects of fluids in large maps, such as adding fluids like floods, mudslides, and waterfalls to the scene.
[0029] In existing related technical solutions, the SPH algorithm and FlowMap technology are mainly used to realize fluid simulation. The SPH algorithm is a particle-based fluid simulation method widely used to simulate the motion of liquids and gases. It achieves dynamic fluid effects by simulating a large number of particles and their interactions. However, this process requires iterating through a large amount of information, leading to a high computational load and excessive performance consumption, making it unsuitable for applications such as games. FlowMap technology, on the other hand, is a texture-based fluid simulation method. It mainly uses flow maps to control the movement direction and speed of textures to achieve dynamic fluid effects. However, since the flow map is fixed, and the virtual scene contains obstacles such as buildings, there are bound to be issues such as fluids changing direction when encountering obstacles, or objects floating on the fluid to create interactive dynamic effects like mudslides. However, it cannot accurately simulate the fluid's performance.
[0030] Therefore, there is an urgent need for a fluid simulation method that can accurately simulate the dynamic effects of fluids while ensuring low performance consumption to meet the needs of practical applications.
[0031] This exemplary embodiment addresses the aforementioned problems and proposes a fluid simulation method. This method can be applied to any application scenario requiring fluid simulation, such as creating mudslide effects or waterfall effects. The method obtains the initial fluid parameters and initial velocity parameters of the fluid sub-models in each grid of the region to be simulated at the current iteration number. The initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number. Based on the initial fluid parameters, the physical quantity values of the physical forces acting on the fluid sub-models in each grid are determined. For a target grid among multiple grids, the target velocity parameters of the target grid at the current iteration number are determined based on the initial velocity parameters of the fluid sub-models in the target grid and the physical quantity values of the physical forces acting on the target grid. Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, the fluid dynamic effects of the fluid models in the region to be simulated are generated.
[0032] On the one hand, this method simulates fluid changes of particles using a mesh-based approach, significantly reducing computational load compared to existing particle simulation methods. Furthermore, since the simulation area is a two-dimensional plane, it only needs to simulate fluid effects within a three-dimensional scene, thus reducing performance consumption. On the other hand, by using a mesh as the simulation unit and calculating the forces between meshes, this method simulates dynamic fluid effects. Compared to existing methods using flow mapping, it allows for interaction with other objects, such as objects floating on fluid, thus accurately representing fluid effects and improving the realism of fluid simulation.
[0033] The following will combine Figure 1 The fluid simulation method and apparatus proposed in this disclosure are applied to... Figure 1 An embodiment of the system architecture in the exemplary application environment shown is illustrated.
[0034] like Figure 1 The diagram shown is an application scenario provided by an embodiment of this application. In this scenario, a terminal device 101 and a server 102 may be included.
[0035] Terminal device 101 can be, for example, any device involving item recommendation, such as a mobile phone, tablet computer (PAD), laptop computer, desktop computer, smart TV, smart in-vehicle device, smart wearable device, or aircraft. Terminal device 101 can have a target application installed, which can have functions such as displaying fluid simulation effects. The application involved in this embodiment can be a software client, or a webpage, mini-program, etc. Server 102 is the server corresponding to the software, webpage, mini-program, etc., and the specific type of client is not limited.
[0036] Server 102 can be a backend server for the target application, providing corresponding backend services such as recommendation services and recommendation reason generation services. It can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, i.e., Content Delivery Network (CDN), and big data and artificial intelligence platforms, but it is not limited to these.
[0037] It should be noted that the fluid simulation method in this embodiment can be executed by either the terminal device 101 or the server 102 alone, or by both the server 102 and the terminal device 101. Both the server 102 and the terminal device 101 may include one or more processors, memory, and interactive I / O interfaces. Furthermore, the server 102 may be configured with a database to store trained model parameters. The memory of both the server 102 and the terminal device 101 may also store the program instructions required for execution in the fluid simulation method provided in this embodiment. These program instructions, when executed by the processor, can be used to implement the process of simulating fluid effects provided in this embodiment.
[0038] It should be noted that when the fluid simulation method provided in this application embodiment is executed by either server 102 or terminal device 101 alone, the above application scenario may also include only a single device, either server 102 or terminal device 101. Alternatively, server 102 and terminal device 101 may be considered as the same device. Of course, in practical applications, when the fluid simulation method provided in this application embodiment is executed by both server 102 and terminal device 101, server 102 and terminal device 101 may also be the same device. That is, server 102 and terminal device 101 may be different functional modules of the same device, or a virtual device virtualized by the same physical device.
[0039] In this embodiment, the terminal device 101 and the server 102 can communicate directly or indirectly through one or more networks 103. The network 103 can be a wired network or a wireless network; for example, the wireless network can be a mobile cellular network or a wireless fidelity network. The network used is Fidelity (Wi-Fi), but it can also be other possible networks; this application does not limit the scope of the embodiments. It should be noted that... Figure 1 The examples shown are merely illustrative; in reality, the number of terminal devices and servers is unlimited and is not specifically limited in the embodiments of this application.
[0040] For example, in one exemplary embodiment, the terminal device acquires the initial fluid parameters and initial velocity parameters of the fluid sub-models in each grid of the region to be simulated at the current iteration number. The initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number. Based on the initial fluid parameters, the physical quantity value of the physical force acting on the fluid sub-model in each grid is determined. For a target grid among multiple grids, based on the initial velocity parameters of the fluid sub-model in the target grid and the physical quantity value of the physical force acting on the target grid, the target velocity parameter of the target grid at the current iteration number is determined. Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, the fluid dynamic effect of the fluid model in the region to be simulated is generated.
[0041] The following describes the method provided by exemplary embodiments of this application in conjunction with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way. It should also be noted that the following method can be executed by the terminal device or the server, or by both the terminal device and the server. Here, the example is specifically shown with the terminal device as the executing entity.
[0042] The following example illustrates how the fluid simulation method can be applied to the aforementioned terminal device. Figure 2 A flowchart illustrating one exemplary embodiment of the fluid simulation method is shown below. Figure 2 The fluid simulation method provided in this disclosure includes the following steps S201-S204:
[0043] Step S201: Obtain the initial fluid parameters and initial velocity parameters of the fluid sub-model in each grid of the region to be simulated at the current iteration number.
[0044] Among them, the initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number of the current iteration number.
[0045] Step S202: Based on the initial fluid parameters, determine the physical quantity values of the physical forces acting on the fluid sub-model in each grid.
[0046] Step S203: For the target mesh in multiple meshes, based on the initial velocity parameters of the fluid sub-model in the target mesh and the physical quantity values of the physical forces acting on the target mesh, determine the target velocity parameters of the target mesh at the current iteration number.
[0047] Step S204: Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, generate the fluid dynamics effect of the fluid model in the region to be simulated.
[0048] In some embodiments of this disclosure, the technical solutions involve obtaining the initial fluid parameters and initial velocity parameters of the fluid sub-models in each grid of the region to be simulated at the current iteration number. These initial fluid parameters and initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number. Based on the initial fluid parameters, the physical quantities of the physical forces acting on the fluid sub-models in each grid are determined. For a target grid among multiple grids, the target velocity parameters of the target grid at the current iteration number are determined based on the initial velocity parameters of the fluid sub-models in the target grid and the physical quantities of the physical forces acting on the target grid. Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, the fluid dynamics of the fluid model in the region to be simulated are generated. On one hand, this method simulates the fluid changes of particles on a grid-by-grid basis, which significantly reduces the computational load compared to existing particle simulation methods. Furthermore, since the region to be simulated is a two-dimensional plane, the method only needs to simulate the fluid effects in a three-dimensional scene on a two-dimensional plane, thereby reducing performance consumption. On the other hand, this method uses a grid as the simulation unit to calculate the interaction force between grids, thereby simulating the dynamic effects of fluid. Compared with the existing technology that uses flow mapping, it can interact with other objects, such as objects floating on the fluid, thus accurately expressing the fluid effect and improving the realism of fluid simulation.
[0049] The specific embodiments will be discussed. Figure 2 The specific implementation methods of each step in the illustrated embodiment are described in detail below:
[0050] In step S201, the initial fluid parameters and initial velocity parameters of the fluid sub-models in each grid of the region to be simulated are obtained at the current iteration number.
[0051] The simulated area is the region within the virtual scene used to simulate fluid dynamics. It is understood that the simulated area can occupy a portion of the virtual scene or the entire virtual scene; the embodiments disclosed herein do not impose any special limitations on this. The fluid model is a dynamically flowing model, such as models of floods, mudslides, waterfalls, smoke, and water mist. A fluid sub-model is a part of the fluid model; that is, the fluid model is composed of fluid sub-models from various meshes. The current iteration number is any simulation number on the timeline of simulating fluid dynamics, while the fluid dynamics displayed by the fluid model are visual effects formed by the changes in flow velocity of the fluid sub-models based on different iteration numbers.
[0052] The initial fluid parameters and initial velocity parameters mentioned above are parameter data obtained by each fluid sub-model based on the previous iteration number. That is, the initial fluid parameters for the current iteration number are obtained through the fluid simulation process of the previous iteration number, and are used as the initial fluid parameters for the next iteration number to continue the fluid simulation. Similarly, the initial velocity parameters are used to characterize the flow velocity of the fluid sub-model in each grid. The initial velocity parameters for the current iteration number are fluid velocity parameters obtained through the fluid simulation process of the previous iteration number, and are used as the initial velocity parameters for the next iteration number to continue the fluid simulation.
[0053] It should be explained that if the current iteration number is the first iteration number on the time axis of simulating fluid dynamics, then the fluid parameters and fluid velocity of the previous iteration number can be taken as the initial default values.
[0054] In related technical solutions, the annual simulation process for fluid dynamics is usually implemented in a three-dimensional virtual scene. Considering that directly simulating fluid effects in a three-dimensional virtual scene involves large computational loads, increased performance consumption, and thus affects the real-time dynamic effects of the fluid, the embodiments of this disclosure can first perform meshing processing on the two-dimensional plane of the region to be simulated before performing the above step S201, so as to obtain multiple meshes. By simulating only the two-dimensional plane of the region to be simulated, the fluid dynamics effect in the three-dimensional virtual scene can be realized based on the two-dimensional plane, greatly reducing the computational load. The above process will be described in detail below:
[0055] In one optional embodiment of this disclosure, a two-dimensional plane of the region to be simulated is obtained, and the two-dimensional plane is meshed according to a first mesh precision to obtain multiple meshes for the two-dimensional plane; a two-dimensional array is constructed according to the first mesh precision, and the initial fluid parameters of the fluid sub-model in each mesh at the current iteration number are stored in the two-dimensional array so as to obtain the initial fluid parameters of each mesh from the two-dimensional array.
[0056] The two-dimensional plane of the area to be simulated can be a two-dimensional plane region formed based on a top-down view. For example, in some large-map game scenes, virtual models in the virtual scene are usually displayed from a top-down perspective. Furthermore, obtaining the two-dimensional plane of the area to be simulated can also prevent the fluid model from appearing hollowed out. Taking a waterfall model as an example, by obtaining the two-dimensional plane of the waterfall model, the user will not be able to see the interior of the waterfall model.
[0057] For example, after obtaining a two-dimensional plane of the region to be simulated, the two-dimensional plane can be meshed according to a first mesh precision to obtain multiple meshes for the two-dimensional plane. The first mesh precision is used to determine the number of meshes generated for the two-dimensional plane of the region to be simulated. Generally, the higher the mesh precision, the more meshes are generated, the smaller the area occupied by a single mesh on the two-dimensional plane, and the smaller the area of the fluid sub-model within each mesh.
[0058] It should be understood that a higher mesh precision setting results in a larger number of generated meshes, leading to increased computation and higher performance consumption of computer equipment. Conversely, a lower mesh precision setting generates fewer meshes, resulting in less computation, but also lower accuracy in calculating fluid parameters for each fluid sub-model, leading to poor fluid model performance. Therefore, it is necessary to select a suitable mesh precision for meshing the region to be simulated.
[0059] For ease of understanding, the following will combine Figure 3 The effect of meshing the two-dimensional plane of the simulated area according to the first mesh precision is illustrated by the following example.
[0060] Figure 3 This schematic diagram illustrates one type of mesh effect in this exemplary embodiment, with reference to... Figure 3 As shown, assuming it is necessary to... Figure 3 The area shown is used to simulate flood effects and obtain... Figure 3 The area shown is a two-dimensional plane from a top-down perspective, and this two-dimensional plane is meshed according to the first mesh precision to obtain the area to be simulated composed of different meshes.
[0061] In an optional embodiment, regarding the method of determining the mesh accuracy, embodiments of this disclosure may automatically determine a suitable mesh accuracy as a default value (i.e., the first mesh accuracy) based on the area of the region to be simulated and directly perform meshing processing, or provide the user with a mesh accuracy for reference based on the determined default value for the user to manually determine. Embodiments of this disclosure do not impose any special limitations on this.
[0062] The following will describe in detail the process of manually determining the grid precision shown in the above embodiments, based on the above-described meshing process with reference to specific examples.
[0063] In an optional embodiment, the user can also adjust the first grid precision in real time, that is, in response to the adjustment operation for the first grid precision, the terminal device performs gridding processing on the two-dimensional plane of the area to be simulated according to the adjusted second grid precision.
[0064] The precision of the second grid can be greater than or less than that of the first grid. (Refer to...) Figure 3 The first grid precision is shown. If the adjusted second grid precision is greater than the first grid precision, then... Figure 3 The grid density becomes denser, and the area occupied by each individual grid cell decreases; conversely, if the adjusted second grid cell precision is less than the first grid cell precision, then... Figure 3 The number of grid cells becomes sparser, and the area occupied by each individual grid cell becomes larger.
[0065] For example, the graphical user interface of the terminal device can also display or trigger an editing interface for the mesh precision, so that the user can adjust the first mesh precision to the second mesh precision in the editing interface, and then re-mesh the two-dimensional plane of the area to be simulated according to the second mesh precision.
[0066] The above embodiments can improve the flexibility of meshing processing. Users can compare the fluid model effects under different mesh accuracies to determine the better fluid dynamics effect or the fluid dynamics effect with better visual effects.
[0067] In the above embodiments, while performing meshing processing according to the first mesh precision or the second mesh precision, a two-dimensional array is also constructed according to the same mesh precision used for meshing processing. This allows the initial fluid data of the fluid sub-model in each mesh under the current simulation number to be stored in the two-dimensional array, so as to obtain the initial fluid data of each mesh from the two-dimensional array.
[0068] A two-dimensional array is a set of values arranged in order, and a value can be uniquely identified based on the two dimensions of the two-dimensional array. For example, one of the two-dimensional arrays, a[3][5], contains two dimensions, usually the number of rows and the number of columns. a[3][5] represents the two-dimensional array element located in the third row and fifth column.
[0069] In this regard, after constructing a two-dimensional array based on the above embodiments, the initial fluid parameters of the fluid sub-model in each grid at the current iteration number can be stored in the two-dimensional array so that each grid corresponds to a data in the two-dimensional array.
[0070] In an optional embodiment of this disclosure, during the process of storing the initial fluid parameters of the fluid sub-model in each grid into a two-dimensional array at the current iteration number, a one-to-one correspondence between the position information of each grid and the index value in the two-dimensional array can be pre-constructed; according to the correspondence, the initial fluid parameters in each grid are stored into the two-dimensional array element with the corresponding index value.
[0071] The initial fluid parameters for each grid cell contain at least the location information of that grid cell. Therefore, the initial fluid parameters can be stored based on the location information of each grid cell. The one-to-one correspondence between the location information of each grid cell and the index value in the two-dimensional array indicates that each grid cell determined based on the location information corresponds to a unique index value, so that a unique two-dimensional array element can be determined based on the index value.
[0072] For example, the terminal device can construct a two-dimensional array element with the same number of grids as the grids obtained after gridding, based on the grid precision used in the gridding process. This allows the initial fluid parameters of each grid at the current iteration number to be matched with the corresponding two-dimensional array element for data storage, thereby ensuring data security and the logical consistency of data processing.
[0073] Taking the first grid precision used in the meshing process as an example, the simulated region is meshed based on the first grid precision to obtain the first number of grids, and a two-dimensional array is constructed according to the first grid precision, so that the two-dimensional array contains the first number of two-dimensional array elements. Then, based on the position information contained in the initial fluid parameters of each grid, a one-to-one correspondence is constructed between the first number of grids and the first number of two-dimensional array elements. Based on the correspondence, the initial fluid parameters of the fluid sub-model in a grid with a position information (e.g., (x, y) coordinates) can be stored in the two-dimensional array element with the corresponding index value. For example, if the position coordinate of a certain grid is (3, 5), its corresponding position index is a[3][5] in the two-dimensional array a. Then the data value corresponding to a[3][5] is the initial fluid parameter of the fluid sub-model in the current simulation number.
[0074] It is understood that the initial velocity parameters of each grid can also be stored in a two-dimensional array, and the embodiments of this disclosure do not impose any special restrictions on this.
[0075] In this embodiment, the initial fluid parameters of each grid are stored by means of a one-to-one correspondence between the position information of each grid and the index value in the two-dimensional array, which can improve the efficiency of data storage and retrieval.
[0076] Based on the above embodiments, when responding to an adjustment operation for the first mesh precision and meshing the two-dimensional plane of the region to be simulated according to the adjusted second mesh precision, a two-dimensional array is constructed according to the second mesh precision to store the initial fluid parameters of the fluid sub-models in each mesh at the current iteration number into the two-dimensional array constructed based on the second mesh precision. In this regard, it is always ensured that the number of generated meshes is the same as the number of array elements in the created two-dimensional array.
[0077] In one optional embodiment of this disclosure, the initial fluid parameters in any of the above embodiments may include one or more of the following: the location information of the fluid sub-model in each grid, the ground height, the fluid direction, the fluid height, and the fluid pressure field parameters.
[0078] For example, the initial fluid parameters shown in any of the above embodiments may include the current position information of the fluid sub-model in each grid (e.g., the xy coordinates of the grid), surface height, fluid direction, fluid height, fluid pressure field parameters, and other single or multiple parameters.
[0079] To facilitate the storage and calculation of initial fluid parameters, the initial fluid parameters for each grid can be stored as tuples. Then, for each tuple, the corresponding fluid dynamics can be simulated simply by calculating the changes in the fluid information of that tuple. The initial fluid parameters for each tuple are as follows:
[0080] Position: Represents the position information of the fluid sub-model in each grid. In the two-dimensional plane, the position information of each grid is stored as (X,Y), and this position information can also be transformed into the world space position.
[0081] Height: Represents the surface height information in the tuple, that is, the height information brought to the fluid submodel in this grid based on the terrain;
[0082] Liquid_Velocity: Characterizes the fluid direction in each mesh's fluid sub-model;
[0083] Liquid_Height: Characterizes the fluid height of the fluid sub-model in each grid;
[0084] Liquid_Pressure: Characterizes the fluid pressure field of the fluid sub-model in each grid.
[0085] In this embodiment, the initial fluid data of each fluid sub-model in the current iteration is stored in a tuple structure, which facilitates the display of multiple attribute data of fluid information and provides convenience for the subsequent fluid parameter update process.
[0086] After obtaining the initial fluid parameters of the fluid sub-model in each grid at the current iteration number in step S201, step S202 can be executed to determine the physical quantity value of the physical force on the fluid sub-model in each grid based on the initial fluid parameters.
[0087] In one alternative embodiment, the physical force includes one or more of pressure, gravity, and externally applied force.
[0088] Pressure is determined by velocity parameters (e.g., flow velocity) of fluid sub-models in adjacent grids, while gravity can be determined based on the surface height and fluid height of each fluid sub-model in the grid. Externally applied forces can be generated by rigid body collisions between the external virtual model and the fluid sub-models. For example, a pebble (external virtual model) falling into water introduces an externally applied force, which then triggers rigid body collisions with other fluid sub-models to propagate velocity. The primary purpose of externally applied forces is to correct for the three-dimensional spatial influences that are absent in the two-dimensional fluid model.
[0089] In step 203, for the target grid among multiple grids, the target velocity parameters of the target grid at the current iteration number are determined based on the initial velocity parameters of the fluid sub-model in the target grid and the physical quantity values of the physical forces acting on the target grid.
[0090] For example, based on the initial velocity parameters of the fluid submodel in the target mesh and the physical quantities of the physical forces acting on the target mesh, the fluid velocity of the target mesh can be updated at the current iteration number.
[0091] First, combine Figure 4 The advection extrapolation process between fluid sub-models is illustrated by the following example:
[0092] Reference Figure 4 As shown in the diagram, when multiple adjacent grids have an initial velocity direction indicated by the solid arrow within the internal grid, the velocity converges in that direction, causing a pressure increase in that initial velocity direction. This, in turn, generates a corresponding pressure field on other grids, resulting in the velocity represented by the dashed line. In other words, during advection simulation, velocity affects the pressure field, and the pressure field, in turn, affects the fluid velocity.
[0093] Based on the above explanation, for fluids in planar space, for ease of calculation, we can assume that the fluid is a rigid body (i.e., assume that the fluid is an incompressible homogeneous fluid). The simulation of its dynamic fluid effect must follow the above advection derivation process, and then the above advection derivation process can be shown through the advection equation.
[0094] In one optional embodiment of this disclosure, the physical force includes at least pressure and externally applied force. The process of determining the target velocity parameter of the target mesh at the current iteration number based on the initial velocity parameter of the fluid submodel in the target mesh and the physical quantity value of the physical force acting on the target mesh may include: determining the advection velocity of the fluid submodel based on the initial velocity parameter of the fluid submodel in the target mesh; determining the diffusion velocity of the fluid submodel in the target mesh based on the advection velocity; determining the velocity of the fluid submodel in the target mesh under the action of the externally applied force based on the diffusion velocity; determining the pressure on the fluid submodel in the target mesh based on the velocity under the action of the externally applied force; and determining the target velocity parameter of the target mesh at the current iteration number based on the pressure and the velocity of the fluid submodel in the target mesh under the action of the externally applied force.
[0095] In other words, the above process can be logically represented as follows:
[0096] u1 = advect(u); Calculate the advect velocity of each fluid sub-model in the plane;
[0097] u2 = diffuse(u1); Calculates the diffusion velocity of each fluid sub-model in the plane;
[0098] u3 = addForces(u2); Calculate the velocity of each fluid sub-model under the action of externally applied forces;
[0099] p = computePressure(u3); Calculates the pressure field;
[0100] u4 = subtractPressureGradient(u3, p); Calculates the velocity under the negative pressure gradient field based on the velocity under the action of the pressure field and the external force, i.e. the target velocity parameter;
[0101] The parameters u1, u2, u3, and u4 mentioned above all represent the velocity field, p represents the pressure field, and the negative pressure gradient field is derived from the velocity field and pressure field calculated above to show the flow velocity of each fluid sub-model under the above physical forces.
[0102] The above process characterizes the simulation process of the fluid model at the current iteration number, achieving the simulation of three-dimensional fluid effects through a two-dimensional plane. Furthermore, the above code logic characterizes the advection equations that must be followed to simulate fluid dynamics.
[0103] In the fluid simulation process described above, iterative calculations are performed strictly according to the processing logic of the advection equation to ensure that the processing logic satisfies the advection equation; otherwise, the calculation method for the advection equation will not be satisfied. Furthermore, the advection and diffusion terms of each fluid sub-model are mandatory terms in the Poisson equation.
[0104] In one optional embodiment of this disclosure, the total pressure value of the fluid model is kept constant by a preset pressure value, which is determined by the surface tension coefficient of each fluid sub-model.
[0105] For example, while the pressure field changes within the fluid model, the total pressure value of the overall fluid model in the system must always remain within a preset pressure value, and the total pressure value can be determined based on the viscosity of the fluid sub-model, i.e., the surface tension coefficient.
[0106] It should be explained that the surface tension coefficient σ is the partial derivative of the Gibbs free energy G with respect to the area S, assuming constant temperature T and pressure p. The unit of Gibbs free energy is energy, therefore the unit of the surface tension coefficient is energy / area. The force that causes the surface of a liquid (i.e., fluid) to contract is called surface tension.
[0107] Regarding externally applied forces, in step 202 above, when determining the physical quantity of the physical force exerted on the fluid sub-model in each grid based on the initial fluid parameters, the quantity of the externally applied force can be calculated based on the surface height and fluid height included in the initial fluid parameters, as well as the source externally applied force.
[0108] In an optional embodiment of this disclosure, the sum of the surface height and fluid height of the first target grid is determined to obtain a first height sum; the sum of the surface height and fluid height of the second target grid is determined to obtain a second height sum; if the first height sum is equal to the second height sum, and the third height sum is less than the second height sum, the gravity value between the second target grid and the third target grid is determined, so as to determine the amount of externally applied force transmitted from the second target grid to the third target grid for each fluid sub-model based on the gravity value; the third height sum is the sum of the surface height and fluid height of the third target grid; the distance between the first target grid and the source externally applied force is minimized.
[0109] For example, when the first height of the first target grid is equal to the second height of the second target grid, the pressure values of each grid between the first and second target grids are equal. Based on the principles of advection and diffusion, the external force applied to the second target grid will continue to be transmitted outward until it encounters the third target grid at a third height and a lower third target grid.
[0110] At this point, the gravitational potential energy can be determined based on the height difference between the second and third target grids, so that the gravitational potential energy can be converted into the flow velocity of each fluid sub-model according to Newton's theorem, thereby realizing the velocity conversion when the fluid surface falls.
[0111] For ease of understanding, the following will combine Figure 5A , Figure 5BThe process of determining the external applied force and pressure in the above embodiments will be described in order to determine the velocity parameters of each grid target in step 203 based on the determined external applied force and pressure values.
[0112] Figure 5A This schematically illustrates the physical force transformation under fluid data between meshes in the first exemplary embodiment of this invention, with reference to... Figure 5A As shown, for the three grid points Sv1, Sv2, and Sv3 shown in the figure, when Figure 5A The part shown is subjected to an external force S, where the external force is the source of the external force, and the direction indicated by the arrow is the direction of fluid flow.
[0113] Under the action of the externally applied force S, since the liquid surface satisfies the condition that d2+h2=d1+h1 is equal, it can be understood that at the current height, the surface pressure of the water body in each grid between the first and second target grids is equal. The externally applied force on Sv2 will continue to affect the fluid in other ranges according to the advection formula (e.g., referring to Poisson's equation). Based on the transmission of the externally applied force, when the fluid flows to Sv1 and Sv3, d3+h3≠d1+h1, that is, the liquid surface is not at the same height. In this case, according to Newton's law, the potential energy mgh between the second and third target grids (where h is the height difference between the second and third target grids) will be equivalently converted into kinetic energy, i.e., 1 / 2mv. 2 That is, based on the aforementioned potential energy, it can be calculated that when the liquid surface falls, the subsequent velocity conversion also satisfies Newton's laws. Furthermore, since the tuple information retains the fluid height d1, as well as the magnitude range of each fluid parameter in the tuple, and the viscosity of the liquid (i.e., the surface tension coefficient), the externally applied force V1 transmitted by the fluid in the Sv3 direction can be obtained.
[0114] In another optional embodiment of this disclosure, if the first height is less than or equal to the second height, the magnitude of the external force applied to the fluid submodel of each grid between the first target grid and the second target grid is based on the surface between the first target grid and the second target grid.
[0115] Among them, the first target grid is the smallest in distance from the external force applied to the source.
[0116] For example, if the first height of the first target grid is less than the second height of the second target grid, then there is a surface slope between the first target grid and the second target grid, and the surface height pushes the fluid sub-model inward, i.e., the support force, and the externally applied force F outward = F inward at this location.
[0117] For a two-dimensional plane, the externally applied force F is in two-dimensional space. However, the surface has a slope and is not vertical. Therefore, the force F should be decomposed into an upward support force and an inward support force to obtain the internal support force F as the magnitude of the externally applied force of the fluid sub-model of each grid between the first target grid and the second target grid.
[0118] exist Figure 5A Based on the indicated surface elevation, Figure 5B This schematically illustrates the physical force transformation under fluid data between meshes in the second exemplary embodiment of this invention, with reference to... Figure 5B As shown, for the grid points Sv1 (the second target grid) and Sv2 (the first target grid) shown in the figure, when the page height of the Sv2 grid is k2, the corresponding liquid surface height of the Sv2 grid is k2+h2. At this time, there exists d1+h1>k2+h2. In this case, the surface slope pushes the fluid sub-model inward, that is, an external force F is applied, and the force F acting outward at this position is equal to F acting inward.
[0119] However, it is worth noting that as a planar fluid, we should focus on the force F in 2-dimensional space. However, our mountain has a slope and is not vertical. Therefore, the externally applied force F should be decomposed into an upward externally applied force F1 and an inward externally applied force F2. The output externally applied force is the inward externally applied force F2.
[0120] In this regard, after determining the magnitude of the externally applied force for each grid based on the above embodiments, step 203 can be executed to obtain the target velocity parameters for each grid based on the initial velocity parameters of each grid and the velocity conversion caused by the externally applied force.
[0121] Furthermore, for physical forces that at least include pressure, the initial fluid parameters include at least surface height and fluid height. In this regard, when performing step 202 above, in an optional embodiment of this disclosure, the sum of the surface height and fluid height of the fourth target grid is determined to obtain the fourth height sum; the sum of the surface height and fluid height of the fifth target grid is determined to obtain the fifth height sum; if the fourth height sum is greater than the fifth height sum, and the distance between the fourth target grid and the externally applied force is the smallest, then a first pressure value is provided to the fourth target grid based on the externally applied force, and the first pressure value is transmitted to the fifth target grid.
[0122] For example, when the distance between the fourth target grid and the externally applied force is minimal, if the sum of the fourth and fifth heights is greater than the sum of the fifth heights (i.e., the surface heights are different), the corresponding fluid surface heights will also be different, and the corresponding fluid pressures will also be different. Due to the communicating vessel effect of the fluid, and assuming the external pressure is constant, the internal fluid pressure of the fourth target grid will increase under the force applied from the external source, thereby continuously increasing the pressure of the surrounding fifth target grid.
[0123] Figure 6 This schematically illustrates the physical force transformation under fluid data between meshes in the third exemplary embodiment of this invention; see reference. Figure 6 As shown, the Sv1 mesh is the fourth target mesh, and the Sv3 mesh is the fifth target mesh. Correspondingly, when in... Figure 6 When an external force S1 is applied at the indicated location, additional pressure is provided by the external force S1, which continuously increases the pressure of the surrounding fourth target grid to obtain only the first pressure value. While transmitting the first pressure value to the Sv3 grid, the first pressure value is also transmitted due to gravity.
[0124] In some other example embodiments of this disclosure, if the fourth height is less than the fifth height and the distance between the fifth target grid and the externally applied force is the smallest, then a second pressure value is provided to the fourth target grid based on the externally applied force, and a third pressure value is provided to the fourth target grid from the fifth target grid.
[0125] Continue to refer to Figure 7 As shown, the externally applied force S2 is closest to the fifth target grid, and its pressure change will be transmitted to Sv3, which has the same liquid level height d3. Since d2 + h2 = d3 + h3, the pressure between Sv3 and Sv2 is equal, both being the second pressure value. However, since the liquid level height (d1 + h1) of Sv1 (the fourth target grid) exists, it means that there is a higher pressure at point Sv1. Therefore, the pressure cannot continue to be transmitted to Sv1. Instead, the pressure is transmitted from Sv1 to the fifth target grids such as Sv3 or Sv2 to provide the third pressure value.
[0126] In another optional embodiment of this disclosure, if the fourth height sum equals the fifth height sum, and the distance between the fourth target grid and the externally applied force is the smallest, then a fourth pressure value is provided to the fourth target grid based on the externally applied force, and the fourth pressure value is transmitted to the fifth target grid, and the total pressure value of the fourth target grid is equal to the total pressure value of the fifth target grid.
[0127] For example, since the liquid level is the same, the total pressure value of the fourth target grid is equal to the total pressure value of the fifth target grid, both of which are the fourth pressure value.
[0128] Figure 6 This schematically illustrates the physical force transformation under fluid data between meshes in the third exemplary embodiment of this invention; see reference. Figure 6 As shown, Sv1 grid is the fourth target grid and Sv3 grid is the fifth target grid. Regardless of whether the distance between the external source and the fourth target grid is the smallest or the distance between the external source and the fifth target grid is the smallest, the total pressure value of the fourth target grid can be equal to the total pressure value of the fifth target grid.
[0129] It should be explained that even if there is an obstruction between the Sv1 and Sv2 meshes, the pressure of the liquid remains consistent.
[0130] Using the above method, height information can be converted into two-dimensional influence coefficients of the actual fluid. These influence coefficients are then used to correct the fluid and velocity parameters in the actual tuple. Subsequently, the fluid dynamics are simulated by reading the information within the tuple.
[0131] It should be explained that, in solving the Poisson pressure equation, the divergence of the effect of pressure on the actual fluid surface can be calculated based on the position coordinates of each grid.
[0132] In step S204, based on the target velocity parameters of the fluid sub-models in each grid at different iteration numbers, the fluid dynamics effect of the fluid model in the region to be simulated is generated.
[0133] For example, by calculating the target velocity parameters of the fluid sub-model in each grid at different iterations based on the above embodiments, the fluid dynamics of the fluid model in the region to be simulated can be simulated.
[0134] To implement the above-described fluid simulation method, one embodiment of this disclosure provides a fluid simulation apparatus. Figure 8 A schematic diagram of the fluid simulation device is shown.
[0135] The fluid simulation device 800 includes a fluid parameter acquisition module 801, a physical quantity value determination module 802, a velocity parameter determination module 803, and a fluid simulation module 804.
[0136] The fluid parameter acquisition module 801 is used to acquire the initial fluid parameters of multiple grids in the region to be simulated; the magnitude determination module 802 is used to determine the magnitude of the physical force corresponding to each grid in the first simulation based on the initial fluid parameters of multiple grids; the velocity parameter determination module 803 is used to acquire the initial velocity parameters of the fluid corresponding to the target grid in the second simulation for the target grid among multiple grids, and determine the target velocity parameters of the target grid in the first simulation based on the initial velocity parameters and the magnitude of the physical force of the target grid in the first simulation; the fluid simulation module 804 is used to simulate the dynamic effects of the fluid based on the target velocity parameters of each grid in the region to be simulated in the first simulation.
[0137] In an optional embodiment of this disclosure, the device may further include a mesh processing module and an array construction module. The mesh processing module is used to obtain a two-dimensional plane of the region to be simulated and to mesh the two-dimensional plane according to a first mesh precision to obtain multiple meshes for the two-dimensional plane. The array construction module is used to construct a two-dimensional array according to the first mesh precision and to store the initial fluid parameters of the fluid sub-model in each mesh at the current iteration number into the two-dimensional array so as to obtain the initial fluid parameters of each mesh from the two-dimensional array.
[0138] In an optional embodiment of this disclosure, the initial fluid parameters of each grid include at least the position information of each grid. An array construction module is used to construct a one-to-one correspondence between the position information of each grid and the index value in the two-dimensional array. According to the correspondence, the initial fluid parameters in each grid are stored in the two-dimensional array element with the corresponding index value.
[0139] In an optional embodiment of this disclosure, the apparatus may further include a precision adjustment module for meshing the two-dimensional plane of the region to be simulated according to the adjusted second mesh precision in response to an adjustment operation for the first mesh precision; and an array construction module for constructing a two-dimensional array according to the second mesh precision to store the initial fluid parameters of the fluid sub-models in each mesh at the current iteration number into the two-dimensional array.
[0140] In one optional embodiment of this disclosure, the initial fluid parameters include one or more of the following: location information of the fluid sub-model in each grid, surface height, fluid direction, fluid height, and fluid pressure field parameters.
[0141] In an optional embodiment of this disclosure, the initial fluid parameters include at least surface height and fluid height; the physical quantity determination module 802 is used to determine the sum of the surface height and fluid height of the first target grid to obtain a first height sum; determine the sum of the surface height and fluid height of the second target grid to obtain a second height sum; if the first height sum is equal to the second height sum, and the third height sum is less than the second height sum, determine the gravity value between the second target grid and the third target grid, so as to determine the amount of externally applied force transmitted from the second target grid to the third target grid for each fluid sub-model based on the gravity value; the third height sum is the sum of the surface height and fluid height of the third target grid; or, the physical quantity determination module 802 is used to determine the amount of externally applied force to the fluid sub-model of each grid between the first target grid and the second target grid based on the surface between the first target grid and the second target grid if the first height sum is less than the second height sum and they are not equal; wherein, the distance between the first target grid and the source externally applied force is the smallest.
[0142] In an optional embodiment of this disclosure, the initial fluid parameters include at least surface height and fluid height, and the physical force includes at least pressure. The physical quantity determination module 802 is used to determine the sum of the surface height and fluid height of the fourth target grid to obtain a fourth height sum; determine the sum of the surface height and fluid height of the fifth target grid to obtain a fifth height sum; if the fourth height sum is greater than the fifth height sum, and the distance between the fourth target grid and the externally applied force is minimal, then a first pressure value is provided to the fourth target grid based on the externally applied force, and the first pressure value is transmitted to the fifth target grid; or, the physical quantity determination module 802 is used to provide a second pressure value to the fifth target grid based on the externally applied force if the fourth height sum is greater than the fifth height sum, and the distance between the fifth target grid and the externally applied force is minimal, and the fourth target grid provides a third pressure value to the fifth target grid.
[0143] In an optional embodiment of this disclosure, the magnitude determination module 802 can also be used to provide a fourth pressure magnitude to the fourth target grid based on the external force applied from the source if the fourth height sum equals the fifth height sum and the distance between the fourth target grid and the external force applied from the source is the smallest, and to transmit the fourth pressure magnitude to the fifth target grid, wherein the total pressure magnitude of the fourth target grid is equal to the total pressure magnitude of the fifth target grid.
[0144] In an optional embodiment of this disclosure, the velocity parameter determination module 803 is used to determine the advection velocity of the fluid submodel in the target mesh based on the initial velocity parameters of the fluid submodel in the target mesh; determine the diffusion velocity of the fluid submodel in the target mesh based on the advection velocity; determine the velocity of the fluid submodel in the target mesh under the action of an externally applied force based on the diffusion velocity; determine the pressure on the fluid submodel in the target mesh based on the velocity under the action of the externally applied force; and determine the target velocity parameter of the target mesh at the current iteration number based on the pressure and the velocity of the fluid submodel in the target mesh under the action of the externally applied force.
[0145] In one optional embodiment of this disclosure, the total pressure value of the fluid model is kept constant by a preset pressure value, which is determined by the surface tension coefficient of each fluid sub-model.
[0146] The fluid simulation device 800 provided in this embodiment can execute the technical solution of the fluid simulation method in any of the above embodiments. Its implementation principle and beneficial effects are similar to those of the fluid simulation method. Please refer to the implementation principle and beneficial effects of the fluid simulation method. It will not be repeated here.
[0147] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the present invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the present invention described in the "Exemplary Methods" section above.
[0148] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0149] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0150] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0151] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, radio frequency (RF), or any suitable combination thereof.
[0152] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0153] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided.
[0154] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: entirely in hardware, entirely in software (including firmware, microcode, etc.), or in a combination of hardware and software, collectively referred to herein as “circuit,” “module,” or “system.”
[0155] The following reference Figure 9 To describe an electronic device 900 according to this embodiment of the present invention. Figure 9 The electronic device 900 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0156] like Figure 9 As shown, the electronic device 900 is presented in the form of a general-purpose computing device. The components of the electronic device 900 may include, but are not limited to: at least one processing unit 910, at least one storage unit 920, a bus 930 connecting different system components (including storage unit 920 and processing unit 910), and a display unit 940.
[0157] The storage unit stores program code, which can be executed by the processing unit 910 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 910 can execute... Figure 2 Steps S201 to S204 are shown in the figure.
[0158] Storage unit 920 may include readable media in the form of volatile storage units, such as random access memory (RAM) 9201 and / or cache memory 9202, and may further include read-only memory (ROM) 9203.
[0159] The storage unit 920 may also include a program / utility 9204 having a set (at least one) program module 9205, such program module 9205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0160] Bus 930 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0161] Electronic device 900 can also communicate with one or more external devices 1000 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 900, and / or with any device that enables electronic device 900 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 950. Furthermore, electronic device 900 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 960. As shown, network adapter 960 communicates with other modules of electronic device 900 via bus 930. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems.
[0162] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0163] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0164] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0165] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0166] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is defined only by the appended claims.
Claims
1. A fluid simulation method, characterized in that, include: A two-dimensional plane of the region to be simulated is obtained, and the two-dimensional plane is meshed according to a first mesh precision to obtain multiple meshes for the two-dimensional plane; A two-dimensional array is constructed based on the first grid precision, and the initial fluid parameters of the fluid sub-model in each grid at the current iteration number are stored in the two-dimensional array; In response to the adjustment operation for the first mesh precision, the two-dimensional plane of the region to be simulated is meshed according to the adjusted second mesh precision; and a two-dimensional array is constructed according to the second mesh precision to store the initial fluid parameters of the fluid sub-model in each mesh at the current iteration number into the two-dimensional array; The initial fluid parameters and initial velocity parameters of each fluid sub-model in the grid of the region to be simulated at the current iteration number are obtained from the two-dimensional array. The initial fluid parameters and the initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number of the current iteration number. Based on the initial fluid parameters, determine the physical quantities of the physical forces acting on the fluid sub-models in each grid; For each target grid, based on the initial velocity parameters of the fluid sub-model in the target grid and the physical quantity of the physical force acting on the target grid, the target velocity parameters of the target grid at the current iteration number are determined. Based on the target velocity parameters of the fluid sub-models in each grid at each iteration number, the fluid dynamics effect of the fluid model in the region to be simulated is generated.
2. The method according to claim 1, characterized in that, The initial fluid parameters of each grid include at least the position information of each grid. The step of storing the initial fluid parameters of the fluid sub-model in each grid at the current iteration number into the two-dimensional array includes: Establish a one-to-one correspondence between the position information of each grid and the index value in the two-dimensional array; According to the aforementioned correspondence, the initial fluid parameters in each grid are stored in the corresponding index value of the two-dimensional array element.
3. The method according to any one of claims 1 to 2, characterized in that, The initial fluid parameters include one or more of the following: the location information of the fluid sub-model in each grid, surface height, fluid direction, fluid height, and fluid pressure field parameters.
4. The method according to claim 1, characterized in that, The initial fluid parameters include at least the surface height and the fluid height; determining the physical quantities of the physical forces acting on the fluid sub-models in each grid based on the initial fluid parameters includes: Determine the sum of the surface height and fluid height of the first target grid to obtain the first height sum; Determine the sum of the surface height and fluid height of the second target grid to obtain the second height sum; If the first height sum is equal to the second height sum, and the third height sum is less than the second height sum, the gravity value between the second target grid and the third target grid is determined, so as to determine the amount of externally applied force transmitted from the second target grid to the third target grid for each fluid sub-model based on the gravity value; the third height sum is the sum of the surface height and the fluid height of the third target grid; Alternatively, if the first height sum is less than the second height sum, then based on the surface between the first target grid and the second target grid, the magnitude of the external force applied to the fluid submodel of each grid between the first target grid and the second target grid; Among them, the first target mesh is the smallest in distance from the external force applied by the source.
5. The method according to claim 1, characterized in that, The initial fluid parameters include at least surface height and fluid height, and the physical forces include at least pressure; determining the physical quantity values of the physical forces acting on the fluid sub-model in each grid based on the initial fluid parameters includes: Determine the sum of the surface height and fluid height of the fourth target grid to obtain the fourth height sum; Determine the sum of the surface height and fluid height of the fifth target grid to obtain the fifth height sum; If the sum of the fourth heights is greater than the sum of the fifth heights, and the distance between the fourth target grid and the externally applied force is the smallest, then a first pressure value is provided to the fourth target grid based on the externally applied force, and the first pressure value is transmitted to the fifth target grid. Alternatively, if the fourth height sum is greater than the fifth height sum, and the distance between the fifth target grid and the externally applied force is the smallest, then a second pressure value is provided to the fifth target grid based on the externally applied force, and a third pressure value is provided to the fifth target grid by the fourth target grid.
6. The method according to claim 5, characterized in that, The method further includes: If the sum of the fourth heights equals the sum of the fifth heights, and the distance between the fourth target grid and the externally applied force is minimized, then a fourth pressure value is provided to the fourth target grid based on the externally applied force, and the fourth pressure value is transmitted to the fifth target grid. The total pressure value of the fourth target grid is equal to the total pressure value of the fifth target grid.
7. The fluid simulation method according to claim 1, characterized in that, The physical forces include at least pressure and externally applied forces. Determining the target velocity parameters of the target mesh at the current iteration number, based on the initial velocity parameters of the fluid submodel in the target mesh and the physical quantities of the physical forces acting on the target mesh, includes: Based on the initial velocity parameters of the fluid sub-model in the target mesh, the advection velocity of the fluid sub-model is determined; Based on the advection velocity, determine the diffusion velocity of the fluid sub-model in the target mesh; Based on the diffusion rate, determine the velocity of the fluid sub-model in the target mesh under the applied external force; The pressure exerted on the fluid sub-model in the target mesh is determined based on the velocity under the applied external force. Based on the pressure and the velocity of the fluid sub-model in the target mesh under the applied external force, the target velocity parameters of the target mesh at the current iteration number are determined.
8. The method according to claim 7, characterized in that, The total pressure value of the fluid model remains unchanged at a preset pressure value, which is determined by the surface tension coefficient of each fluid sub-model.
9. A fluid simulation device, characterized in that, The device includes: The mesh processing module is used to obtain a two-dimensional plane of the region to be simulated, and to mesh the two-dimensional plane according to a first mesh precision to obtain multiple meshes for the two-dimensional plane; the array construction module is used to construct a two-dimensional array according to the first mesh precision, and to store the initial fluid parameters of the fluid sub-model in each mesh at the current iteration number into the two-dimensional array; The precision adjustment module is used to perform meshing of the two-dimensional plane of the region to be simulated according to the adjusted second mesh precision in response to the adjustment operation for the first mesh precision; the array construction module is also used to construct a two-dimensional array according to the second mesh precision, so as to store the initial fluid parameters of the fluid sub-model in each mesh at the current iteration number into the two-dimensional array; The fluid parameter acquisition module is used to acquire the initial fluid parameters of the fluid sub-models in each grid of the simulated region at the current iteration number and the initial velocity parameters at the current iteration number from the two-dimensional array. The initial fluid parameters and the initial velocity parameters are parameter data obtained by each fluid sub-model based on the previous iteration number of the current iteration number. The physical quantity determination module is used to determine the physical quantity values of the physical forces acting on the fluid sub-model in each grid based on the initial fluid parameters. The velocity parameter determination module is used to determine the target velocity parameters of the target mesh at the current iteration number, based on the initial velocity parameters of the fluid sub-model in the target mesh and the physical quantity values of the physical forces acting on the target mesh. The fluid simulation module is used to generate the fluid dynamics of the fluid model in the region to be simulated based on the target velocity parameters of the fluid sub-models in each grid at each iteration number.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the fluid simulation method according to any one of claims 1 to 8.
11. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the fluid simulation method according to any one of claims 1 to 8 by executing the executable instructions.
Citation Information
Patent Citations
Fluid mechanics simulation method and device and computer readable storage medium
CN112613243A
Lattice Boltzmann fluid animation simulation method based on implicit particle interpolation
CN117475040A