A fluid simulation method based on GPU octree acceleration and SPH algorithm

By combining octree traversal and the SPH algorithm in the GPU, the problem of excessive CPU load is solved, the frame rate of fluid simulation is improved, and efficient water particle simulation is achieved.

CN115438600BActive Publication Date: 2026-02-17GUILIN UNIV OF ELECTRONIC TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211111028.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-13
Publication Date
2026-02-17
Estimated Expiration
2042-09-13

AI Technical Summary

Technical Problem

The octree algorithm in the existing SPH algorithm performs tree construction and traversal on the CPU, which increases the CPU load and results in a lower frame rate.

Method used

A fluid simulation method based on GPU octree acceleration and SPH algorithm is adopted. The coordinates of water particles are generated by initializing the DirectX rendering pipeline in the CPU, and a linear octree is built in the CPU. The coordinates and tree are passed to the GPU for depth-first traversal. The parallel computing capability of the GPU is used to search for nearest water particles, and the rendering is performed in the CPU.

Benefits of technology

It reduces CPU load, increases overall frame rate, reduces the limitation of frame rate on the number of water particles, and leverages the parallel computing advantages of the GPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115438600B_ABST
    Figure CN115438600B_ABST
Patent Text Reader

Abstract

The application discloses a fluid simulation method based on GPU octree acceleration and SPH algorithm, in order to reduce the load of the CPU and place the traversal of the octree in the GPU, the traditional octree algorithm is improved, a linear table is used to store the nodes of the octree, a pointer is replaced by an index in the linear table, so that the pointer can still be used when being transmitted into the GPU, the pointer does not need to be relocated, and an iteration method with O(1) space complexity is proposed to realize the traversal of the octree, the powerful parallel computing capacity of the GPU is utilized, and the performance advantage of the octree in the near neighbor search algorithm is also utilized, after the GPU and the linear octree are accelerated, the overall frame rate is greatly reduced due to the limitation of the number of water particles, and the load of the CPU is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of water particle simulation technology, specifically to a fluid simulation method based on GPU octree acceleration and SPH algorithm. Background Technology

[0002] In computer graphics, natural scene simulation, especially fluid simulation, is widely used in many real-world fields, including scientific research, film and television special effects, computer games, disaster rescue, science education, sports competitions, and military simulation. Currently, the mainstream methods for fluid simulation are mainly divided into two categories: the Eulerian method and the Lagrangian method. The main idea of ​​the Eulerian method is to divide the fluid into independent cell grids and calculate the physical quantities in each grid separately, thereby calculating the positional changes of the entire water-fluid system. The Eulerian method has high accuracy; if the grid accuracy is high enough, it can almost perfectly reproduce many details of liquid flow. However, the Eulerian method has low computational efficiency and high resource consumption, making it difficult to apply in practical engineering with current computing power. The Lagrangian method, as a meshless method, treats each water particle as the research object, calculating the physical quantities of each water particle separately, and calculating the influence of other water particles in the domain on the current water particle, ultimately calculating the positional changes of each water particle. Smoothed Particle Hydrodynamics (SPH) is one such example. The basic idea of ​​the SPH algorithm is to describe a continuous fluid using a group of interacting particles, each carrying various physical quantities, including mass and velocity. By solving the dynamic equations of the particle group and tracking the trajectory of each particle, the mechanical behavior of the entire system is obtained. In the search for nearest neighbor particles in the SPH algorithm, the octree algorithm is commonly used. However, conventional octree algorithms involve building and traversing the tree on the CPU, which significantly increases the CPU load. As the number of water particles increases, the search time for nearest neighbor particles increases dramatically, resulting in a lower frame rate. Summary of the Invention

[0003] The present invention aims to solve the problem that the octree algorithm in the existing SPH algorithm requires the CPU to build and traverse the tree, thereby increasing the CPU load and causing a low frame rate. It provides a fluid simulation method based on GPU octree acceleration and SPH algorithm.

[0004] To solve the above problems, the present invention is achieved through the following technical solution:

[0005] A fluid simulation method based on GPU octree acceleration and SPH algorithm includes the following steps:

[0006] Step S1: Initialize the DirectX rendering pipeline;

[0007] Step S2: Use the CPU to randomly generate the coordinates of water particles within a preset range;

[0008] Step S3: In the CPU, establish a linear octree based on the coordinates of the water particles;

[0009] Step S4: Transfer the coordinates of the water particles and the linear octree from the CPU to the GPU.

