A method and system for interactive simulation of fluid and thin film solid
By combining spatial hashing and prefix and technology, position-based fluid algorithm and extended position-based dynamics algorithm, the computational complexity and fluid penetration problems of fluid-film solid interaction simulation are solved, achieving efficient and accurate simulation results.
Patent Information
- Application Number
- CN202411272944.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The prior art is difficult to efficiently and accurately simulate the interaction between fluid and film solids, especially in the complex forms of deformable solids, resulting in a significant increase in computing volume and storage requirements, and is prone to physical inaction such as fluid penetration.
Collision detection is performed using a combination of spatial hashing and prefix and technology, and combined with position-based fluid algorithms and extended position-based dynamics algorithms, to achieve interactive simulation of fluid and thin film solids. Through GPU parallel computing and shared memory technology, the simulation process is accelerated and fluid penetration is prevented.
It realizes rapid and accurate detection and response of fluid and film solid interaction, avoids the occurrence of fluid penetration, and improves simulation efficiency and calculation performance.
Smart Images

Figure CN118780097B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computer simulation, and in particular to a method and system for interactive simulation of fluid and thin film solid. Background Art
[0002] The interaction between fluid and thin film solids is widely present in nature and engineering applications, and the simulation of its dynamic interaction process has always been a hot topic in computer science research. For example, the flow of water in a soft water pipe, water flow on cloth, balloons filled with water, etc. In these phenomena, complex interactions will occur between fluid and thin film solids: the viscosity and pressure of the fluid will change the shape of the thin film solid, and the deformation of the thin film solid will in turn affect the flow state of the fluid. How to accurately and efficiently simulate these interaction phenomena is of great significance to improving simulation effects and computing efficiency.
[0003] In fluid simulation of interactive scenes, the Lagrangian method has the advantages of high flexibility and better representation of the fluid in the scene. Among them, the Smoothed Particle Hydrodynamics (SPH) method is the most famous. Since Müller et al. introduced the SPH method into fluid simulation in 2003, it has become an important method in the field of fluid simulation. This method brings a new perspective to fluid simulation. Through the smooth kernel function, the connection between particles is established to simulate the dynamic behavior. However, while pursuing high-precision simulation, this method also faces problems such as high computational complexity, insufficient real-time performance, and instability in some extreme cases.
[0004] In recent years, Macklin et al. introduced the calculation formula for fluid density in the smooth particle hydrodynamics method SPH into the position-based fluid (PBF) method, which effectively solved the instability problem of the SPH method and achieved better real-time performance, significantly improving the real-time performance of fluid simulation. In addition, the position-based dynamics method also proposed constraints for elastic solids, which can simulate fluids and solids under a unified position-based dynamics (PBD) method framework. However, the position-based dynamics method is limited by the number of iterations and the choice of time step. Therefore, Macklin et al. further improved it and proposed the extended position-based dynamics (XPBD) method, thereby overcoming the limitations of PBD and achieving a more stable, accurate and efficient physical simulation.
[0005] Although some studies have attempted to simulate the interaction between fluids and solids through a unified particle system (such as the work of Akinici et al.), particle sampling faces huge challenges when faced with the complex morphology of deformable solids. For example, when the solid is deformed, how should the solid particles change? And when using particles to represent the solid structure, a large number of particles are required to accurately describe the complex deformation, which will lead to a significant increase in computational and storage requirements.
[0006] Considering that the most common form of solid is triangular mesh, in order to improve the versatility of the system, how to efficiently and accurately simulate the interaction between particle-based fluid and triangular mesh-based thin film solid has become an urgent problem to be solved. In order to prevent physical unrealistic phenomena such as fluid penetrating thin film solid during the simulation process, it is crucial to develop an effective collision detection and response mechanism. This requires not only that the algorithm can accurately identify the potential collision points between fluid particles and thin film solid meshes, but also that it can quickly and stably calculate the position changes of particles and mesh vertices after the collision to prevent the occurrence of physical unrealistic phenomena such as fluid penetration. At the same time, in order to improve the simulation efficiency, it is also necessary to make full use of the parallel processing capabilities of modern computing platforms, and accelerate the calculation process of collision detection and response by optimizing data structures, parallelizing algorithms, and other means. Summary of the invention
[0007] In order to address the deficiencies of the prior art, the present invention provides a method and system for interactive simulation of fluids and thin film solids, which uses a method combining spatial hashing and prefix technology to quickly and accurately detect potential collision points between fluid particles and thin film solid grids.
[0008] On the one hand, a method for interactive simulation of fluids and thin film solids is provided, including: based on real thin film solids, constructing a thin film solid model, initializing thin film solid information, and establishing constraints of the thin film solid model; based on real fluids, constructing initial information of the fluid and establishing constraints of the fluid; using a position-based fluid algorithm to calculate the fluid according to the constraints of the fluid to obtain relevant information of the fluid; using an extended position-based dynamics algorithm to calculate relevant information of the thin film solid according to the constraints of the thin film solid model; based on the obtained relevant information of the fluid and the thin film solid, performing collision detection and collision response on the fluid and the thin film solid, correcting the positions of the fluid particles and the thin film solid that are detected to have collided, to prevent penetration; and updating the positions of the fluid and the thin film solid.
[0009] On the other hand, an interactive simulation system of fluid and thin film solid is provided, including: a first constraint condition establishment module, which is configured to: construct a thin film solid model based on the real thin film solid, initialize the thin film solid information, and establish the constraint conditions of the thin film solid model; a second constraint condition establishment module, which is configured to: construct the initial information of the fluid based on the real fluid, and establish the constraint conditions of the fluid; a first calculation module, which is configured to: use a position-based fluid algorithm to calculate the fluid according to the constraint conditions of the fluid to obtain relevant information of the fluid; a second calculation module, which is configured to: use an extended position-based dynamics algorithm to calculate the relevant information of the thin film solid according to the constraint conditions of the thin film solid model; a collision detection and response module, which is configured to: based on the obtained relevant information of the fluid and the thin film solid, perform collision detection and collision response on the fluid and the thin film solid, and correct the positions of the fluid particles and the thin film solid detected to prevent penetration; a position update module, which is configured to: update the positions of the fluid and the thin film solid.
[0010] The above technical scheme has the following advantages or beneficial effects: The solid model of the present invention is represented by a triangular mesh, which can adapt to various forms of thin film solids, such as pipes, cloth, small balls, etc. The present invention designs a recovery constraint for the pipeline model and adds a stretching constraint to jointly simulate the elastic deformation behavior of the pipeline under stress. Through these constraints, large deformation of the pipeline can be effectively prevented. In the collision detection link, the present invention adopts a method combining spatial hashing and prefix technology to quickly and accurately detect potential collision points between fluid particles and thin film solid grids. The particle position is corrected by collision constraints to effectively prevent the fluid particles from penetrating the thin film solid grid. The present invention accelerates the fluid and thin film solid interaction algorithm using GPU parallel computing and shared memory technology, and can perform real-time interaction between fluid and thin film solids. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0012] Figure 1 It is a flow chart in an embodiment of the present invention.
[0013] Figure 2 This is a neighbor particle search graph in an embodiment of the present invention.
[0014] Figure 3 Schematic diagram of stretching constraint in an embodiment of the present invention.
[0015] Figure 4 This is a simulation effect diagram of fluid and cloth interaction in an embodiment of the present invention.
[0016] Figure 5 This is a simulation effect diagram of the interaction between fluid and four-pronged pipe in an embodiment of the present invention. DETAILED DESCRIPTION
[0017] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0018] Embodiment 1: This embodiment provides an interactive simulation method for fluids and thin film solids, including: S101: based on real thin film solids, construct a thin film solid model, initialize thin film solid information, and establish constraints for the thin film solid model; S102: based on real fluids, construct initial information for the fluid and establish constraints for the fluid; S103: using a position-based fluid algorithm, calculate the fluid according to the constraints of the fluid, and obtain relevant information about the fluid; S104: using an extended position-based dynamics algorithm, calculate relevant information about the thin film solid according to the constraints of the thin film solid model; S105: based on the obtained relevant information about the fluid and the thin film solid, perform collision detection and collision response on the fluid and the thin film solid, and correct the positions of the fluid particles and the thin film solid that are detected to have collided, to prevent penetration; S106: updating the positions of the fluid and the thin film solid.
[0019] Furthermore, the thin film solid specifically refers to a solid modeled by a single layer of triangular mesh, such as cloth, balloons, etc.
[0020] Furthermore, the S101: constructing a thin film solid model based on the real thin film solid, and using Maya software to generate the thin film solid model.
[0021] Furthermore, the thin film solid information is initialized, wherein the thin film solid information includes: vertex mass of the thin film solid model, vertex position of the thin film solid model, vertex velocity of the thin film solid model, and elastic coefficient of the thin film solid model.
[0022] Furthermore, the thin film solid model refers to: a triangular mesh model.
[0023] Furthermore, the vertex position refers to the coordinates of the triangle mesh vertex in the scene.
[0024] Furthermore, the vertex velocity refers to the velocity of the triangle mesh vertices in the scene.
[0025] Furthermore, the vertex quality is: the quality of each vertex is determined by the area of the triangle where it is located Determine, vertex quality The calculation formula is: ;in, is the mesh vertex subscript index, is the vertex The set of triangles where is a triangle in the set.
[0026] Further, the initialization of the thin film solid information includes: initializing the vertex position to the initial position of the vertex in the thin film solid; initializing the vertex velocity to zero; and initializing the vertex mass to one third of the sum of the areas of the triangles where the vertex is located.
[0027] It should be understood that the mesh model of thin film solid is introduced to obtain the vertex position and triangle connection relationship of the model; the thin film solid model has properties such as vertex position, vertex velocity, vertex quality, etc. The vertex position is initialized to the initial position of the model, and the vertex velocity is initialized to 0.
[0028] Furthermore, the constraint conditions for establishing the thin film solid model include: stretching constraint conditions, bending constraint conditions and recovery constraint conditions of the thin film solid; among them, the stretching constraint conditions are used to simulate the elasticity of the thin film solid. For the triangular mesh, each edge and the two points connected by the edge constitute a stretching constraint; the bending constraint conditions are used to maintain the angle between the triangular facets to achieve bending resistance. A bending constraint is established for every two triangles with common edges in the triangular mesh; the recovery constraint conditions are applied to the pipeline scene to maintain the shape of the pipeline and prevent excessive stretching of the pipeline when the particles stay. A recovery constraint is established for each vertex of the triangular mesh.
[0029] It should be understood that by establishing the stretching constraint condition, the bending constraint condition and the recovery constraint condition of the thin film solid, the position of the thin film solid is corrected to achieve the elasticity of the thin film solid.
[0030] Stretch Constraints For the stretch constraint, each edge generates a stretch constraint. The stretch constraint is constructed by calculating the length of each edge: ;in, is the initial distance between the two vertices connected by the edge, Indicates the predicted position of the first vertex, Indicates the predicted position of the second vertex;
[0031] Furthermore, the bending constraint For the bending constraint, a bending constraint is established for every two triangles with common edges. The bending constraint is constructed by calculating the dihedral angle between the two triangles: ;in, are the predicted positions of the three vertices of the first triangle, are the predicted positions of the three vertices of the second triangle, is the initial dihedral angle between the first triangle and the second triangle; and are the normal vectors of the two triangles.
[0032] Furthermore, the recovery constraint Generate a constraint for each vertex, retain the initial position of each vertex, and use it to establish the recovery constraint: ;in, is the initial position of the mesh vertices, is the predicted position of the mesh vertex at the current moment.
[0033] Furthermore, the S102: constructs initial information of the fluid based on the real fluid, wherein the initial information of the fluid includes: fluid particle density, fluid particle mass, fluid particle position, fluid particle velocity, fluid particle viscosity, neighbor particle search radius, kernel function, gravity and relaxation parameters.
[0034] Furthermore, the S102: establishing fluid constraint conditions, wherein the fluid constraint conditions refer to: a density-invariant constraint that maintains a fluid density-invariant characteristic.
[0035] The continuously added fluid particles are saved, the position of the fluid particles at the next moment under the action of gravity is predicted, the neighbor particles of the changed fluid particles are found, and the density is calculated according to the density calculation formula of smoothed particle hydrodynamics (SPH). For fluid particles with density greater than the static density, the position of the fluid particles is corrected according to the density invariance constraint formula.
[0036] Smoothed Particle Hydrodynamics (SPH) Density The calculation formula is: ;in, For the Particles, For the Particles, For the The mass of a particle, is the smooth kernel function, It is The predicted position of a particle at the next moment, It is The predicted position of a particle at the next moment, is the core radius, and is also the radius when searching for neighbor particles. ; is the smooth kernel function.
[0037] Each fluid particle generates a density invariance constraint. , the formula for fluid constraint is: ;in, Indicates The density of particles, represents the density of the fluid at static state, Indicates The predicted position of the first neighbor particle of a particle, Indicates The particle n The predicted positions of neighbor particles.
[0038] It should be understood that the position and flow direction of the continuously added fluid particles are determined; the position of the fluid particles is initialized, and the speed is set to the determined flow direction. According to the speed setting, the flow rate of the fluid can be freely controlled, the static density of the fluid is set, and a density invariant constraint is established for each fluid particle.
[0039] Initialize the vertex position and velocity attributes of the thin film solid model mesh, record the triangle information of the mesh, generate fluid particles inside or outside the thin film solid, and specify the flow direction to achieve fluid flow. All steps are accelerated using GPU parallel acceleration technology.
[0040] Furthermore, the S103: adopting a position-based fluid algorithm to calculate the fluid according to the constraints of the fluid to obtain relevant information of the fluid, includes: step S103-1: if it is the first execution, the position of the fluid particle at the next moment is calculated according to the initial position and initial velocity of the fluid particle; if it is not the first execution, the position of the fluid particle at the next moment is calculated according to the updated velocity and updated position of the fluid particle; step S103-2: searching for neighbor particles; step S103-3: after finding the neighbor particles, the density of each fluid particle is calculated according to the position of the fluid particle at the next moment; step S103-4: for fluid particles whose density is greater than the static density, according to the density invariance constraint formula, the position of the fluid particle is corrected to satisfy the constraint, and return to step S103-1.
[0041] Furthermore, the step S103-1: calculating the position of the fluid particle at the next moment; predicting the position of the fluid particle at the next moment according to the external force: ; ;in, It is The velocity of a fluid particle at the current moment, is the acceleration due to gravity, is the time step, It is the current moment The current position of a fluid particle, is the predicted velocity of the fluid particles at the next moment, is the predicted position of the fluid particle at the next moment.
[0042] It should be understood that the density of the fluid particles may change after the position changes, and it is corrected according to the density constraint formula to achieve the incompressible property of the fluid. A key step is to search for neighbor particles to calculate the density of the fluid particles.
[0043] Furthermore, the step S103-2: searching for neighbor particles includes: using a spatial hashing method to divide the fluid space into a plurality of Grid, so when searching for neighbor particles, the search radius is also Therefore, the neighbor particles of the current fluid particle can only appear in the 27 grids centered on the grid where the current fluid particle is located. By searching for fluid particles in these 27 grids, the neighbor particles whose distance to the current fluid particle is less than The fluid particles are recorded as neighbor particles of the current fluid particles.
[0044] ;in, is the hash value, , , is the center coordinate of the grid where the fluid particles are located, is an XOR operation, is the size of the hash table, is the remainder operation, is the radius within which the fluid particle searches for neighbors.
[0045] Furthermore, the step S103-3: after finding the neighbor particles, calculating the density of each fluid particle according to the position of the fluid particle at the next moment, includes: after finding the neighbor particles, calculating the density of each fluid particle according to the density calculation formula in S102.
[0046] Step S103-4: For fluid particles whose density is greater than the static density, according to the density invariance constraint formula, the position of the fluid particles is corrected to satisfy the constraint, including: ; ;in, For the Particles, For the The subscript of the neighbor particles of a particle, is the relative subscript index of the particle involved in the density constraint, is the static density of the fluid, is the corrected position, is the kernel function gradient, is a relaxation factor introduced to prevent the denominator from being zero. and is the scaling factor, and is the predicted position of the fluid particles, is the neighbor particle search radius, is the constraint function, For along Direction gradient.
[0047] Furthermore, the S104: using an extended position-based dynamics algorithm, according to the constraint conditions of the thin film solid model, calculates the relevant information of the thin film solid, including: predicting the position of the vertex of the thin film solid model at the next moment according to the external force, and correcting the vertex position of the vertex thin film solid model according to the constraint correction formula; the constraint correction formula is: ;in, is the subscript of the triangle mesh vertex, is the inverse of mass, is the gradient of the constraint function, Is the matrix consisting of the vertices included in the constraint function ; Indicates the corrected position, Represents the predicted position of each vertex.
[0048] The calculation formula is: ;in, is the accumulated value before the current constraint, , , is the inverse of the stiffness coefficient; represents the constraint function, Represents the inverse of mass, represents the gradient of the constraint function, is the first intermediate variable, is the second intermediate variable.
[0049] It should be understood that in order to achieve deformation of the thin film solid, the stretching constraint is used to achieve the elasticity of the thin film solid, the bending constraint is used to achieve the bending resistance of the thin film solid, and the recovery constraint is used to prevent large deformation of the pipeline. According to the change of the elastic coefficient, the softer or harder effect of the thin film solid can be achieved.
[0050] Further, the S105: based on the obtained relevant information of the fluid and the thin film solid, collision detection and collision response are performed on the fluid and the thin film solid, and the positions of the fluid particles and the thin film solid that are detected to have collided are corrected to prevent penetration from occurring, including: S105-1: using spatial hashing, the entire area where the fluid and the solid are located is divided into multiple grids, and the size of each grid is determined by the radius of the fluid particle and the size of the triangle, and the calculation formula is: ;in, is the grid size of the division, h is the fluid particle search neighbor radius, is the average size of the axis-aligned bounding boxes of all triangles.
[0051] Fluid particles and triangles are mapped to corresponding grids through hash mapping, and fluid particle-film solid triangle pairs that are not in the same grid are eliminated. For fluid particle-film solid triangle pairs in the same grid, they are recorded; the fluid particle-film solid triangle pair refers to a relationship pair consisting of a fluid particle and a film solid triangle face. S105-2: For collision detection between a moving sphere and a moving triangle, a continuous collision detection algorithm is used to detect whether a collision occurs during the movement. Relative to the vertices, the sphere has volume, and the first collision should be on the sphere surface rather than the center of the sphere. The formula of the continuous collision detection algorithm is: ;in, , t If it is not in this interval, it means that there is no collision in the motion within the current time step. is the coordinate of the center of the ball during the motion, , is a point on the triangle t The position at It is a triangle in t The unit normal vector at r is the radius of the sphere.
[0052] S105-3: For the fluid particle-film solid triangle pair that is detected to have collided, the position of the fluid particle is corrected according to the collision constraint formula: ;in, is the predicted position of the center of the sphere of fluid particles that collided, is the position of the center of the fluid particle at the moment of collision, is the collision surface normal; is the collision constraint.
[0053] S105-4: For thin film solid triangles, the speed of the ball is decomposed into the speed along the normal direction of the triangle and the speed perpendicular to the normal direction of the triangle. The speed along the normal direction of the triangle will affect the position of the triangle. Therefore, when the sphere collides with the triangle, the positions of the three vertices of the triangle are moved along the normal direction, thereby realizing the correction of the positions of the three vertices of the triangle, wherein the moving distance is determined by the speed of the sphere.
[0054] Furthermore, the step S106: updating the positions of the fluid and the thin film solid includes: updating the positions of the fluid particles and the thin film solid model triangle mesh at the next moment to the predicted positions, updating the speed, and outputting the fluid particles and mesh vertex position information.
[0055] In game development, real-time fluid and solid interaction simulation can make the changes in the game scene more natural and smooth, thereby enhancing the immersion of the game; in virtual surgery systems, real-time fluid and blood vessel interaction simulation can help doctors better perform surgical training. The present invention proposes a real-time interaction simulation between a fluid modeled by particles and a thin film solid modeled by a triangular mesh, which ensures the non-penetration effect of the fluid and realizes the elasticity of the thin film solid. Figure 1 A flow chart showing the interactive simulation between particle-based fluid and triangle-mesh-based thin-film solid of the present invention. Figure 2 A neighbor particle search graph in an embodiment of the present invention is shown. Figure 3 A schematic diagram of stretching constraints in an embodiment of the present invention is shown. Figure 4 The figure shows the effect of fluid and cloth interaction simulation in an embodiment of the present invention. Figure 5 The figure shows the interactive simulation effect of fluid and four-pronged pipe in the embodiment of the present invention.
[0056] Furthermore, the method also includes: transferring the attributes of the triangle mesh vertices and the attribute information of the fluid particles into the GPU memory, so that the GPU can directly and quickly access these data. In subsequent calculations, the parallel computing capability of the GPU is utilized to efficiently update and interact with the fluid particles and mesh vertices through CUDA kernel functions, thereby significantly accelerating the computing efficiency of the entire simulation process.
[0057] Furthermore, the method also includes: the gravity calculation and density constraint correction parts of each fluid particle are independent, so threads are directly assigned to each fluid particle for parallel traversal; in the neighbor search part of the fluid particle, since the GPU does not support variable-length data structures, it is impossible to store the list of particles contained in each grid, but because the center of each particle is only in one grid, two spaces with the same number of fluid particles can be opened to store the fluid particle index and the hash value of the grid where the fluid particle is located.
[0058] Then, the hash values are sorted according to their size, and two additional spaces matching the size of the hash table are opened to record the starting and ending positions of each hash value, so that the neighboring particles of the fluid particles can be quickly retrieved; for the triangular mesh constraint correction part in the thin film solid model, since the stretching constraint is established based on the edge, write conflicts will occur when correcting each edge and the vertex position in parallel.
[0059] In order to avoid write conflicts, the edges need to be grouped, each edge is considered as a node, and a connection relationship is established between the two nodes corresponding to the two edges with common vertices to form a graph structure. According to the Welch-Powell graph coloring method, the edges are divided into multiple groups so that the vertices involved in the edges of each group are different. Therefore, threads can be assigned to each edge of the same group to solve the constraints in parallel. The same is true for bend constraints. A bend constraint is considered as a node, and a connection relationship is established between the two nodes corresponding to the two bend constraints with the same vertex.
[0060] The collision detection and response phase achieves efficient operation through parallel computing strategies and spatial optimization technology. In the collision detection phase, two objects, fluid particles and thin film solid triangles, are involved. Here, the spatial hashing method is used to find the fluid particle-thin film solid triangle pairs that may collide.
[0061] Specifically, the hash value of the grid where the triangle is located is recorded, and a thread is assigned to each particle to detect the triangle that collides with it. Unlike the neighbor particle search part, each fluid particle only occupies one grid, but each triangle may occupy multiple grids. In order to maximize the space saving of storing triangle hash values, parallel prefix and technology are introduced.
[0062] Open up an array of the same size as the number of triangles, assign threads to store the number of grids occupied by each triangle, and then calculate the prefix sum of the array in parallel to get the location where each triangle index and its hash value should be stored, so that the triangle index and its hash value can be placed in the one-dimensional array in parallel.
[0063] The parallel prefix sum technology is divided into two parts: Up-Sweep and Down-Sweep. In the Up-Sweep part, the data is accumulated and calculated through the tree structure, and the partial sums are gradually summarized until the root node; the Down-Sweep part distributes the partial sums layer by layer from the root node to the bottom layer, and finally calculates the prefix sum of each position.
[0064] In the collision response phase, for fluid particles, the collision constraints generated are mutually opposed, so threads can be directly assigned for parallel calculation; for thin film solid triangles, the change amount of each fluid particle to the mesh vertex is written into the change amount through atomic operations, and the average value is taken to obtain the position change amount of each vertex.
[0065] Process data flexibly according to actual needs. When it is only used for the next calculation, just update the position of the fluid particles and the vertices of the thin film solid model at the next moment; when data needs to be exported, copy it from the GPU memory to the CPU memory and then write it to the file.
[0066] The present invention can well realize the real-time interaction between particle-based fluid and thin film solid based on triangular mesh, realize the elasticity of thin film solid, and effectively avoid the penetration of fluid particles. At the same time, a series of CUDA kernel functions are designed in the system to efficiently update and interact with the vertices of the fluid particles and thin film solid model mesh, thereby significantly accelerating the computational efficiency of the entire simulation process.
[0067] Embodiment 2: This embodiment provides an interactive simulation system of fluids and thin film solids, including: a first constraint condition establishment module, which is configured to: construct a thin film solid model based on real thin film solids, initialize thin film solid information, and establish constraints for the thin film solid model; a second constraint condition establishment module, which is configured to: construct initial information of the fluid based on the real fluid, and establish constraints for the fluid; a first calculation module, which is configured to: use a position-based fluid algorithm to calculate the fluid according to the constraints of the fluid to obtain relevant information of the fluid; a second calculation module, which is configured to: use an extended position-based dynamics algorithm to calculate relevant information of the thin film solid according to the constraints of the thin film solid model; a collision detection and response module, which is configured to: perform collision detection and collision response on the fluid and the thin film solid based on the obtained relevant information of the fluid and the thin film solid, and correct the positions of the fluid particles and the thin film solid detected to prevent penetration; a position update module, which is configured to: update the positions of the fluid and the thin film solid.
[0068] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for interactive simulation of fluid and thin film solid, characterized in that: include: Based on the real thin film solid, a thin film solid model is constructed, thin film solid information is initialized, and constraint conditions of the thin film solid model are established; Based on the real fluid, construct the initial information of the fluid and establish the constraints of the fluid; Adopting the position-based fluid algorithm, the fluid is calculated according to the constraints of the fluid to obtain the relevant information of the fluid; The extended position-based dynamics algorithm is used to calculate the relevant information of the thin film solid according to the constraints of the thin film solid model; Based on the obtained relevant information of the fluid and the thin film solid, collision detection and collision response are performed on the fluid and the thin film solid, and the positions of the fluid particles and the thin film solid that are detected to have collided are corrected to prevent penetration; Update the positions of fluids and thin film solids; The constraints for establishing the thin film solid model include: Tensile constraints, bending constraints, and recovery constraints for thin film solids; Among them, the stretching constraint condition is used to simulate the elasticity of thin film solids. For triangular meshes, each edge and the two points connected by the edge constitute a stretching constraint; the bending constraint condition is used to maintain the angle between triangular facets to achieve bending resistance. Every two triangles with common edges in the triangular mesh establish a bending constraint; the recovery constraint condition is applied to the pipeline scene to maintain the shape of the pipeline and prevent excessive stretching of the pipeline when particles stay. Each vertex of the triangular mesh establishes a recovery constraint; The method includes performing collision detection and collision response on the fluid and the thin film solid based on the obtained relevant information of the fluid and the thin film solid, and correcting the positions of the fluid particles and the thin film solid that are detected to have collided to prevent penetration, including: Using spatial hashing, the entire fluid and solid area is divided into multiple grids. The size of each grid is determined by the radius of the fluid particle and the size of the triangle. The calculation formula is: ; in, is the grid size of the division, h is the fluid particle search neighbor radius, is the average size of all triangle axis-aligned bounding boxes; Fluid particles and triangles are mapped to corresponding grids through hash mapping, and fluid particle-film solid triangle pairs that are not in the same grid are eliminated. For fluid particle-film solid triangle pairs in the same grid, they are recorded; the fluid particle-film solid triangle pair refers to a relationship pair consisting of a fluid particle and a film solid triangle face; For the collision detection between the moving sphere and the moving triangle, the continuous collision detection algorithm is used to detect whether a collision occurs during the movement. The formula of the continuous collision detection algorithm is: ; in, , t If it is not in this interval, it means that there is no collision in the motion within the current time step. is the coordinate of the center of the ball during the motion, , is a point on the triangle t The position at It is a triangle in t The unit normal vector at r is the radius of the sphere; For the fluid particle-film solid triangle pair that is detected to have collided, the position of the fluid particle is corrected according to the collision constraint formula: ; in, is the predicted position of the center of the sphere of fluid particles that collided, is the position of the center of the fluid particle at the moment of collision, is the collision surface normal; is the collision constraint; For a thin film solid triangle, the speed of the ball is decomposed into the speed along the normal direction of the triangle and the speed perpendicular to the normal direction of the triangle. The speed along the normal direction of the triangle will affect the position of the triangle. Therefore, when the sphere collides with the triangle, the positions of the three vertices of the triangle are moved along the normal direction, thereby realizing the correction of the positions of the three vertices of the triangle, where the moving distance is determined by the speed of the sphere.
2. The interactive simulation method of fluid and thin film solid according to claim 1, characterized in that: Stretch Constraints For the stretch constraint, each edge generates a stretch constraint. The stretch constraint is constructed by calculating the length of each edge: ;in, is the initial distance between the two vertices connected by the edge, Indicates the predicted position of the first vertex, Indicates the predicted position of the second vertex; Bending Constraints For the bending constraint, a bending constraint is established for every two triangles with common edges. The bending constraint is constructed by calculating the dihedral angle between the two triangles: ;in, are the predicted positions of the three vertices of the first triangle, are the predicted positions of the three vertices of the second triangle, is the initial dihedral angle between the first triangle and the second triangle; and are the normal vectors of the two triangles; Restoring Constraints Generate a constraint for each vertex, retain the initial position of each vertex, and use it to establish the recovery constraint: ;in, is the initial position of the mesh vertices, is the predicted position of the mesh vertex at the current moment.
3. The interactive simulation method of fluid and thin film solid according to claim 1, characterized in that: Establish fluid constraints, where the fluid constraints refer to: density invariance constraints that maintain the fluid density invariance property; save the continuously added fluid particles, predict the position of the fluid particles at the next moment under the action of gravity, find the neighbor particles of the fluid particles after the change, calculate the density according to the smooth particle dynamics density calculation formula, and for fluid particles with a density greater than the static density, correct the position of the fluid particles according to the density invariance constraint formula; Smooth particle dynamics density The calculation formula is: ; in, For the Particles, For the Particles, For the The mass of a particle, is the smooth kernel function, It is The predicted position of a particle at the next moment, It is The predicted position of a particle at the next moment, is the core radius, which is also the radius when searching for neighbor particles; Smoothing kernel function , the formula is as follows: ; Each fluid particle generates a density invariance constraint. , the formula for fluid constraint is: ;in, Indicates The density of particles, represents the density of the fluid at static state, Indicates The predicted position of the first neighbor particle of a particle, Indicates The particle n The predicted positions of neighbor particles.
4. The interactive simulation method of fluid and thin film solid according to claim 1, characterized in that: Using the position-based fluid algorithm, the fluid is calculated according to the constraints of the fluid to obtain relevant information of the fluid, including: Step (1): if it is the first execution, the position of the fluid particle at the next moment is calculated based on the initial position and initial velocity of the fluid particle; if it is not the first execution, the position of the fluid particle at the next moment is calculated based on the updated velocity and updated position of the fluid particle; Step (2): Search for neighbor particles; Step (3): After finding the neighbor particles, calculate the density of each fluid particle based on the position of the fluid particle at the next moment; Step (4): For fluid particles whose density is greater than the static density, according to the density invariance constraint formula, correct the position of the fluid particles so that they satisfy the constraint, and return to step (1).
5. The interactive simulation method of fluid and thin film solid according to claim 4, characterized in that: Searching for neighbor particles includes: using spatial hashing to divide the fluid space into multiple particles of size Grid, so when searching for neighbor particles, the search radius is also Therefore, the neighbor particles of the current fluid particle can only appear in the 27 grids centered on the grid where the current fluid particle is located. By searching for fluid particles in these 27 grids, the neighbor particles whose distance to the current fluid particle is less than The fluid particle is recorded as the neighbor particle of the current fluid particle; the hash value The calculation formula is: ; in, , , is the center coordinate of the grid where the fluid particles are located, is an XOR operation, is the size of the hash table, is the remainder operation, is the radius within which the fluid particle searches for neighbors.
6. The interactive simulation method of fluid and thin film solid according to claim 4, characterized in that: For fluid particles with a density greater than the static density, the position of the fluid particles is corrected according to the density invariance constraint formula to satisfy the constraint, including: ; ; in, For the Particles, For the The subscript of the neighbor particles of a particle, is the relative subscript index of the particle involved in the density constraint, is the static density of the fluid, is the corrected position, is the kernel function gradient, is a relaxation factor introduced to prevent the denominator from being zero. and is the scaling factor, and is the predicted position of the fluid particles, is the neighbor particle search radius, is the constraint function, For along Direction gradient.
7. The interactive simulation method of fluid and thin film solid according to claim 1, characterized in that: The extended position-based dynamics algorithm is used to calculate the relevant information of the thin film solid according to the constraints of the thin film solid model, including: Predict the position of the vertex of the thin film solid model at the next moment according to the external force, and correct the vertex position of the thin film solid model according to the constraint correction formula; The constraint correction formula is: ; in, is the subscript of the triangle mesh vertex, is the inverse of mass, is the gradient of the constraint function, Is the matrix consisting of the vertices included in the constraint function ; Indicates the corrected position, Represents the predicted position of each vertex; The calculation formula is: ; in, is the accumulated value before the current constraint, , , is the inverse of the stiffness coefficient; represents the constraint function, Represents the inverse of mass, represents the gradient of the constraint function, is the first intermediate variable, is the second intermediate variable.
8. An interactive simulation system of fluid and thin film solid using the interactive simulation method of fluid and thin film solid according to any one of claims 1 to 7, characterized in that: include: A first constraint condition establishment module is configured to: construct a thin film solid model based on a real thin film solid, initialize thin film solid information, and establish constraint conditions for the thin film solid model; A second constraint condition establishment module is configured to: construct initial information of the fluid based on the real fluid and establish constraint conditions of the fluid; A first calculation module is configured to: use a position-based fluid algorithm to calculate the fluid according to the constraints of the fluid to obtain relevant information of the fluid; A second calculation module is configured to: calculate relevant information of the thin film solid according to the constraint conditions of the thin film solid model by using an extended position-based dynamics algorithm; A collision detection and response module is configured to: perform collision detection and collision response on the fluid and the thin film solid based on the obtained relevant information of the fluid and the thin film solid, and correct the positions of the fluid particles and the thin film solid that are detected to have collided to prevent penetration; A position updating module is configured to update the positions of the fluid and the thin film solid.
Citation Information
Patent Citations
Particle computer dynamic simulation method for 3D garment
CN106407605A
Fluid-structure interaction simulation method and system for deflection process of trailing edge of ram-type parafoil
CN113204911A