Fluid simulation method and device based on Niagarsa particle system
By adopting the spatial segmentation and global distance field evaluation algorithm of the Niagara particle system in the fluid simulation technology, the calculation efficiency and stability problems of fluid simulation in complex scenarios are solved, and efficient and accurate fluid simulation effects are achieved, satisfying the tunnel and traffic The demand for accident scenarios.
Patent Information
- Application Number
- CN202411810513.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-01-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing fluid simulation technology has high calculation overhead, low efficiency, poor numerical stability and insufficient accuracy in complex scenarios. It is difficult to ensure performance and fluency in large-scale particle scenarios, and it is difficult to meet the needs of tunnel and traffic accident simulation.
Using the fluid simulation method based on the Niagara particle system, the particle area is divided through the spatial segmentation algorithm, the neighborhood search mechanism is optimized, and the particle motion state and collision detection are updated in real time, and the time step is dynamically adjusted to maintain Simulation is stable.
It significantly improves the computational efficiency and stability of fluid simulation, ensures the timeliness and accuracy of fluid simulation in complex scenarios, and improves the authenticity and visual effect of fluid behavior.
Smart Images

Figure CN119294215A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of fluid simulation technology, and in particular to a fluid simulation method and device based on a Niagara particle system. Background Art
[0002] With the rapid development of computer graphics and virtual reality technology, 3D scene simulation has been widely used in many fields, such as game development, film and television production, virtual simulation training, etc. As one of the most advanced game engines, Unreal Engine (UE) has become the preferred tool for many developers to perform 3D scenes and physical simulations with its powerful rendering capabilities, physics engine and user-friendly development environment. In particular, the latest version of Unreal Engine 5 (UE5) has introduced advanced technologies such as Nanite virtual geometry and Lumen global illumination, which provide strong support for the authenticity and complexity of the scene.
[0003] In 3D scene simulation, fluid simulation, as an important technology, is widely used in the presentation of natural phenomena such as smoke, flames, and water flow. Smoke simulation is one of the key points and difficulties. By accurately simulating the flow, diffusion, light and shadow effects of smoke, the immersion and authenticity of the scene can be greatly improved. However, traditional fluid simulation often requires extremely high computing resources, especially in large-scale complex scenes (such as smoke simulation in tunnels), the computing overhead will increase sharply, thus affecting the overall performance and frame rate performance. Therefore, how to improve the computing efficiency while maintaining high precision of fluid simulation has become a hot topic in this field. At present, there is a wide demand for tunnel smoke fluid simulation technology in the market. For example, in emergency drills and evacuation simulations of tunnel fires, accurate smoke simulation can help decision makers better understand the diffusion path of smoke and its impact on personnel evacuation. In addition, disaster scenes in film and television production also require realistic smoke simulation to enhance visual impact and realism.
[0004] However, existing fluid simulation technologies have problems such as performance bottlenecks, insufficient accuracy, and unrealistic interactions with the environment in complex scenarios, especially in tunnel and traffic accident simulations. Specifically, traditional fluid simulation methods, such as fluid simulation based on SPH (Smoothed Particle Hydrodynamics) and UE Cascade particle system. The SPH method regards the fluid as consisting of a large number of particles, each particle carries the fluid's mass, velocity, position and other properties, and the physical properties of the fluid (such as density, pressure and viscosity) are calculated by the interaction between adjacent particles. The core of this method is that the interaction between particles is smoothed by a kernel function to obtain the overall characteristics of the fluid. Although traditional fluid simulation technology can provide certain fluid visual effects, it has the following defects in dealing with large numbers of particles, complex dynamic environments and high-precision scenes:
[0005] 1. High computational overhead: SPH fluid simulation requires complex physical calculations for each particle, especially solving the density, pressure, and interaction force of the particles. When the number of particles increases to hundreds of thousands or even millions, the amount of calculation increases exponentially. When faced with a large number of particles, the computational complexity of existing fluid simulation increases dramatically, especially in real-time accident simulation, it is difficult to guarantee performance and smoothness.
[0006] 2. Low efficiency of neighborhood search: Due to the uneven distribution of particles, the traditional SPH method is inefficient in finding particle neighbors, resulting in a decrease in overall performance and making it difficult to meet the requirements of fast and changeable fluid behavior in traffic accident scenarios.
[0007] 3. Numerical stability issues: Fluid simulations in high-pressure or high-density areas are prone to numerical instability, which can lead to abnormal fluid behavior in fluid simulations, irregular particle movement, or even simulation collapse, and fail to accurately reflect real physical phenomena such as smoke and gas diffusion in accidents.
[0008] 4. Insufficient accuracy: Existing fluid simulation methods have limited accuracy when dealing with complex fluid phenomena such as fine diffusion of smoke and gas flow, and it is difficult to provide high-precision and realistic simulation effects in tunnel and traffic accident simulation scenarios. Summary of the invention
[0009] In view of the above problems, the present invention is proposed to provide a fluid simulation method and device based on the Niagara particle system that overcomes the above problems or at least partially solves the above problems.
[0010] One aspect of the present invention provides a fluid simulation method based on a Niagara particle system, the method comprising:
[0011] Determine the simulation environment scenario to be simulated and create a Niagara system under the current simulation environment scenario;
[0012] In the Niagara system, use the grid 2D gas and / or grid 3D gas in the fluid simulation plug-in to create a particle emitter for the fluid template to establish a fluid simulation space, set the particle life cycle, initialize the particle physical properties, and set the particle collision rules;
[0013] The space segmentation algorithm is used to divide the particles in the fluid simulation space into multiple distribution areas and associate the adjacent distribution areas;
[0014] In the fluid simulation stage, the neighboring particles of each particle in the fluid simulation space at the current moment are obtained according to the correlation between the particle distribution areas, and the motion state information of each particle and the interaction force between the particle and the adjacent particles are calculated in real time to obtain the motion trajectory and interaction of the particle. The motion state information of the particle is updated according to the motion trajectory and interaction of the particle according to the preset time step, and the collision between the particle and the environment is checked in real time using the preset global distance field evaluation algorithm, so as to adjust the motion state information of the particle according to the collision situation;
[0015] The above steps of updating the motion state information of the particles are repeated until the preset simulation termination condition is met, and after each update, the current motion state information and morphology information of the particles are passed to the rendering module for visual rendering.
[0016] Furthermore, the method of using a space segmentation algorithm to divide particles in the fluid simulation space into a plurality of distribution areas and associating adjacent distribution areas includes:
[0017] The entire fluid simulation space is recursively divided into a specified number of node regions using a partition tree structure, and adjacent node regions are connected through pointers. The node regions are used to store particles, and the number of particles in each node region is less than a preset upper limit of the number of particles.
[0018] The depth of the segmentation tree and the upper limit of the number of particles in each node area are dynamically adjusted according to the distribution of particles to reduce the number of empty nodes generated in the low-density particle area.
[0019] Furthermore, the step of obtaining the neighboring particles of each particle in the fluid simulation space at the current moment according to the correlation relationship between the particle distribution areas includes:
[0020] Find the node area and adjacent node area of the segmentation tree where each particle is located to retrieve the candidate neighboring particles of each particle;
[0021] The Euclidean distance between each particle and its corresponding candidate neighboring particle is calculated, and the candidate neighboring particles whose Euclidean distance is within the preset kernel function support radius are selected as the neighboring particles of the current particle.
[0022] Furthermore, the method further comprises:
[0023] A neighborhood cache is set for each particle, and the neighborhood cache is used to store the neighborhood particle information obtained by the most recent neighborhood search of the corresponding particle;
[0024] Correspondingly, before searching for the node region and the adjacent node region of the segmentation tree where the position of each particle is located, the method further includes:
[0025] Determine whether the motion amplitude of each particle is within a preset motion threshold range;
[0026] If the movement amplitude of any particle is within the preset movement threshold range, the historical neighbor particles in the neighborhood buffer area of the current particle are obtained, and the historical neighbor particles are used as the neighbor particles of the current particle at the current moment.
[0027] Furthermore, the method further comprises:
[0028] When the particle position of any particle changes, the particle information in the node area of the segmentation tree is readjusted and updated to reflect the latest particle distribution in the segmentation tree structure.
[0029] Furthermore, the method further comprises:
[0030] The simulation state of the fluid is monitored in real time, and the time step is dynamically adjusted according to the simulation state of the fluid to maintain the stability of the simulation state of the fluid.
[0031] Furthermore, the method further comprises:
[0032] Based on the preset visual operation interface, the simulation parameters of the fluid simulation process are displayed and the user's parameter adjustment request for any simulation parameter is monitored in real time;
[0033] When a parameter adjustment request from the user is received, the target parameter carried in the parameter adjustment request is obtained and the target parameter is used as the latest parameter value of the current simulation parameter.
[0034] Furthermore, a preset global distance field evaluation algorithm is used to check the collision between particles and the environment in real time. The specific implementation methods include:
[0035] Obtain the global distance field and distance field gradient of each particle sample point in the fluid simulation space in the global space;
[0036] detecting the validity of the global distance field and the distance field gradient;
[0037] When the global distance field and the distance field gradient are valid data, the corresponding particle sample point is judged whether it is close to the surface or boundary of the object according to the global distance field, and the fluid direction is determined according to the distance field gradient to realize the collision detection between the particle and the environment.
[0038] In a second aspect, the present invention also provides a fluid simulation device based on a Niagara particle system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned fluid simulation method based on the Niagara particle system when executing the computer program.
[0039] In a third aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned fluid simulation method based on the Niagara particle system.
[0040] The embodiment of the present invention provides a fluid simulation method and device based on the Niagara particle system, which reduces computing overhead and improves the computing efficiency of fluid simulation by combining the powerful parallel computing capability of the Niagara system and the particle system of traditional fluid simulation, thereby maintaining real-time performance in large-scale fluid scenes and meeting the timeliness requirements of fluid simulation in complex scenes; further, the present invention improves the efficiency of interactive calculations between particles by improving the neighborhood search mechanism, avoids performance bottlenecks caused by a large number of particles or uneven distribution, and ensures that fluid simulation in complex environments can run smoothly.
[0041] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0043] Figure 1 A flow chart of a fluid simulation method based on a Niagara particle system provided by an embodiment of the present invention;
[0044] Figure 2 A specific implementation flow chart of establishing a fluid simulation space provided by an embodiment of the present invention;
[0045] Figure 3 Schematic diagram of using a global distance field evaluation algorithm to check the collision between particles and the environment in real time according to an embodiment of the present invention Figure 1 ;
[0046] Figure 4 Schematic diagram of using a global distance field evaluation algorithm to check the collision between particles and the environment in real time according to an embodiment of the present invention Figure 2 . DETAILED DESCRIPTION
[0047] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0048] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0049] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.
[0050] Figure 1 The flowchart of the fluid simulation method based on the Niagara particle system according to one embodiment of the present invention is schematically shown. Figure 1 The fluid simulation method based on the Niagara particle system of the embodiment of the present invention specifically includes the following steps:
[0051] S11, determining a simulation environment scene to be simulated and creating a Niagara system under the current simulation environment scene;
[0052] S12. In the Niagara system, the grid 2D gas and / or grid 3D gas in the fluid simulation plug-in are used as fluid templates to create particle emitters to establish a fluid simulation space, and the particle life cycle is set, the particle physical properties are initialized, and the particle collision rules are set. Among them, initializing the particle physical properties includes defining the initial velocity, configuring color and size changes, adding physical and motion properties, and selecting appearance material textures. Taking the tunnel as an example of the simulation environment scene, the specific implementation process of using the grid 2D gas and / or grid 3D gas in the fluid simulation plug-in in the Niagara system as a fluid template to create a particle emitter to establish a fluid simulation space is as follows Figure 2 shown.
[0053] The particle generation of the present invention initializes the number and position of particles, calls the particle manager to generate particles, and stores them in a data structure (such as an array or a linked list). The particle generation algorithm provided by the present invention uses a random distribution algorithm (such as Poisson Disk Sampling) to generate the initial particle position to ensure the uniform distribution of particles in space. The particle motion algorithm provided by the present invention uses the Euler method or the Semi-Implicit Euler Method to iteratively update the time step to calculate the speed and position of the particles. The particle generation algorithm and the particle motion algorithm are specifically as follows:
[0054] Particle generation algorithm: Use a random distribution algorithm (such as Poisson Disk Sampling) to generate the initial particle positions to ensure that the particles are evenly distributed in space.
[0055] Particle motion algorithm: Euler method or semi-implicit Euler method is used to iteratively update the time step to calculate the velocity and position of the particles.
[0056] formula:
[0057] Speed Update:
[0058] Location Updates:
[0059] in, is the particle velocity, is the particle acceleration, is the particle position and △t is the time step.
[0060] S13. Using a space segmentation algorithm, the particles in the fluid simulation space are divided into multiple distribution areas and the adjacent distribution areas are associated.
[0061] S14. In the fluid simulation stage, the neighboring particles of each particle in the fluid simulation space at the current moment are obtained according to the correlation between the particle distribution areas, and the motion state information of each particle and the interaction force between the particle and the adjacent particles are calculated in real time to obtain the motion trajectory and interaction of the particle. The motion state information of the particle is updated according to the motion trajectory and interaction of the particle according to the preset time step, and the collision between the particle and the environment is checked in real time using the preset global distance field evaluation algorithm to adjust the motion state information of the particle according to the collision situation; wherein the motion state information includes attribute information such as velocity, acceleration, and position, and the interaction force between adjacent particles includes pressure force and viscosity force. When updating the particle velocity, the calculated interaction force and the resultant force of external forces (including external forces such as gravity, pressure, etc.) need to be applied to the particle velocity update.
[0062] S15, passing the current motion state information and morphology information of the particle to a rendering module for visual rendering;
[0063] S16, determine whether the preset simulation termination condition is met, wherein the simulation termination condition may be the end of the preset simulation time or the user manually stopping. If not, repeat the above steps S14 to S15 until the preset simulation termination condition is met, and if so, execute step S17;
[0064] S17, end the fluid simulation.
[0065] The fluid simulation method based on the Niagara particle system provided in the embodiment of the present invention reduces computing overhead and improves the computing efficiency of fluid simulation by combining the powerful parallel computing capability of the Niagara system and the particle system of traditional fluid simulation, thereby maintaining real-time performance in large-scale fluid scenes and meeting the timeliness requirements of fluid simulation in complex scenes; further, the present invention improves the efficiency of interactive calculations between particles by improving the neighborhood search mechanism, avoids performance bottlenecks caused by a large number of particles or uneven distribution, and ensures that fluid simulation in complex environments can run smoothly.
[0066] In the embodiment of the present invention, the following Physical Force calculation process is also involved when calculating the interaction force between adjacent particles:
[0067] Lift: Force = (DensityBuoyancy * SimGrid_Density - TemperatureBuoyancy* SimGrid_Temperature) * g; where DensityBuoyancy is the buoyancy effect caused by density, SimGrid_Density is the density of the fluid, TemperatureBuoyancy is the buoyancy effect caused by temperature, and SimGrid_Temperature is the temperature of the fluid.
[0068] Turbulence force: used to add turbulence force to the velocity field, including three parts: turbulence control, turbulence channel [that is, add turbulence, temperature / density to that grid data channel], and grid properties.
[0069] In one embodiment of the present invention, the step S13 uses a space segmentation algorithm to divide particles in the fluid simulation space into multiple distribution areas and associate adjacent distribution areas, which specifically includes the following steps not shown in the drawings:
[0070] S131, using a partition tree structure to recursively divide the entire fluid simulation space into a specified number of node regions, and connecting adjacent node regions through pointers, the node regions are used to store particles and the number of particles in each node region is less than a preset upper limit of the number of particles;
[0071] S132. Dynamically adjust the depth of the segmentation tree and the upper limit of the number of particles in each node area according to the distribution of particles, so as to reduce the number of empty nodes generated in the low-density particle area.
[0072] Traditional neighborhood search algorithms usually use brute force methods to traverse all particle pairs and calculate the distance between them. This method is very time-consuming in large-scale particle scenes, and the computational complexity is , which is inefficient for real-time fluid simulation and cannot meet the needs of complex scenes. The neighborhood search optimization module of the present invention adopts a space segmentation algorithm, such as octree or grid segmentation, which can quickly divide particles into multiple regions through the segmentation tree structure, greatly reducing the search range of neighborhood particles, thereby quickly locating and retrieving neighborhood particles, reducing unnecessary calculations, and significantly improving particle interactions.
[0073] In a specific embodiment, the present invention uses an octree to implement a segmentation tree structure. The entire fluid simulation space is recursively divided into eight sub-regions using an octree, and the number of particles in each sub-region is limited, which facilitates rapid search for neighboring particles. The present invention uses a dynamic segmentation mechanism to dynamically adjust the depth of the octree and the upper limit of the number of particles at each node according to the distribution of particles, avoiding the generation of too many empty nodes in low-density areas and optimizing computational efficiency.
[0074] Furthermore, the step S14 of obtaining the neighboring particles of each particle in the fluid simulation space at the current moment according to the correlation relationship between the particle distribution areas specifically includes the following steps not shown in the drawings:
[0075] S141, searching the node region and adjacent node region of the segmentation tree where the position of each particle is located, so as to retrieve the candidate neighboring particles of each particle;
[0076] S142, calculating the Euclidean distance between each particle and the corresponding candidate neighboring particle, and selecting the candidate neighboring particles whose Euclidean distance is within the preset kernel function support radius as the neighboring particles of the current particle.
[0077] In a specific embodiment, an octree structure is used to quickly retrieve possible neighboring particles at the location of a given particle by searching its node and adjacent nodes, thereby reducing the search range. Then, by calculating the Euclidean distance between particles, it is determined whether it is within the support radius of the kernel function (i.e., the neighborhood octagonal algorithm). The candidate neighboring particles within the kernel function support radius are used as the neighboring particles of the current particle, thereby determining the neighboring particles.
[0078] Furthermore, a neighborhood cache is set for each particle, and the neighborhood cache is used to store the neighborhood particle information obtained by the most recent neighborhood search of the corresponding particle; accordingly, before searching the node area and the adjacent node area of the segmentation tree where the position of each particle is located, it is determined whether the movement amplitude of each particle is within a preset movement threshold range; if the movement amplitude of any particle is within the preset movement threshold range, the historical neighborhood particles in the neighborhood cache of the current particle are obtained, and the historical neighborhood particles are used as the neighborhood particles of the current particle at the current moment.
[0079] Furthermore, when the particle position of any particle changes, the particle information in the node area of the segmentation tree is readjusted and updated to reflect the latest particle distribution in the segmentation tree structure.
[0080] In a specific example, the specific implementation process of the neighborhood search optimization algorithm provided by the embodiment of the present invention is as follows:
[0081] 1. Space initialization:
[0082] The simulation space is divided into multiple small areas through the octree, and each leaf node stores the particles in the area. If the number of particles exceeds a certain threshold, the area is subdivided until the condition is met or the maximum depth of the tree is reached.
[0083] 2. Neighborhood search steps:
[0084] Insert particles: Each particle is inserted into the corresponding octree node according to its position.
[0085] Particle retrieval: When it is necessary to calculate the interaction between particles, the neighborhood of the particle is searched from the octree. First, the node where the particle is located is located, and then the candidate neighborhood particles are determined by checking the adjacent nodes. The present invention can quickly narrow the search range by locating the node where the particle is located and its adjacent nodes, thereby speeding up the process of calculating the distance between particles and determining the neighborhood.
[0086] Neighborhood determination: For all candidate particles, the Euclidean distance between them and the current particle is calculated. If the distance is less than the support radius of the kernel function, it is identified as a neighboring particle. The present invention can quickly narrow the search range by locating the node where the particle is located and its adjacent nodes, thereby speeding up the process of distance calculation between particles and neighborhood determination.
[0087] 3. Dynamic Updates:
[0088] When the particle position changes, the octree is readjusted and updated to ensure that the new particle distribution can be quickly reflected in the spatial segmentation structure.
[0089] 4. Cache optimization:
[0090] If the particle's motion amplitude is small (within the allowable range), the neighboring particles in the previous search result can be directly used to avoid repeated searches and further improve efficiency. In this embodiment, the neighborhood search results can be temporarily stored in the cache and reused in the next frame of fluid simulation to reduce unnecessary repeated calculations.
[0091] The technical effects of the neighborhood search optimization algorithm provided by the embodiment of the present invention are as follows:
[0092] 1. Improved computational efficiency: By using octree to partition the space, the computational complexity of neighborhood search is reduced from Reduced to Specifically, an octree is a data structure that recursively partitions a three-dimensional space. It divides the space into smaller cubic units and is usually used to store and quickly query large-scale three-dimensional spatial data. In the context of neighborhood search, the octree significantly improves query efficiency and reduces computational complexity by effectively organizing and reducing the search space.
[0093] From the professional perspective of fluid and gas dynamics, it can be understood as follows: Assume that the molecules of a fluid or gas are randomly distributed in three-dimensional space, and you need to find the neighboring objects of a certain object or fluid particle. If you do not accelerate the processing, you need to check the relative positions of all particle pairs. The computational complexity of this brute force method is ,in is the total number of particles. This is because each particle is compared to all other particles, and the amount of computation increases with the square of the number of particles.
[0094] The principle of octree, octree gradually organizes particles into these spatial units by recursively dividing the space into smaller cubic units. At each recursive level, the space is divided into 8 subspaces, so that the number of particles in each spatial unit is relatively small. Therefore, when you want to query the neighborhood of a particle, the octree allows you to quickly narrow the search range by searching layer by layer.
[0095] The complexity can be reduced in two ways:
[0096] Spatial segmentation and particle localization: The octree segmentation method allows each subspace to contain relatively few particles. In this way, when performing neighborhood queries, we do not need to traverse the entire space, but only need to check a few spatial units adjacent to the target particle. If the particle position is well localized (that is, the particles are not too scattered), most queries will only involve a few subspaces, greatly reducing the calculation of irrelevant particles.
[0097] Divide and conquer strategy: Since the spatial partitioning of the octree follows the divide and conquer strategy, irrelevant parts can be quickly excluded by comparing the spatial positions of the particles each time a query is made. This means that although we still need to traverse each particle, we do not need to traverse all particles, but only the local area that the target particle may affect. This greatly reduces the total amount of calculations.
[0098] Complexity analysis:
[0099] When the octree is not used, to perform a neighborhood query, a comparison must be made between each pair of particles, and the computational complexity of this process is , where each particle needs to be Particle comparison.
[0100] When using octree, the space is divided into multiple layers. The layer-by-layer structure makes the scope of each query rapidly narrow. For particles with a relatively uniform distribution, the complexity of querying the neighborhood of a particle will be Reduce to , thus reducing the overall complexity from Reduced to , significantly reducing the amount of computation. The cache mechanism avoids frequent recalculation of the global neighborhood, further reducing the system overhead.
[0101] 2. Memory efficiency optimization: Dynamically adjust the depth of the octree to avoid a large number of empty nodes in low-density areas, reducing memory usage.
[0102] 3. Improved search accuracy: By using octrees for local neighborhood searches, it is possible to ensure that the interaction forces of particles are only calculated within their physical influence range, reducing unnecessary long-distance calculations, thereby improving search accuracy and the physical accuracy of the simulation.
[0103] In one embodiment of the present invention, the simulation state of the fluid is monitored in real time, and the time step of particle update rendering is dynamically adjusted according to the simulation state of the fluid, so that it can be automatically adjusted when the GPU pressure is high to maintain the stability of the fluid simulation state.
[0104] The present invention combines the physical solving ability and stabilization algorithm of the Niagara system in the fluid simulation process to adjust the time step and simulation parameters of the fluid simulation in real time, thereby ensuring the stability of the fluid simulation in high-pressure and high-density areas.
[0105] Specifically, fluid simulation may include the following simulation parameters:
[0106] Particle Velocity: The greater the particle velocity in the fluid, the smaller the time step needs to be to avoid numerical errors caused by particles crossing too large a distance during the simulation. max dynamically adjusts the time step.
[0107] Particle Density: Fluid simulations often use density as a constraint. If the density deviates from the target value (for example, the density of water is usually ≈1000kg / m3), the time step needs to be shortened in order to converge to the physically correct state faster.
[0108] Pressure Gradient: Excessive pressure gradient may cause simulation instability. Dynamically detect and adjust the time step to suppress excessive gradient.
[0109] Collision and Contact Forces: When the fluid comes into contact with solid boundaries and obstacles, larger contact forces may require smaller time steps to avoid particle penetration or numerical explosion.
[0110] Surface Tension: Fluids with high surface tension (such as water droplets) are more sensitive to the time step and require special adjustments.
[0111] Fluid Viscosity: Highly viscous fluids (such as oil) require a smaller time step, while low-viscosity fluids may require a smaller time step to accurately simulate details.
[0112] External Forces: Large external forces (such as gravity, wind) may require a smaller time step to avoid drastic changes in particle position or velocity.
[0113] Grid / Particle Resolution: Higher resolutions result in finer-grained computational requirements, so the time step may need to be dynamically reduced.
[0114] In one embodiment of the present invention, based on a preset visual operation interface, the simulation parameters of the fluid simulation process are displayed and the user's parameter adjustment request for any simulation parameter is monitored in real time; when the user's parameter adjustment request is received, the target parameter carried in the parameter adjustment request is obtained and the target parameter is used as the latest parameter value of the current simulation parameter.
[0115] The present invention provides customizable parameter settings, allowing users to adjust particle properties as needed, calculate the impact of different parameters on fluid behavior in real time, optimize simulation effects, improve the details and realism of fluid simulation, and meet the needs of complex scenes. The present invention can provide a visual operation interface, allowing users to monitor the core module in real time and adjust simulation parameters through interface interaction, feedback real-time data, improve user experience, and facilitate rapid testing and adjustment of fluid effects.
[0116] In the embodiment of the present invention, a preset global distance field evaluation algorithm is used to check the collision between particles and the environment in real time. The specific implementation method includes: obtaining the global distance field and distance field gradient of each particle sample point in the fluid simulation space in the global space; detecting the validity of the global distance field and distance field gradient; when the global distance field and distance field gradient are valid data, judging whether the corresponding particle sample point is close to the surface or boundary of the object according to the global distance field, and determining the fluid direction according to the distance field gradient to realize the collision detection between particles and the environment. When the global distance field and / or distance field gradient are invalid data, a fallback mechanism is set to return an invalid value to avoid error propagation. Optionally, the distance field data texture can be queried and an accurate global distance field can be returned, and the gradient can be calculated by sampling the surrounding points to calculate the difference and return the true distance field gradient value.
[0117] Among them, Global Distance Field (GDF): represents the distance from a point in 3D space to the nearest surface. It is often used in real-time rendering, collision detection or surface processing. Gradient: represents the rate of change of directionality at a point. In the distance field, the gradient points in the direction of the nearest surface. Specifically, at any point in the distance field Determine the point The gradient vector ; Point The gradient vector The direction of the force is taken as the direction of the current particle, and the point The gradient vector The magnitude of the force is used as the magnitude of the force on the current particle, the force on the current particle is obtained, and the collision between the particle and the environment is detected according to the force on the current particle.
[0118] In the embodiment of the present invention, by obtaining the distance from the current fluid particle or grid point to the nearest surface, it is possible to effectively determine whether the point is close to the surface or boundary of the object. For example, a positive value indicates that the fluid point is outside the boundary; a negative value or zero indicates that the point is inside the boundary or touches the boundary.
[0119] In an embodiment of the present invention, the direction of the fluid is determined by obtaining the distance field gradient of the current fluid particle or grid. In the distance field, the gradient vector usually indicates the direction from a point to the nearest surface, which is very useful when calculating the interaction between the fluid and the boundary, for example: for simulating the reflection or sliding of the fluid when it hits an obstacle; for applying external forces (such as collision forces) to change the speed or direction of movement of the fluid. Gradient information can also be used to calculate boundary conditions, such as adhesion effects or free surface processing. This is crucial to maintaining realistic boundary behavior in fluid simulation.
[0120] In addition, invalid data can also be avoided. For example, if the calculated gradient is invalid (such as float3(0, 0,0.001f)) or the calculated distance from the particle sample point to the surface is not positive, then the velocity field or pressure field cannot be correctly processed in the fluid calculation. The present invention can avoid error propagation by setting a fallback mechanism and returning an invalid value.
[0121] Furthermore, the present invention needs to detect the data validity of the global distance field and distance field gradient of the particle sample point. If the above conditions are not met, the detection function will return an invalid value, usually an error state value or a default value, such as a maximum distance value. The detection conditions are as follows: laxGlobalDistance>0: The global maximum distance must be positive, which indicates that there is valid distance data. distanceAtQueryPoint>0: The distance from the particle sample point to the surface must be positive, indicating that the point is within the valid area of the distance field. gradient != float3(0, 0, 0.001f): The gradient cannot be the preset invalid placeholder value float3(0, 0, 0.001f). If the validity is met, the collision detection between the particle and the environment is realized based on the global distance field and distance field gradient corresponding to the particle sample point.
[0122] In a specific embodiment, the implementation process of the global distance field evaluation algorithm is as follows:
[0123] World Position Transformation:
[0124] MakeLWCVector3 and LWCToFloat combine the input coordinates with the large world coordinates (LWC, Large World Coordinates) and convert them into a floating point sample point SamplePosition.
[0125] Distance query:
[0126] Call GetDistanceToNearestSurfaceGlobal to query the distance to the nearest surface.
[0127] Gradient query:
[0128] Call GetDistanceFieldGradientGlobal to query the gradient.
[0129] Result validity check:
[0130] Judgment conditions:
[0131] The maximum global distance value (MaxGlobalDFAOConeDistance) is greater than 0.
[0132] When the distance at the query point is greater than 0, the gradient cannot be float3(0, 0, 0.001f) (invalid placeholder value).
[0133] Fallback mechanism:
[0134] • If the precondition is not met, an invalid value is returned directly.
[0135] float GetDistanceToNearestSurfaceGlobal(float3TranslatedWorldPosition)
[0136] {
[0137] return MaxGlobalDFAOConeDistance;
[0138] }
[0139] Directly return the global maximum distance MaxGlobalDFAOConeDistance.
[0140] In actual implementation, this function can also query the distance field data texture and return the accurate distance value.
[0141] float3 GetDistanceFieldGradientGlobal(float3 TranslatedWorldPosition)
[0142] {
[0143] return float3(0, 0, 0.001f);
[0144] }
[0145] In combination with actual Figure 3 and Figure 4 , you can observe a red distance field, which is used to limit the display range of the fog. Within this range, for example, in the tunnel in the attached figure, there will be a collision with the tunnel wall.
[0146] The fluid simulation method based on the Niagara particle system provided by the present invention has at least the following technical advantages:
[0147] 1 Improve the efficiency of fluid simulation:
[0148] The present invention combines the traditional fluid simulation method with the Niagara fluid system of the Unreal Engine, and utilizes Niagara's parallel processing capability to significantly improve the computational efficiency of fluid simulation. Compared with traditional fluid simulation solutions, the present invention can complete more complex fluid effect simulations in a shorter time, meeting the needs of real-time applications.
[0149] 2 Enhance the visual effect of fluid:
[0150] Through the optimized neighborhood search algorithm, the present invention effectively solves the performance bottleneck of the traditional SPH method in high-density and complex fluid scenes, ensuring the smoothness and stability of fluid simulation. This improvement can make the visual effect of the fluid more realistic, especially in tunnel and traffic accident simulation, the realistic reproduction of fluid behavior is improved.
[0151] 3. Improve numerical stability:
[0152] The present invention optimizes the numerical instability problem of high-pressure and high-density fluids and develops a new stability algorithm. Compared with the prior art, this improvement ensures the accuracy of fluid simulation under extreme conditions, avoids the numerical instability phenomenon commonly seen in traditional methods, and thus improves the reliability of simulation results.
[0153] In addition, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the fluid simulation method based on the Niagara particle system are implemented.
[0154] In this embodiment, if the fluid simulation method based on the Niagara particle system is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium.
[0155] In addition, an embodiment of the present invention further provides a fluid simulation device based on a Niagara particle system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the fluid simulation method based on a Niagara particle system when executing the computer program. Figure 1 Steps S11 to S17 are shown.
[0156] The embodiment of the present invention provides a fluid simulation method and device based on the Niagara particle system, which reduces computing overhead and improves the computing efficiency of fluid simulation by combining the powerful parallel computing capability of the Niagara system and the particle system of traditional fluid simulation, thereby maintaining real-time performance in large-scale fluid scenes and meeting the timeliness requirements of fluid simulation in complex scenes; further, the present invention improves the efficiency of interactive calculations between particles by improving the neighborhood search mechanism, avoids performance bottlenecks caused by a large number of particles or uneven distribution, and ensures that fluid simulation in complex environments can run smoothly.
[0157] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A fluid simulation method based on Niagara particle system, characterized in that: The method comprises: Determine the simulation environment scene to be simulated and create a Niagara particle system in the current simulation environment scene; In the Niagara system, use the grid 2D gas and / or grid 3D gas in the fluid simulation plug-in to create a particle emitter for the fluid template to establish a fluid simulation space, set the particle life cycle, initialize the particle physical properties, and set the particle collision rules; The space segmentation algorithm is used to divide the particles in the fluid simulation space into multiple distribution areas and associate the adjacent distribution areas; In the fluid simulation stage, the neighboring particles of each particle in the fluid simulation space at the current moment are obtained according to the correlation between the particle distribution areas, and the motion state information of each particle and the interaction force between the particle and the adjacent particles are calculated in real time to obtain the motion trajectory and interaction of the particle. The motion state information of the particle is updated according to the motion trajectory and interaction of the particle according to the preset time step, and the collision between the particle and the environment is checked in real time using the preset global distance field evaluation algorithm, so as to adjust the motion state information of the particle according to the collision situation; Repeat the above steps of updating the particle's motion state information until the preset simulation termination condition is met, and after each update, pass the particle's current motion state information and morphology information to the rendering module for visual rendering.
2. The method according to claim 1, characterized in that The method of using a space segmentation algorithm to divide particles in the fluid simulation space into a plurality of distribution areas and associating adjacent distribution areas includes: The entire fluid simulation space is recursively divided into a specified number of node regions using a partition tree structure, and adjacent node regions are connected through pointers. The node regions are used to store particles, and the number of particles in each node region is less than a preset upper limit of the number of particles. The depth of the segmentation tree and the upper limit of the number of particles in each node area are dynamically adjusted according to the distribution of particles to reduce the number of empty nodes generated in the low-density particle area.
3. The method according to claim 2, characterized in that The step of obtaining the neighboring particles of each particle at the current moment in the fluid simulation space according to the correlation relationship between the particle distribution areas includes: Find the node area and adjacent node area of the segmentation tree where each particle is located to retrieve the candidate neighboring particles of each particle; The Euclidean distance between each particle and its corresponding candidate neighboring particle is calculated, and the candidate neighboring particles whose Euclidean distance is within the preset kernel function support radius are selected as the neighboring particles of the current particle.
4. The method according to claim 3, characterized in that The method further comprises: A neighborhood cache is set for each particle, and the neighborhood cache is used to store the neighborhood particle information obtained by the most recent neighborhood search of the corresponding particle; Correspondingly, before searching for the node region and the adjacent node region of the segmentation tree where the position of each particle is located, the method further includes: Determine whether the motion amplitude of each particle is within a preset motion threshold range; If the movement amplitude of any particle is within the preset movement threshold range, the historical neighbor particles in the neighborhood buffer area of the current particle are obtained, and the historical neighbor particles are used as the neighbor particles of the current particle at the current moment.
5. The method according to claim 2, characterized in that: The method further comprises: When the particle position of any particle changes, the particle information in the node area of the segmentation tree is readjusted and updated to reflect the latest particle distribution in the segmentation tree structure.
6. The method according to claim 1, characterized in that The method further comprises: The simulation state of the fluid is monitored in real time, and the time step is dynamically adjusted according to the simulation state of the fluid to maintain the stability of the simulation state of the fluid.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Based on the preset visual operation interface, the simulation parameters of the fluid simulation process are displayed and the user's parameter adjustment request for any simulation parameter is monitored in real time; When a parameter adjustment request from the user is received, the target parameter carried in the parameter adjustment request is obtained and the target parameter is used as the latest parameter value of the current simulation parameter.
8. The method according to any one of claims 1 to 6, characterized in that: The method of using a preset global distance field evaluation algorithm to check the collision between particles and the environment in real time includes: Obtain the global distance field and distance field gradient of each particle sample point in the fluid simulation space in the global space; detecting the validity of the global distance field and the distance field gradient; When the global distance field and the distance field gradient are valid data, the corresponding particle sample point is judged whether it is close to the surface or boundary of the object according to the global distance field, and the fluid direction is determined according to the distance field gradient to realize the collision detection between the particle and the environment.
9. A fluid simulation device based on Niagara particle system, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Dam bursting flood routing simulation method based on two-dimensional SPH
CN104991999A
STL model Monte Carlo particle transport simulation method based on octree neighborhood search
CN118313014A
Plane point cloud extraction method and device, electronic equipment and storage medium
CN119048788A
Cited By
Flood forecasting method and device based on multi-model cooperation and medium
CN120409165A