[0010] Step S5: Traverse the linear octree in depth-first order in the GPU to detect the nearest neighbor water particles of the query water particles.

[0011] Step S6: Return the coordinates of the water particles from the GPU to the CPU;

[0012] Step S7: Apply a rendering scheme to color the water particles in the CPU.

[0013] In step S2 above, the coordinates of the randomly generated water particles are located within a cube within a preset range of [-10, 10].

[0014] The specific process of step S3 above is as follows:

[0015] Step S3.1: Calculate the center coordinates of the bounding box formed by all water particles, as well as the length, width and height of the bounding box, based on the coordinates of all water particles.

[0016] Step S3.2: Create an empty linear octree; define each node of the linear octree as pointing to a cube of three-dimensional space, and each child node is obtained by subdividing the parent node into three-dimensional spaces; subdividing the parent node into three-dimensional spaces means using the center coordinates of the three-dimensional space pointed to by the parent node as the origin of the three-dimensional coordinate system, and using the X-axis, Y-axis, and Z-axis as dividing lines to evenly divide the three-dimensional space of the parent node into 8 sub-three-dimensional spaces of equal size. These sub-three-dimensional spaces are the three-dimensional spaces pointed to by the child nodes; use a linear list to store the nodes of the linear octree, where the node index is the current node's index in the linear list, and each node stores the index of the parent node and the indexes of all child nodes to realize the return of the root node and the traversal of the subtree;

[0017] Step S3.3: Insert a root node into an empty octree. The center coordinates and length, width and height of the root node are the center coordinates and length, width and height of the bounding box. Mark the root node as a node that does not contain water particles.

[0018] Step S3.4: Iterate through each water particle, obtain the coordinates of the current water particle, and perform the following operations;

[0019] Step S3.4.1: Traverse the linear octree starting from the root node:

[0020] If the current node is a non-leaf node of a linear octree, then the positional relationship between the coordinates of the current water particle and the center coordinates of the current node determines which child node the current water particle should be placed in, and S3.4.1 continues to be executed.

[0021] If the current node is a leaf node of a linear octree, then proceed to step S3.4.2;

[0022] Step S3.4.2: Determine whether the current node contains water particles:

[0023] If the current node does not contain water particles, then the current water particle is placed into the current leaf node;

[0024] If the current node contains water particles, remove the original water particles from the current node and subdivide the current node into three-dimensional space. After subdivision, determine which child node the original water particles should be placed in based on the positional relationship between the original water particles in the current node and the center of the leaf node. At the same time, determine which child node the current water particles should be placed in based on the positional relationship between the coordinates of the current water particles and the center coordinates of the current node. If the original water particles and the current water particles are still in the same child node, then treat that child node as the current node and repeat step S3.4.2. If the original water particles and the current water particles are not in the same child node, then continue to execute step 3.4.

[0025] In step S4 above, in the GPU, the coordinates of water particles are input using the SRV buffer in the DirectX11 framework and output using the UAV buffer in the DirectX11 framework; the linear octree is stored using the SRV buffer.

[0026] The specific process of step 5 above is as follows:

[0027] Step S5.1: Create two temporary variables to store the currently accessed node and the previously accessed node, respectively;

[0028] Step S5.2: Access the root node;

[0029] Step S5.3: If the currently visited node is a child node of the previously visited node or the previously visited node is empty, it means that the currently visited node has not been visited yet, and jump to step S5.4; if the currently visited node is the parent node of the previously visited node, it means that the previously visited node and its subtrees have been visited, and jump to step S5.6.

[0030] Step S5.4: If the currently visited node is a leaf node, it means that the currently visited node stores water particle information, and jump to step S5.5; if the currently visited node is a non-leaf node, it means that the currently visited node stores tree trunk information, and jump to step S5.6.

[0031] Step S5.5: Determine whether the coordinates of the water particle in the currently visited node are within the scope of the query water particle. If yes, determine that the water particle in the currently visited node is the immediate neighbor of the query water particle. Calculate the coordinates of the query water particle based on the SPH formula and the immediate neighbor. After the calculation, visit the parent node of the currently visited node and jump to step S5.3. If the coordinates of the water particle in the currently visited node are not within the scope of the query water particle, jump to step S5.3.

[0032] Step S5.6: If the currently visited node has unvisited child nodes, then visit the unvisited child nodes; if the currently visited node has no unvisited child nodes and the parent node of the currently visited node is not empty, then visit the parent node of the currently visited node and jump to step S5.3; if the currently visited node has no unvisited child nodes and the parent node of the currently visited node is empty, then the linear octree traversal is complete, and jump to step S6.

