Flexible body simulation method, electronic device, storage medium, and computer program product
By combining the weights of linear and nonlinear elastic models in flexible body simulation and smoothing mesh changes, the problem of unstable simulation results in the existing technology is solved, and a flexible body simulation effect that takes into account real-time performance and authenticity is achieved.
Patent Information
- Application Number
- CN202410846979.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-27
AI Technical Summary
Existing flexible body simulation technology is difficult to balance real-time performance and authenticity, and usually requires a trade-off between real-time performance and authenticity, resulting in unstable simulation results or excessive calculations, making it impossible to achieve real-time simulation under hardware conditions.
By using the specified elastic model in the flexible body simulation, the distortion parameters and deformation state are determined according to the vertex coordinates of the mesh, and the weights of the linear and nonlinear elastic models are combined to smooth the transition to ensure the stability and real-time performance of the simulation results.
It achieves a flexible body simulation effect that takes into account real-time and authenticity while ensuring the stability of the simulation results, and improves the smoothness and efficiency of the simulation process.
Smart Images

Figure CN118395751B
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphic simulation technology, and in particular to a simulation method for a flexible body, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In the field of graphics, there is a very wide demand for flexible body simulation. Common simulated flexible bodies include rubber materials, human tissues, etc. For these flexible body materials, the academic community has conducted very extensive research. For example, the classic Neo-Hookean family nonlinear elastic model is a mechanical model used to describe this type of material. Their most notable feature is extremely small compressibility. During the deformation process, the volume of the material basically does not change. The volume parameter is related to the size of the material in different directions in three-dimensional space, and it has very high nonlinearity. This feature brings challenges to the simulation of flexible bodies. The high degree of nonlinearity of the material indicates that the material is very sensitive to deformation, and a small deformation may cause a large change in force. In order to improve the accuracy of the simulation calculation, the simulation time step is often required, such as only simulating 1 / 1000 second or even 1 / 10000 second each time. This means that in the real-time simulation process, the solver must perform at least 1000 or 10000 solution calculations per second, which is unrealistic under current hardware conditions, and even if the hardware is increased, the cost is too high. Therefore, the relevant schemes only focus on one of the characteristics of real-time and authenticity for flexible body simulation. If you choose to focus on real-time performance, you need to weaken the nonlinear characteristics of the flexible body, thereby significantly increasing the simulation time step. If you focus on authenticity, you need to reduce the simulation time step, increase the amount of calculation, and give up the real-time requirement.
[0003] However, with the continuous expansion of flexible body simulation applications and the increase in demand, the requirements for real-time and authenticity of flexible body simulation are also increasing. A reasonable simulation solution is urgently needed so that flexible body simulation can take into account both real-time and authenticity effects. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a simulation method for a flexible body and an electronic device, a storage medium, and a computer program product, which are used to ensure a smooth transition between linear and nonlinear parts within a specified elastic model, ensure the stability of the simulation results during mesh changes, and update the vertex coordinates of the mesh using the specified elastic model as the mesh, thereby taking into account both real-time and authenticity requirements.
[0005] On the one hand, the present application provides a simulation method for a flexible body, comprising:
[0006] According to the vertex coordinates of each mesh of the flexible body at time t, the distortion parameter of the mesh is determined;
[0007] Based on the distortion parameters of each mesh, a deformation state of the mesh is determined, and based on the deformation state, a target constraint condition of a specified elastic model is determined; wherein the specified elastic model includes a linear elastic model and a nonlinear elastic model, and the target constraint condition includes weights of the linear elastic model and the nonlinear elastic model;
[0008] Based on the specified elastic model under the target constraint conditions corresponding to each mesh, the vertex coordinates of each mesh at time t+1 are determined.
[0009] In one embodiment, determining the distortion parameter of each mesh of the flexible body according to the vertex coordinates of the mesh at time t includes:
[0010] According to the vertex coordinates of each mesh at time t, the deformation gradient of the mesh is determined;
[0011] Based on the deformation gradient of each grid, determining the determinant of the deformation gradient and the modulus length of each column in the deformation gradient;
[0012] The distortion parameters of each grid are determined according to the determinant corresponding to the deformation gradient of each grid and the modulus length of each column.
[0013] In one embodiment, determining the deformation state of each mesh based on the distortion parameter of the mesh includes:
[0014] For each grid, determine whether the distortion parameter of the grid is a negative number, and determine whether the grid is flipped based on the determination result;
[0015] For each grid, it is determined whether the distortion parameter of the grid is within the collapse value range, and based on the determination result, it is determined whether the grid collapses.
[0016] In one embodiment, the linear elastic model characterizes the first sub-energy of the grid by the modulus of the deformation gradient of the grid in each column, the modulus of each rotational deformation gradient of the grid in each column, and the deformation strength of the flexible body in each column of the deformation gradient; wherein each rotational deformation gradient is obtained by rotating the deformation gradient around each coordinate axis;
[0017] The nonlinear elastic model characterizes the second sub-energy of the grid through the determinant of the deformation gradient and the volume deformation intensity of the grid;
[0018] The designated elastic model obtains the energy of the grid by weighted summing the first sub-energy and the second sub-energy through the weights of the linear elastic model and the nonlinear elastic model.
[0019] In one embodiment, the linear elastic model is:
[0020]
[0021] Among them, K i represents the deformation strength of the flexible body in the i-th column of the deformation gradient; |F i | represents the modulus of the i-th column of the deformation gradient; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the X-axis; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Y axis; represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Z axis;
[0022] The nonlinear elastic model is:
[0023]
[0024] Where λ represents the volume deformation intensity and det(F) is the determinant of the deformation gradient.
[0025] In one embodiment, determining the target constraint condition of the specified elastic model based on the deformation state includes:
[0026] For any grid, if the grid flips and collapses, the weights of the linear elastic model and the nonlinear elastic model are determined based on the distortion parameters of the grid;
[0027] Correcting the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient;
[0028] Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model;
[0029] The weights of the linear elastic model and the nonlinear elastic model, the modified deformation gradient in the linear elastic model, and the minimum angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraints of the grid.
[0030] In one embodiment, determining the target constraint condition of the specified elastic model based on the deformation state includes:
[0031] For any grid, if the grid flips but does not collapse, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the grid;
[0032] Correcting the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient;
[0033] The weights of the linear elastic model and the nonlinear elastic model, and the modified deformation gradient in the linear elastic model are used as target constraint conditions of the grid.
[0034] In one embodiment, determining the target constraint condition of the specified elastic model based on the deformation state includes:
[0035] For any grid, if the grid collapses but does not flip, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the grid;
[0036] Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model;
[0037] The weights of the linear elastic model and the nonlinear elastic model and the minimum value of the angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraint conditions of the grid.
[0038] In one embodiment, determining the target constraint condition of the specified elastic model based on the deformation state includes:
[0039] For any grid, if the grid does not collapse and does not flip, the weights of the linear elastic model and the nonlinear elastic model are determined to be default values.
[0040] In one embodiment, the step of correcting the deformation gradient of the grid in the linear elastic model to obtain the corrected deformation gradient includes:
[0041] Perform singular value decomposition on the deformation gradient of the grid to obtain two rotation matrices and a diagonal matrix;
[0042] The negative numbers in the diagonal matrix are set to zero to obtain an adjusted matrix;
[0043] The modified deformation gradient of the grid is determined by using the adjusted matrix and the two rotation matrices, and is used for the linear elastic model of the grid.
[0044] On the other hand, the present application provides an electronic device, the electronic device comprising:
[0045] processor;
[0046] a memory for storing processor-executable instructions;
[0047] Wherein, the processor is configured to execute the above-mentioned flexible body simulation method.
[0048] Furthermore, the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program can be executed by a processor to complete the above-mentioned flexible body simulation method.
[0049] In addition, the present application provides a computer program product, including a computer program / instruction, which implements the above-mentioned flexible body simulation method when executed by a processor.
[0050] In the present application scheme, during the flexible body simulation process, at time t, the distortion parameters of the mesh can be determined according to the vertex coordinates of each mesh, and then the deformation state of the mesh can be determined by the distortion parameters, and the target constraint conditions corresponding to the mesh can be further determined by the deformation state, and the target constraint conditions include the weight of the linear elastic model and the weight of the nonlinear elastic model in the specified elastic model. In this case, the vertex coordinates of each mesh at time t+1 can be updated according to the energy calculated by the specified elastic model under the target constraint conditions. At each moment in this process, the weights of the linear elastic model and the nonlinear elastic model in the specified elastic model for calculating energy for the mesh can be determined according to the deformation state of each mesh, thereby ensuring the smooth transition of the linear and nonlinear parts in the specified elastic model and the stability of the simulation results during the mesh change process. Therefore, updating the vertex coordinates of the mesh with the specified elastic model as the mesh can take into account the requirements of real-time and authenticity, obtain good flexible body simulation effects, and achieve smooth changes in the visual effects of flexible body deformation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings required for use in the embodiments of the present application are briefly introduced below.
[0052] Figure 1 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application;
[0053] Figure 2 A schematic diagram of a flow chart of a simulation method for a flexible body provided in one embodiment of the present application;
[0054] Figure 3 An embodiment of the present application provides Figure 2 Detailed flowchart of step 210;
[0055] Figure 4 A schematic diagram of a tetrahedron before deformation provided by an embodiment of the present application;
[0056] Figure 5 A schematic diagram of a deformed tetrahedron provided in an embodiment of the present application;
[0057] Figure 6 A schematic diagram of grid flipping provided in an embodiment of the present application;
[0058] Figure 7 A flowchart of a method for determining target constraint conditions provided in an embodiment of the present application;
[0059] Figure 8 A schematic diagram of a grid deformation provided in an embodiment of the present application;
[0060] Fig. 9 A flowchart of a method for determining target constraint conditions provided in another embodiment of the present application;
[0061] Fig.10 A flowchart of a method for determining target constraint conditions provided in yet another embodiment of the present application;
[0062] Fig.11 A block diagram of a flexible body simulation device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0063] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0064] Similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0065] like Figure 1 As shown, this embodiment provides an electronic device 1, including: at least one processor 11 and a memory 12, Figure 1 A processor 11 is taken as an example. The processor 11 and the memory 12 are connected via a bus 10. The memory 12 stores instructions that can be executed by the processor 11. The instructions are executed by the processor 11 so that the electronic device 1 can execute all or part of the process of the method in the following embodiment. In one embodiment, the electronic device 1 can be a host, a server, a server cluster or a cloud computing center and other intelligent devices, which are used to execute the simulation method of the flexible body.
[0066] The memory 12 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0067] The present application also provides a computer-readable storage medium, which stores a computer program. The computer program can be executed by the processor 11 to complete the flexible body simulation method provided by the present application.
[0068] The present application also provides a computer program product, including a computer program / instruction, which implements the flexible body simulation method provided in the present application when the computer program / instruction is executed by a processor.
[0069] See also Figure 2 , is a flow chart of a simulation method for a flexible body provided in an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps 210 to 230.
[0070] Step 210: Determine the distortion parameters of each mesh of the flexible body according to the vertex coordinates of the mesh at time t.
[0071] In the graphic simulation, the flexible body is composed of multiple meshes, where the meshes are three-dimensional meshes, and the form of the meshes can be set according to the application requirements. Exemplarily, the meshes constituting the flexible body are tetrahedrons, hexahedrons, octahedrons, dodecahedrons, etc. Each mesh has multiple vertices. During the simulation of the flexible body, it is in a state of motion and / or deformation due to the force. Therefore, the simulation process needs to continuously update the vertex coordinates of each mesh of the flexible body.
[0072] Time t is any time after the start of the flexible body simulation. At time t, the distortion parameters of each mesh can be calculated based on the vertex coordinates of each mesh, and the distortion parameters represent the deformation state of the mesh.
[0073] Step 220: Based on the distortion parameters of each grid, determine the deformation state of the grid, and determine the target constraint conditions of the specified elastic model based on the deformation state; wherein the specified elastic model includes a linear elastic model and a nonlinear elastic model, and the target constraint conditions include weights of the linear elastic model and the nonlinear elastic model.
[0074] After the distortion parameters of each grid are obtained, the deformation state corresponding to the distortion parameters can be determined. Here, the deformation state may include but is not limited to flipping, collapsing, not flipping, not collapsing, etc.
[0075] After determining the deformation state of any mesh, the target constraint condition of the specified elastic model corresponding to the mesh can be determined. The specified elastic model includes a linear elastic model and a nonlinear elastic model. Therefore, the weight of the linear elastic model in the specified elastic model and the weight of the nonlinear elastic model in the specified elastic model can be determined based on the deformation state.
[0076] Step 230: Determine the vertex coordinates of each mesh at time t+1 based on the specified elastic model under the target constraint condition corresponding to each mesh.
[0077] After determining the corresponding target constraint conditions for each grid, the energy of each grid can be characterized by specifying the elastic model of each grid under the target constraint conditions. The energy of any grid represents the elastic potential energy generated by the deformation of the flexible body in the grid.
[0078] Based on the specified elastic model of each mesh under the target constraint conditions, the first-order and second-order derivatives of the position are obtained, and the force and Hessian matrix can be derived. The former is the force on each vertex of the mesh, and the latter is the resistance strength of each vertex of the mesh to deformation.
[0079] After obtaining the forces and Hessian matrices corresponding to all meshes in the flexible body, the vertex coordinates of each mesh at time t+1 can be updated based on the vertex coordinates of each mesh at time t.
[0080] Through the above measures, in the flexible body simulation process, at time t, the distortion parameters of the mesh can be determined according to the vertex coordinates of each mesh, and then the deformation state of the mesh can be determined by the distortion parameters, and the target constraint conditions corresponding to the mesh can be further determined by the deformation state. The target constraint conditions include the weight of the linear elastic model and the weight of the nonlinear elastic model in the specified elastic model. In this case, the vertex coordinates of each mesh at time t+1 can be updated according to the energy calculated by the specified elastic model under the target constraint conditions. In this process, at each moment, the weights of the linear elastic model and the nonlinear elastic model in the specified elastic model for calculating energy for the mesh can be determined according to the deformation state of each mesh, thereby ensuring the smooth transition of the linear and nonlinear parts in the specified elastic model and the stability of the simulation results during the mesh change process. Therefore, updating the vertex coordinates of the mesh with the specified elastic model as the mesh can take into account the requirements of real-time and authenticity, obtain good flexible body simulation effects, and realize smooth changes in the visual effects of flexible body deformation.
[0081] In one embodiment, see Figure 3 , provided in one embodiment of the present application Figure 2 Detailed flowchart of step 210 in FIG. 2 , when step 210 is executed to calculate the distortion parameters, the following steps 211 to 213 may be executed.
[0082] Step 211: Determine the deformation gradient of each mesh according to the vertex coordinates of the mesh at time t.
[0083] In this solution, the method of calculating the deformation gradient for the grid may include but is not limited to the finite element method, the finite volume method, the MPM (Material Point Method, physical point method), etc.
[0084] Take the mesh as a tetrahedron and the deformation gradient calculated by the finite element method as an example, see Figure 4 , is a schematic diagram of a tetrahedron before deformation provided by an embodiment of the present application, Figure 4 One of the tetrahedrons is in an undeformed state, that is, the initial state of the tetrahedron in the flexible body. At this time, the coordinates of the four vertices of the tetrahedron can be recorded as X0, X1, X2, and X3. Figure 5 , is a schematic diagram of a deformed tetrahedron provided in an embodiment of the present application, Figure 5 yes Figure 4 The tetrahedron in is in a deformed state. At this time, the coordinates of the four vertices of the tetrahedron can be recorded as x0, x1, x2, and x3. The deformation process of the tetrahedron can be expressed by the following formula (1):
[0085] (1)
[0086] Among them, X0, X1, X2, and X3 are the coordinates of the four vertices of the mesh in the undeformed state; x0, x1, x2, and x3 are the coordinates of the four vertices of the mesh in the deformed state; and F is the deformation gradient of the mesh.
[0087] At time t, for any mesh, the vertex coordinates in the initial state can be substituted into formula (1), and the vertex coordinates of each vertex at time t can be substituted into formula (1) to calculate the deformation gradient of the mesh. In the case of a tetrahedron, the deformation gradient is a 3*3 transformation matrix, which represents the deformation information of the tetrahedron from an undeformed state to a deformed state. If the mesh is another polyhedron, the number of vertex coordinates in formula (1) can be adaptively adjusted to calculate the deformation gradient.
[0088] Step 212: Based on the deformation gradient of each grid, determine the determinant of the deformation gradient and the modulus of each column in the deformation gradient.
[0089] Step 213: Determine the distortion parameters of each grid according to the determinant corresponding to the deformation gradient of each grid and the modulus length of each column.
[0090] After obtaining the deformation gradient of any grid, the determinant and the modulus of each column can be determined for the deformation gradient. Here, each column of the deformation gradient can be regarded as a column vector. The deformation gradient is denoted by F, F i represents the i-th column in the matrix F, that is, the i-th column vector, whose modulus length |F i | represents the deformation rate of the grid in the i-th column.
[0091] For example, the distortion parameter of the grid can be calculated by the following formula (2):
[0092] (2)
[0093] Where s is the distortion parameter; det(F) is the determinant of the deformation gradient F; |F i | is the modulus length of the i-th column in the deformation gradient F.
[0094] Through the above measures, the corresponding distortion parameters can be calculated for each mesh based on the vertex coordinates.
[0095] In one embodiment, when executing step 220, for each grid, it can be determined whether the distortion parameter of the grid is a negative number, and whether the grid is flipped is determined based on the determination result.
[0096] Mesh flipping refers to any vertex of a mesh penetrating its corresponding mesh face. Figure 6 , is a schematic diagram of a grid flipping provided in an embodiment of the present application, such as Figure 6As shown, the vertex coordinates of the four vertices of the mesh before flipping are X0, X1, X2, and X3, and the vertex coordinates of the four vertices of the mesh after flipping are X0, X1, X2', and X3. The vertex with vertex coordinate X2 passes through the plane X0X1X3, and the mesh is flipped. The tetrahedrons are in a mirror relationship before and after flipping.
[0097] When the grid is flipped, the determinant of the deformation gradient of the grid is negative, while the modulus of each column in the deformation gradient is always positive. Therefore, if the distortion parameter of any grid is negative, the grid is flipped; if the distortion parameter of any grid is positive, the grid is not flipped.
[0098] For each grid, it can be determined whether the distortion parameter of the grid is within the collapse value range, and whether the grid collapses based on the judgment result. When the grid collapses, the determinant of the deformation gradient of the grid will be close to 0, so that the distortion parameter is close to 0. Therefore, configuring the collapse data range can indicate the range of the distortion parameter when the grid collapses. The collapse value range can be set as needed. For example, the collapse value range is [-0.1, 0.1]. If the distortion parameter of any grid is within the collapse value range, the grid collapses; if the distortion parameter of any grid is not within the collapse value range, the grid does not collapse.
[0099] Through the above measures, the deformation state of each mesh can be determined based on the distortion parameters of the mesh.
[0100] In one embodiment, the linear elastic model characterizes the first sub-energy of the grid by the modulus of the deformation gradient of the grid in each column, the modulus of the deformation gradient of each rotation of the grid in each column, and the deformation strength of the flexible body in each column of the deformation gradient, wherein each rotational deformation gradient is obtained by rotating the deformation gradient around each coordinate axis.
[0101] The deformation gradient F of any grid is the transformation matrix. The deformation gradient F is rotated 45 degrees around the X axis to obtain the rotated deformation gradient F x45 ; The deformation gradient F is rotated 45 degrees around the Y axis to obtain the rotated deformation gradient F y45 ; The deformation gradient F is rotated 45 degrees around the Z axis to obtain the rotated deformation gradient F z45 .
[0102] The linear elastic model includes the deformation gradient F in each column of the modulus length |F i |、Deformation gradient F after rotation x45 The module length in each column , deformation gradient after rotation F y45 The module length in each column , deformation gradient after rotation F z45 The module length in each column , and the deformation strength K of the flexible body in each column of the deformation gradient i Here, for any flexible body, the deformation strength can be preconfigured for it.
[0103] The nonlinear elastic model characterizes the second sub-energy of the mesh through the determinant of the deformation gradient and the volume deformation intensity of the mesh. Here, the volume deformation intensity is a physical characteristic of the flexible body material itself and can be pre-configured in the simulation software.
[0104] The elastic model is specified to obtain the energy of the grid by weighted summing the first sub-energy and the second sub-energy through the weights of the linear elastic model and the nonlinear elastic model.
[0105] For example, the specified elastic model can be expressed by the following formula (3):
[0106] (3)
[0107] Among them, Ψ1 represents the linear elastic model; Ψ2 represents the nonlinear elastic model; the weight of the linear elastic model is the default value 1, and the weight of the nonlinear elastic model is α.
[0108] In one embodiment, the linear elastic model can be expressed by the following formula (4):
[0109] (4)
[0110] Among them, K i represents the deformation intensity of the flexible body in the i-th column of the deformation gradient; |F i | represents the modulus of the i-th column of the deformation gradient; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the X-axis; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Y axis; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Z axis.
[0111] The first term on the right side of this linear elastic model describes the elastic potential energy generated by the axial deformation of the mesh along the coordinate axis, and the last three terms describe the elastic potential energy generated by the angle changes between the three coordinate axes. This linear elastic model is highly stable and can maintain stable simulation even in various extreme deformation states (for example, when the mesh collapses into a surface, an edge, or even a point).
[0112] The nonlinear elastic model can be expressed by the following formula (5):
[0113] (5)
[0114] Among them, λ represents the volume deformation intensity; det(F) is the determinant of the deformation gradient, which means the volume change rate.
[0115] This nonlinear elastic model describes the response of an elastic material to a volume change, where the determinant of the deformation gradient is highly nonlinear and proportional to the product of the deformation of the mesh in the three coordinate axes.
[0116] In one embodiment, see Figure 7 , is a flow chart of a method for determining target constraint conditions provided in an embodiment of the present application, such as Figure 7 As shown, when determining the target constraint condition according to the deformation state, the following steps 710 to 740 may be performed.
[0117] Step 710: For any mesh, if the mesh is flipped and collapsed, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the mesh.
[0118] When the grid flips and collapses, the weight of the linear elastic model and the weight of the nonlinear elastic model can be calculated according to the distortion parameters of the grid.
[0119] For example, for the specified elastic model shown in formula (3), it is only necessary to determine the weight of the nonlinear elastic model. For example, the weight of the nonlinear elastic model can be determined by the following formula (6):
[0120] (6)
[0121] Among them, e is a natural constant and s is a distortion parameter.
[0122] In this case, when the mesh is flipped, the weight of the nonlinear elastic model is 0 because the distortion parameter is less than 0, and the specified elastic model only contains the linear elastic model. When the mesh is not flipped, the weight of the nonlinear elastic model changes significantly when the distortion parameter is close to 0. In other cases, the weight of the nonlinear elastic model is approximately 1, which is close to the weight of the linear elastic model.
[0123] When the mesh deformation is small, a more realistic nonlinear elastic model can be used to ensure the simulation effect. When the mesh is unstable, the nonlinear elastic model is weakened or even cancelled and switched to a stable linear elastic model, which makes it easier for the mesh to quickly return to normal, showing a high degree of simulation stability and improving the real-time performance of the simulation.
[0124] Step 720: Correct the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient.
[0125] In the case of mesh flipping, the deformation gradient of the mesh needs to be corrected to obtain a corrected deformation gradient. Here, the corrected deformation gradient is only used for the linear elastic model and has nothing to do with the nonlinear elastic model corresponding to the mesh.
[0126] After obtaining the corrected deformation gradient, the corrected deformation gradient can be rotated around each coordinate axis to obtain three rotated deformation gradients. Furthermore, the modulus length of the corrected deformation gradient in each column and the modulus length of each rotated deformation gradient in each column are substituted into the linear elastic model of the grid.
[0127] Step 730: Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model.
[0128] In the simulation algorithm, although the nonlinear elastic model represents the second sub-energy of the grid, when actually updating the vertex coordinates of the grid, what is needed is the force and Hessian matrix derived from the nonlinear elastic model. Here, the force is the first-order derivative of the second sub-energy indicated by the nonlinear elastic model with respect to the position, and the Hessian matrix is the second-order derivative of the second sub-energy indicated by the nonlinear elastic model with respect to the position.
[0129] See also Figure 8 , is a schematic diagram of a grid deformation provided in an embodiment of the present application, such as Figure 8 The tetrahedron in is not the mesh itself, but is constructed based on the column vectors F0, F1, and F2 in the mesh's deformation gradient. The tetrahedron can indicate the deformation state of the mesh. When the mesh volume changes, the force on the edge F0 is always parallel to the surface. The normal of the volume is in the direction of volume recovery, which is also the direction of the fastest volume recovery. When the edge F1 and the edge F2 collapse into a line, , which makes it impossible to determine the direction of the force on edge F0. In this case, the Hessian matrix of the grid is also 0. As a result, the grid has neither force to restore the volume nor resistance in the F0 direction, which is equivalent to the existence of no grid in this direction, and the grid cannot restore the volume.
[0130] To avoid this problem, after determining that any grid collapses, this extreme case can be restricted, that is, the minimum angle between the column vectors of the deformation gradient in the nonlinear elastic model is set to ensure that the force and Hessian matrix are not zero. For example: Figure 8When the middle edge F1 and edge F2 collapse into a line, the angle is 0. Since the minimum angle has been set, the minimum angle is greater than 0, which is equivalent to randomly assigning a force direction to edge F0 to ensure that it will not fall into an extreme state where the force direction cannot be calculated. In this case, the stability of the nonlinear elastic model can be guaranteed, and it can stably withstand local force concentration or sudden external forces (such as violent dragging of the flexible body) during the simulation process.
[0131] Here, the minimum angle cannot be too large, otherwise it will affect the calculation of the grid volume. The grid volume is 0 when collapsed. After setting the minimum angle, the volume is no longer 0, but must be close to 0. For example, the minimum angle corresponding to each column of the deformation gradient in the nonlinear elastic model is 0.003.
[0132] Step 740: The weights of the linear elastic model and the nonlinear elastic model, the corrected deformation gradient in the linear elastic model, and the minimum angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraints for the grid.
[0133] When the weight of the linear elastic model, the weight of the nonlinear elastic model, the minimum value of the angle between the modified deformation gradient in the linear elastic model and the deformation gradient column vector in the nonlinear elastic model are obtained, the target constraint condition of the grid when it is flipped and collapsed is obtained.
[0134] In one embodiment, see Fig. 9 , is a flow chart of a method for determining target constraint conditions provided by another embodiment of the present application, such as Fig. 9 As shown, when determining the target constraint condition according to the deformation state, the following steps 910 to 930 may be performed.
[0135] Step 910: For any mesh, if the mesh is flipped but not collapsed, the weights of the linear elastic model and the nonlinear elastic model are determined based on the distortion parameters of the mesh.
[0136] Step 920: Correct the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient.
[0137] The specific execution process of step 910 to step 920 may refer to the contents of the aforementioned step 710 to step 720.
[0138] Step 930: The weights of the linear elastic model and the nonlinear elastic model, and the modified deformation gradient in the linear elastic model are used as target constraints of the grid.
[0139] After obtaining the weight of the linear elastic model, the weight of the nonlinear elastic model, and the modified deformation gradient in the linear elastic model, the target constraint condition of the grid when flipping but not collapsing occurs can be obtained.
[0140] In one embodiment, see Fig.10 , which is a flow chart of a method for determining target constraints provided by another embodiment of the present application, such as Fig.10 As shown, when determining the target constraint condition according to the deformation state, the following steps 1010 to 1030 may be performed.
[0141] Step 1010: For any grid, if the grid collapses but does not flip, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the grid.
[0142] The specific execution process of step 1010 may refer to the content of the aforementioned step 710.
[0143] Step 1020: Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model.
[0144] The specific execution process of step 1020 may refer to the content of the aforementioned step 730.
[0145] Step 1030: The weights of the linear elastic model and the nonlinear elastic model, and the minimum angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraints of the grid.
[0146] After obtaining the weight of the linear elastic model, the weight of the nonlinear elastic model, and the minimum angle between the deformation gradient column vectors in the nonlinear elastic model, the target constraint condition of the grid when it collapses but does not flip is obtained.
[0147] In one embodiment, for any grid, if the grid has not collapsed and has not flipped, the weights of the linear elastic model and the nonlinear elastic model may be determined to be default values.
[0148] Here, the default weight values of the linear elastic model and the nonlinear elastic model can be configured according to application requirements. For example, the default weight values of the linear elastic model and the nonlinear elastic model are both 1.
[0149] In this case, the default values of the weights for the linear elastic model and the nonlinear elastic model can be used as objective constraints for the specified elastic model for the grid.
[0150] In one embodiment, since the linear elastic model is a function of the deformation modulus, it cannot reflect the mirror relationship of the mesh when flipped, and the mesh cannot be actively restored after flipping through the linear elastic model. When the deformation gradient of the mesh in the linear elastic model is corrected to obtain the corrected deformation gradient, the deformation gradient of the mesh can be subjected to singular value decomposition (SVD) to obtain two rotation matrices and a diagonal matrix.
[0151] For example, the SVD decomposition of the deformation gradient can be expressed by the following formula (7):
[0152] (7)
[0153] Among them, F is the deformation gradient; U and V are rotation matrices; Σ is a diagonal matrix.
[0154] The diagonal matrix can be expressed as , where the three elements are the deformation of the grid in different coordinate axis directions. If any element is negative, it means that the grid has flipped in the coordinate axis direction corresponding to the element. Therefore, the negative numbers in the diagonal matrix can be set to zero to obtain the adjusted matrix. For example, if σ1 in the diagonal matrix is negative, the adjusted matrix is expressed as .
[0155] After obtaining the adjusted matrix, the modified deformation gradient of the grid is determined by using the adjusted matrix and the two rotation matrices decomposed previously. By substituting the adjusted matrix and the two rotation matrices into formula (7), the modified deformation gradient can be obtained, which can be used for the linear elastic model of the grid.
[0156] By this measure, the negative numbers in the diagonal matrix are set to zero, and the contribution of the flipping principal axis to the elastic force can be abandoned, because it will hinder the recovery of the flipped mesh. Therefore, after obtaining the corrected deformation gradient, the remaining deformation information in the corrected deformation gradient can flip the mesh back.
[0157] Fig.11 is a block diagram of a simulation device for a flexible body according to an embodiment of the present invention. Fig.11 As shown, the device may include:
[0158] A first determination module 1110 is used to determine the distortion parameter of each mesh of the flexible body according to the vertex coordinates of the mesh at time t;
[0159] A second determination module 1120 is used to determine the deformation state of each mesh based on the distortion parameter of the mesh, and determine the target constraint condition of the specified elastic model based on the deformation state; wherein the specified elastic model includes a linear elastic model and a nonlinear elastic model, and the target constraint condition includes the weights of the linear elastic model and the nonlinear elastic model;
[0160] The third determination module 1130 is used to determine the vertex coordinates of each mesh at time t+1 based on the specified elastic model under the target constraint condition corresponding to each mesh.
[0161] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned flexible body simulation method, and will not be repeated here.
[0162] In several embodiments provided in the present application, the disclosed devices and methods may also be implemented in other ways. The device embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0163] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0164] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
Claims
1. A simulation method for a flexible body, characterized in that: include: Determining the distortion parameters of each mesh of the flexible body according to the vertex coordinates of the mesh at time t, including: determining the deformation gradient of the mesh according to the vertex coordinates of each mesh at time t; determining the determinant of the deformation gradient and the modulus of each column in the deformation gradient based on the deformation gradient of each mesh; determining the distortion parameters of the mesh according to the determinant corresponding to the deformation gradient of each mesh and the modulus of each column; Based on the distortion parameters of each grid, the deformation state of the grid is determined, and based on the deformation state, the target constraint condition of the specified elastic model is determined; wherein the specified elastic model includes a linear elastic model and a nonlinear elastic model, and the target constraint condition includes the weights of the linear elastic model and the nonlinear elastic model; the deformation state of the grid is determined based on the distortion parameters of each grid, including: for each grid, judging whether the distortion parameter of the grid is a negative number, and determining whether the grid is flipped based on the judgment result; for each grid, judging whether the distortion parameter of the grid is within a collapse value range, and determining whether the grid is collapsed based on the judgment result; Based on the specified elastic model under the target constraint conditions corresponding to each mesh, the vertex coordinates of each mesh at time t+1 are determined.
2. The method according to claim 1, characterized in that The linear elastic model characterizes the first sub-energy of the grid by the modulus of the deformation gradient of the grid in each column, the modulus of each rotational deformation gradient of the grid in each column, and the deformation strength of the flexible body in each column of the deformation gradient; wherein each rotational deformation gradient is obtained by rotating the deformation gradient around each coordinate axis; The nonlinear elastic model characterizes the second sub-energy of the grid through the determinant of the deformation gradient and the volume deformation intensity of the grid; The designated elastic model obtains the energy of the grid by weighted summing the first sub-energy and the second sub-energy through the weights of the linear elastic model and the nonlinear elastic model.
3. The method according to claim 2, characterized in that The linear elastic model is: Among them, K i represents the deformation strength of the flexible body in the i-th column of the deformation gradient; |F i | represents the modulus of the i-th column of the deformation gradient; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the X-axis; Represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Y axis; represents the modulus of the i-th column of the deformation gradient after the deformation gradient is rotated 45 degrees around the Z axis; The nonlinear elastic model is: Where λ represents the volume deformation intensity and det(F) is the determinant of the deformation gradient.
4. The method according to claim 2, characterized in that The determining of the target constraint condition of the specified elastic model based on the deformation state includes: For any grid, if the grid flips and collapses, the weights of the linear elastic model and the nonlinear elastic model are determined based on the distortion parameters of the grid; Correcting the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient; Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model; The weights of the linear elastic model and the nonlinear elastic model, the modified deformation gradient in the linear elastic model, and the minimum angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraints of the grid.
5. The method according to claim 2, characterized in that: The determining of the target constraint condition of the specified elastic model based on the deformation state includes: For any grid, if the grid flips but does not collapse, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the grid; Correcting the deformation gradient of the grid in the linear elastic model to obtain a corrected deformation gradient; The weights of the linear elastic model and the nonlinear elastic model, and the modified deformation gradient in the linear elastic model are used as target constraint conditions of the grid.
6. The method according to claim 2, characterized in that The determining of the target constraint condition of the specified elastic model based on the deformation state includes: For any grid, if the grid collapses but does not flip, determine the weights of the linear elastic model and the nonlinear elastic model based on the distortion parameters of the grid; Setting the minimum angle between the deformation gradient column vectors of the grid in the nonlinear elastic model; The weights of the linear elastic model and the nonlinear elastic model and the minimum value of the angle between the deformation gradient column vectors in the nonlinear elastic model are used as target constraint conditions of the grid.
7. The method according to claim 2, characterized in that The determining of the target constraint condition of the specified elastic model based on the deformation state includes: For any grid, if the grid does not collapse and does not flip, the weights of the linear elastic model and the nonlinear elastic model are determined to be default values.
8. The method according to claim 4 or 5, characterized in that: The step of correcting the deformation gradient of the grid in the linear elastic model to obtain the corrected deformation gradient includes: Perform singular value decomposition on the deformation gradient of the grid to obtain two rotation matrices and a diagonal matrix; The negative numbers in the diagonal matrix are set to zero to obtain an adjusted matrix; The modified deformation gradient of the grid is determined by using the adjusted matrix and the two rotation matrices, and is used for the linear elastic model of the grid.
9. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to execute the flexible body simulation method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program can be executed by a processor to complete the flexible body simulation method according to any one of claims 1 to 8.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the flexible body simulation method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
An elastic deformation simulation method based on linear differential operator
CN101216950A
A method for accelerating the finite element solution of elastic deformation of object mesh model
CN108986220A