[0033] In step S5.1 above, when using a temporary variable CurrentNode to store the currently visited node and a temporary variable LastNode to store the previously visited node, the parent-child relationship between the two nodes can be used to represent different stages of the current linear octree traversal:

[0034] If the last visited node stored in the temporary variable LastNode is the parent node of the currently visited node stored in the temporary variable CurrentNode, then the current stage is the stage of traversing the child nodes of the last visited node stored in the temporary variable LastNode.

[0035] If the previously visited node stored in the temporary variable LastNode is a child node of the currently visited node stored in the temporary variable CurrentNode, it means that all the child nodes of the previously visited node stored in the temporary variable LastNode have been visited, and the next child node of the currently visited node stored in CurrentNode should be visited.

[0036] If the last visited node stored in LastNode is the last child node of the currently visited node stored in CurrentNode, it means that all child nodes of the currently visited node stored in CurrentNode have been traversed, and the other child nodes of the parent node of the currently visited node stored in CurrentNode should be traversed.

[0037] The depth-first traversal of the linear octree ends when the currently visited node stored in CurrentNode is the parent node of the root node, and the previously visited node stored in LastNode is the root node.

[0038] In step 7 above, the screen space fluid rendering scheme is used in the CPU to color the water particles.

[0039] Compared with existing technologies, this invention improves the traditional octree algorithm by reducing the CPU load and placing the octree traversal in the GPU. It uses a linear list to store the octree nodes, replaces the pointers with the indices in the linear list so that they are still usable when passed to the GPU without the need for pointer relocation, and proposes an iterative method with O(1) space complexity to traverse the octree. This not only utilizes the powerful parallel computing capabilities of the GPU, but also leverages the performance advantages of the octree in the nearest neighbor search algorithm. After acceleration by the GPU and the linear octree, the overall frame rate is significantly reduced due to the limitation of the number of water particles, and the CPU load is reduced to a large extent. Attached Figure Description

[0040] Figure 1 This is an octree traversal flowchart for a fluid simulation method based on GPU octree acceleration and the SPH algorithm. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific examples.

[0042] To reduce the CPU (Central Processing Unit) load, this invention proposes to perform octree traversal on the GPU (Graphics Processing Unit). However, traversing an octree on the GPU presents the following technical difficulties: In conventional octree algorithms, nodes are often stored as pointers. In GPU computation, the CPU must allocate a single block of memory for GPU operation. This situation typically presents two solutions: First, the CPU completes the search for adjacent water particles and passes the corresponding node indices to the GPU. This method has several drawbacks: the octree query operation, which should be parallel, is now performed on the CPU, significantly increasing latency. Furthermore, the size of the array of adjacent water particle indices changes with each frame, leading to changes in the overall memory size, making memory block reuse impossible and data alignment within the array difficult to control. Second, all nodes are copied to the same memory block during memory allocation, and then pointers are relocated. This method avoids searching the tree on the CPU, but inevitably increases the time required for pointer relocation and the space occupied by temporary memory blocks. To address this, this invention improves the traditional octree algorithm by using a linear list to store the octree nodes and replacing pointers with indices in the linear list, ensuring its usability when passed to the GPU without requiring pointer relocation. Furthermore, GPUs often only perform simple data calculations and cannot allocate memory. Due to the efficiency-driven nature of the HLSL high-level language, all functions in HLSL are inline, making recursive function syntax impossible. This creates a bottleneck when traversing the octree. Common methods for traversing trees include recursive and iterative traversal. Iterative traversal often requires a stack or queue, but these methods are clearly impractical due to the limitations of HLSL. Therefore, this invention proposes an iterative method with O(1) space complexity to traverse the octree.

[0043] In summary, the fluid simulation method proposed in this invention, based on GPU octree acceleration and the SPH algorithm, uses the SPH algorithm in the water particle simulation stage and leverages linear octrees for GPU parallel computation acceleration. The rendering process utilizes the SSF rendering scheme, and the specific steps are as follows:

[0044] Step S1: Initialize the DirectX rendering pipeline.

[0045] Step S2: Use the CPU to randomly generate the coordinates of water particles within a preset range.

[0046] In a preferred embodiment of the present invention, the coordinates of the water particles are randomly within a cube ranging from [-10, 10].

[0047] Step S3: In the CPU, a linear octree is established based on the coordinates of the water particles. The specific process is as follows:

[0048] Step S3.1: Calculate the center coordinates of the bounding box formed by all water particles, as well as the length, width and height of the bounding box, based on the coordinates of all water particles.

[0049] Step S3.2: Create an empty linear octree. Define each node of the linear octree as pointing to a three-dimensional cube, and each child node is obtained by subdividing the parent node into three-dimensional spaces. Subdividing the parent node into three-dimensional spaces means using the center coordinates of the three-dimensional space pointed to by the parent node as the origin, and using the X, Y, and Z axes as dividing lines to evenly divide the parent node's three-dimensional space into 8 equal-sized sub-three-dimensional spaces. These sub-three-dimensional spaces are the three-dimensional spaces pointed to by the child nodes. Use a linear list to store the nodes of the linear octree, where the node's index is the current node's subscript in the linear list. Each node stores the index of the parent node and the indices of all child nodes to implement returning the root node and traversing the subtree, respectively.

[0050] Step S3.3: Insert a root node into the empty octree. The center coordinates and length, width and height of the root node are the center coordinates and length, width and height of the bounding box. Mark the root node as a node that does not contain water particles.

[0051] Step S3.4: Iterate through each water particle, obtain the coordinates of the current water particle, and perform the following operations;

[0052] Step S3.4.1: Traverse the linear octree starting from the root node:

[0053] If the current node is a non-leaf node of a linear octree, then the positional relationship between the coordinates of the current water particle and the center coordinates of the current node determines which child node the current water particle should be placed in, and S3.4.1 continues to be executed.

[0054] If the current node is a leaf node of a linear octree, then proceed to step S3.4.2;

[0055] Step S3.4.2: Determine whether the current node contains water particles:

[0056] If the current node does not contain water particles, then the current water particle is placed into the current leaf node;

[0057] If the current node contains water particles, remove the existing water particles from the current node and subdivide the current node into three-dimensional space. After subdivision, determine which child node the existing water particles should be placed in based on the positional relationship between the existing water particles and the center of the leaf node. At the same time, determine which child node the current water particles should be placed in based on the positional relationship between the coordinates of the current water particles and the center coordinates of the current node. If the existing water particles and the current water particles are still in the same child node, treat that child node as the current node and repeat step S3.4.2. If the existing water particles and the current water particles are not in the same child node, continue to execute step 3.4.

[0058] Step S4: Transfer the coordinates of the water particles and the linear octree from the CPU to the GPU.

[0059] In a preferred embodiment of the present invention, since the coordinates of water particles are readable and writable in the GPU, the coordinates of water particles in the GPU use the SRV buffer (GPU read-only buffer) in the DirectX11 framework as input and the UAV buffer (GPU writable buffer) in the DirectX11 framework as output; since the linear octree is read-only in the GPU, the linear octree in the GPU is stored using the SRV buffer.

[0060] Step S5: In the GPU, traverse the linear octree in depth-first order to detect the nearest neighbor water particles of the query water particles. The specific process is as follows:

[0061] Step S5.1: Create two temporary variables, CurrentNode and LastNode, to store the currently accessed node and the previously accessed node, respectively;

[0062] Since octree traversal is performed on the GPU, and due to limitations of the HLSL language, recursion and auxiliary storage structures such as stacks or queues cannot be used for octree traversal, this invention employs an iterative algorithm with a space complexity of O(1) when traversing the octree. Only two temporary variables, CurrentNode and LastNode, are used to store the currently visited node and the previously visited node, respectively. When CurrentNode stores the currently visited node and LastNode stores the previously visited node, the parent-child relationship between the two nodes can be used to represent the different stages of the current linear octree traversal.

[0063] If the last visited node stored in the temporary variable LastNode is the parent node of the currently visited node stored in the temporary variable CurrentNode, then the current stage is the stage of traversing the child nodes of the last visited node stored in the temporary variable LastNode.

[0064] If the previously visited node stored in the temporary variable LastNode is a child node of the currently visited node stored in the temporary variable CurrentNode, it means that all the child nodes of the previously visited node stored in the temporary variable LastNode have been visited, and the next child node of the currently visited node stored in CurrentNode should be visited.

[0065] If the last visited node stored in LastNode is the last child node of the currently visited node stored in CurrentNode, it means that all child nodes of the currently visited node stored in CurrentNode have been traversed, and the other child nodes of the parent node of the currently visited node stored in CurrentNode should be traversed.

[0066] Perform a depth-first traversal of the linear octree according to the above three rules. The loop ends when the currently visited node stored in CurrentNode is the parent node of the root node, and the previously visited node stored in LastNode is the root node.

[0067] Step S5.2: Access the root node;

[0068] Step S5.3: If the currently visited node is a child node of the previously visited node (or the previously visited node is empty), it means that the currently visited node has not been visited yet, and jump to step S5.4; if the currently visited node is the parent node of the previously visited node, it means that the previously visited node and its subtrees have been visited, and jump to step S5.6.

[0069] Step S5.4: If the currently visited node is a leaf node, it means that the currently visited node stores water particle information, and jump to step S5.5; if the currently visited node is a non-leaf node, it means that the currently visited node stores tree trunk information, and jump to step S5.6.

[0070] Step S5.5: Determine whether the coordinates of the water particle in the currently visited node are within the scope of the query water particle: If yes (the coordinates of the water particle in the currently visited node are within the scope of the query water particle), then determine that the water particle in the currently visited node is the immediate neighbor of the query water particle. Calculate the coordinates of the query water particle according to the SPH formula and the immediate neighbor. After the calculation, visit the parent node of the currently visited node and jump to step S5.3; if not (the coordinates of the water particle in the currently visited node are not within the scope of the query water particle), then jump to step S5.3.

[0071] Step S5.6: If the current node has unvisited child nodes, then visit that node. If not, and the parent node of the currently visited node is not empty, then visit the parent node of the current node; jump to step S5.3; if not, and the parent node of the currently visited node is empty, then the octree traversal is complete, jump to step S6.

[0072] Step S6: Return the coordinates of the water particles from the GPU to the CPU.

[0073] Step S7: Apply a rendering scheme to color the water particles in the CPU.

[0074] In a preferred embodiment of the present invention, the SSF (Screen Space Fluid) rendering scheme is used to color water particles.

[0075] It should be noted that although the embodiments described above are illustrative, they are not intended to limit the invention. Therefore, the invention is not limited to the specific embodiments described above. Any other embodiments obtained by those skilled in the art under the guidance of this invention without departing from its principles are considered to be within the protection scope of this invention.

Claims

1. A fluid simulation method based on GPU octree acceleration and SPH algorithm, characterized in that, The steps include the following: Step S1: Initialize the DirectX rendering pipeline; Step S2: Use the CPU to randomly generate the coordinates of water particles within a preset range; Step S3: In the CPU, establish a linear octree based on the coordinates of the water particles; Step S4: Transfer the coordinates of the water particles and the linear octree from the CPU to the GPU. Step S5: Traverse the linear octree in depth-first order in the GPU to detect the nearest neighbor water particles of the query water particles. Step S5.1: Create two temporary variables to store the currently accessed node and the previously accessed node, respectively; Step S5.2: Access the root node; Step S5.3: If the currently visited node is a child node of the previously visited node or the previously visited node is empty, it means that the currently visited node has not been visited yet, and proceed to step S5.

4. If the currently visited node is the parent node of the previously visited node, it means that the previously visited node and its subtrees have been visited, and the process jumps to step S5.

6. Step S5.4: If the currently visited node is a leaf node, it means that the currently visited node stores water particle information, and jump to step S5.5; if the currently visited node is a non-leaf node, it means that the currently visited node stores tree trunk information, and jump to step S5.

6. Step S5.5: Determine whether the coordinates of the water particle in the currently visited node are within the scope of the query water particle. If yes, determine that the water particle in the currently visited node is the immediate neighbor of the query water particle. Calculate the coordinates of the query water particle based on the SPH formula and the immediate neighbor. After the calculation, visit the parent node of the currently visited node and jump to step S5.

3. If the coordinates of the water particle in the currently visited node are not within the scope of the query water particle, jump to step S5.

3. Step S5.6: If the currently visited node has unvisited child nodes, then visit the unvisited child nodes; if the currently visited node has no unvisited child nodes and the parent node of the currently visited node is not empty, then visit the parent node of the currently visited node and jump to step S5.

3. If the currently visited node has no unvisited child nodes and the parent node of the currently visited node is empty, then the linear octree traversal is complete, and the process jumps to step S6. Step S6: Return the coordinates of the water particles from the GPU to the CPU; Step S7: Apply a rendering scheme to color the water particles in the CPU.

2. The fluid simulation method based on GPU octree acceleration and SPH algorithm according to claim 1, characterized in that, In step S2, the coordinates of the randomly generated water particles are located within a cube within a preset range of [-10, 10].

3. The fluid simulation method based on GPU octree acceleration and SPH algorithm according to claim 1, characterized in that, The specific process of step S3 is as follows: Step S3.1: Calculate the center coordinates of the bounding box formed by all water particles, as well as the length, width and height of the bounding box, based on the coordinates of all water particles. Step S3.2: Create an empty linear octree; define each node of the linear octree as pointing to a three-dimensional cube space, and each child node is obtained by subdividing the parent node into three-dimensional spaces; The process involves subdividing the parent node into three dimensions. This is done by using the center coordinates of the three-dimensional space pointed to by the parent node as the origin, and dividing the parent node's three-dimensional space into eight equal-sized sub-three-dimensional spaces using the X, Y, and Z axes as dividing lines. These sub-three-dimensional spaces are the three-dimensional spaces pointed to by the child nodes. A linear list is used to store the nodes of the linear octree, where the node's index is the current node's subscript in the linear list. Each node stores the index of its parent node and the indices of all its child nodes to enable the return of the root node and the traversal of the subtree. Step S3.3: Insert a root node into an empty octree. The center coordinates and length, width and height of the root node are the center coordinates and length, width and height of the bounding box. Mark the root node as a node that does not contain water particles. Step S3.4: Iterate through each water particle, obtain the coordinates of the current water particle, and perform the following operations; Step S3.4.1: Traverse the linear octree starting from the root node: If the current node is a non-leaf node of a linear octree, then the positional relationship between the coordinates of the current water particle and the center coordinates of the current node determines which child node the current water particle should be placed in, and S3.4.1 continues to be executed. If the current node is a leaf node of a linear octree, then proceed to step S3.4.2; Step S3.4.2: Determine whether the current node contains water particles: If the current node does not contain water particles, then the current water particle is placed into the current leaf node; If the current node contains water particles, remove the original water particles from the current node and subdivide the current node into three-dimensional space. After subdivision, determine which child node the original water particles should be placed in based on the positional relationship between the original water particles in the current node and the center of the leaf node. At the same time, determine which child node the current water particles should be placed in based on the positional relationship between the coordinates of the current water particles and the center coordinates of the current node. If the original water particles and the current water particles are still in the same child node, then treat that child node as the current node and repeat step S3.4.

2. If the original water particles and the current water particles are not in the same child node, then continue to execute step 3.

4.

4. The fluid simulation method based on GPU octree acceleration and SPH algorithm according to claim 1, characterized in that, In step S4, in the GPU, the coordinates of water particles are input using the SRV buffer in the DirectX11 framework and output using the UAV buffer in the DirectX11 framework; the linear octree is stored using the SRV buffer.

5. The fluid simulation method based on GPU octree acceleration and SPH algorithm according to claim 1, characterized in that, In step S5.1, when using a temporary variable CurrentNode to store the currently visited node and a temporary variable LastNode to store the previously visited node, the parent-child relationship between the two nodes can be used to represent different stages of the current linear octree traversal: If the last visited node stored in the temporary variable LastNode is the parent node of the currently visited node stored in the temporary variable CurrentNode, then the current stage is the stage of traversing the child nodes of the last visited node stored in the temporary variable LastNode. If the previously visited node stored in the temporary variable LastNode is a child node of the currently visited node stored in the temporary variable CurrentNode, it means that all the child nodes of the previously visited node stored in the temporary variable LastNode have been visited, and the next child node of the currently visited node stored in CurrentNode should be visited. If the last visited node stored in LastNode is the last child node of the currently visited node stored in CurrentNode, it means that all child nodes of the currently visited node stored in CurrentNode have been traversed, and the other child nodes of the parent node of the currently visited node stored in CurrentNode should be traversed. The depth-first traversal of the linear octree ends when the currently visited node stored in CurrentNode is the parent node of the root node, and the previously visited node stored in LastNode is the root node.

6. The fluid simulation method based on GPU octree acceleration and SPH algorithm according to claim 1, characterized in that, In step 7, the screen space fluid rendering scheme is used in the CPU to color the water particles.

Citation Information

Patent Citations

  • Three-dimensional fluid simulation method based on graphic processing unit (GPU)

    CN102402791A

  • A method for accelerating terrain rendering based on quadtree using graphics processing unit

    KR100959349B1