Fabric simulation method, device, electronic device and storage medium
By establishing dynamic edges in the finite element grid and using graph neural networks to correct simulation results, the accuracy problem of cloth simulation under low-resolution grids is solved, and efficient cloth motion simulation is achieved.
Patent Information
- Application Number
- CN202410662959.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-27
AI Technical Summary
In fabric simulation based on finite element analysis, the low-resolution finite element mesh cannot accurately simulate the fine-grained fabric wrinkle effect, and the existing correction methods are computationally intensive and have large errors.
By constructing a finite element mesh and establishing dynamic edges in the initial simulation results, the pre-trained graph neural network model is used to correct the motion position and speed, and the final simulation results are generated by combining the connection relationships between static and dynamic edges.
It improves the accuracy of finite element simulation results, reduces calculation costs, and can more accurately simulate irregular collisions in cloth movement.
Smart Images

Figure CN118246294B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of simulation, and in particular to a cloth simulation method, device, electronic device and storage medium. Background Art
[0002] In cloth simulation based on finite element analysis, the resolution of the finite element mesh has a great influence on the results of cloth simulation. Low-resolution finite element mesh cannot accurately simulate fine-grained cloth wrinkle effects.
[0003] In related technologies, although the simulation results of low-resolution finite element meshes can be corrected to a certain extent through high-order finite element methods, nonlinear compression deformation methods, or strain limiting methods, these methods will not only greatly increase the amount of calculation, but also there will still be a large error between the correction results and the actual situation. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a cloth simulation method, device, electronic device and storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a cloth simulation method, comprising:
[0006] Constructing a finite element mesh of the cloth, the finite element mesh comprising a plurality of nodes and a plurality of static edges for connecting the plurality of nodes;
[0007] Simulating the motion state of the cloth based on the finite element mesh to obtain an initial simulation result of the cloth, wherein the initial simulation result includes the motion positions and motion speeds of the multiple nodes;
[0008] For every two nodes among the plurality of nodes, if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length, and there is no static edge between the two nodes, then a dynamic edge is established between the two nodes;
[0009] The motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes are input into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result; wherein the connection relationship of the multiple nodes includes a connection relationship based on static edges and a connection relationship based on dynamic edges, and the result correction amount includes a position correction amount for the motion position and a speed correction amount for the motion speed;
[0010] The initial simulation result is corrected based on the result correction amount to obtain a final simulation result of the cloth model.
[0011] In some embodiments, the graph neural network model includes an encoder, a feature processing unit, and a decoder;
[0012] The step of inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result includes:
[0013] Inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into the encoder to obtain node features of the multiple nodes and edge features of multiple mesh edges; wherein the multiple mesh edges include each static edge of the multiple static edges and the dynamic edge;
[0014] Inputting the node features and the edge features into the feature processing unit to generate target node features of the plurality of nodes; wherein the feature processing unit is used to update the edge features based on the node features, and to update the node features based on the updated edge features;
[0015] The target node feature is input into the decoder to obtain a result correction amount of the initial simulation result.
[0016] In some embodiments, the encoder includes an edge encoding function and a node encoding function;
[0017] The step of inputting the motion position, the motion speed, the static positions of the plurality of nodes in the finite element mesh, and the connection relationship of the nodes into the encoder to obtain the node features of the plurality of nodes and the edge features of the plurality of mesh edges includes:
[0018] Inputting the motion position, the static position and the connection relationship of the nodes into the edge encoding function to obtain edge features of the plurality of mesh edges;
[0019] The movement position and the movement speed are input into the node encoding function to obtain the node features of the multiple nodes.
[0020] In some embodiments, the edge encoding function is used to encode the length and direction of each mesh edge of the plurality of mesh edges in the finite element mesh, and the length and direction of the mesh edge in the initial simulation result, as an edge feature of the mesh edge;
[0021] Wherein, for each static edge among the plurality of mesh edges, the edge encoding function is further used to determine the length and direction of the static edge in the finite element mesh based on the static position of each node connected to the static edge; and determine the length and direction of the static edge in the initial simulation result based on the motion position of each node connected to the static edge;
[0022] For each dynamic edge among the multiple mesh edges, the edge encoding function is also used to determine the length and direction of the dynamic edge in the initial simulation result based on the motion position of each node connected by the dynamic edge; determine the direction of the dynamic edge in the initial simulation result as the direction of the dynamic edge in the finite element mesh, and determine the preset distance length as the length of the dynamic edge in the finite element mesh.
[0023] In some embodiments, the feature processing unit includes at least one edge feature update function and at least one node feature update function alternately arranged, the edge feature update function is used to update the edge feature based on the node feature, and the node feature update function is used to update the node feature based on the edge feature;
[0024] In the alternately set feature update functions, the first feature update function is the edge feature update function or the node feature update function, the last feature update function is the node feature update function, and the result output by the last feature update function is the target node feature.
[0025] In some embodiments, the edge feature update function is specifically used to:
[0026] For each mesh edge among the plurality of mesh edges, an edge feature of the mesh edge is updated based on a node feature of each node connected to the mesh edge.
[0027] In some embodiments, the node feature update function is specifically used to:
[0028] For each node among the plurality of nodes, a node feature of the node is updated based on an edge feature of each mesh edge connected to the node.
[0029] In some embodiments, the decoder includes a position decoding function and a velocity decoding function;
[0030] The step of inputting the target node feature into the decoder to obtain a result correction amount of the initial simulation result includes:
[0031] The target node features are input into the position decoding function and the speed decoding function respectively to obtain the result correction amount.
[0032] In some embodiments, the encoder, the feature processing unit, and the decoder are all pre-trained multi-layer perceptrons.
[0033] According to a second aspect of an embodiment of the present disclosure, there is provided a cloth simulation device, comprising:
[0034] A construction module, used for constructing a finite element mesh of the cloth, wherein the finite element mesh includes a plurality of nodes and a plurality of static edges for connecting the plurality of nodes;
[0035] A simulation module, configured to simulate the motion state of the cloth based on the finite element mesh to obtain an initial simulation result of the cloth, wherein the initial simulation result includes the motion positions and motion speeds of the multiple nodes;
[0036] An establishing module, configured to establish a dynamic edge between each two nodes of the plurality of nodes if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length and there is no static edge between the two nodes;
[0037] An output module, used for inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result; wherein the connection relationship of the multiple nodes includes a connection relationship based on static edges and a connection relationship based on dynamic edges, and the result correction amount includes a position correction amount for the motion position and a speed correction amount for the motion speed;
[0038] The correction module is used to correct the initial simulation result based on the result correction amount to obtain a final simulation result of the cloth model.
[0039] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0040] Processor; and
[0041] A memory, configured to store executable instructions of the processor;
[0042] The processor is configured to execute the method described in the first aspect by executing the executable instructions.
[0043] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the first aspect is implemented.
[0044] The solution provided by the embodiment of the present disclosure can construct a finite element mesh of a cloth. The finite element mesh includes a plurality of nodes and a plurality of static edges for connecting the plurality of nodes. The motion state of the cloth is simulated based on the finite element mesh to obtain an initial simulation result of the cloth. The initial simulation result includes the motion position and motion speed of the plurality of nodes. For each two nodes among the plurality of nodes, if the distance between the two nodes in the initial simulation result is less than or equal to the preset distance length, and there is no static edge between the two nodes, a dynamic edge is established between the two nodes. By establishing a connection between two nodes that affect each other and are not directly connected by a static edge through a dynamic edge, the graph neural network model can capture the irregular collisions that occur in each node during the movement of the cloth. By inputting the motion position, motion speed, static positions of the plurality of nodes in the finite element mesh, and the connection relationship of the plurality of nodes into the pre-trained graph neural network model, a result correction amount of the initial simulation result can be obtained. The connection relationship of the plurality of nodes includes a connection relationship based on a static edge and a connection relationship based on a dynamic edge. The initial simulation result is corrected based on the result correction amount to obtain the final simulation result of the cloth model. The solution provided by the embodiment of the present disclosure can utilize graph neural networks to correct errors in finite element simulation results, thereby significantly improving the accuracy of finite element simulation results at a relatively low computational cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic flow chart of a cloth simulation method in an embodiment of the present disclosure is shown.
[0046] Figure 2 A schematic diagram showing a finite element mesh of a cloth according to an embodiment of the present disclosure.
[0047] Figure 3 A schematic diagram of a collision detection method between nodes in an initial simulation result in an embodiment of the present disclosure is shown.
[0048] Figure 4 A schematic diagram of the overall structure of the graph neural network model in an embodiment of the present disclosure is shown.
[0049] Figure 5 A schematic diagram of an encoder in an embodiment of the present disclosure is shown.
[0050] Figure 6 A schematic diagram of a feature processing unit in an embodiment of the present disclosure is shown.
[0051] Figure 7 A schematic diagram of a decoder in an embodiment of the present disclosure is shown.
[0052] Figure 8 A structural schematic diagram of a cloth simulation device in an embodiment of the present disclosure is shown.
[0053] Fig. 9 A schematic structural diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0054] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0055] First, a cloth simulation method is provided in an embodiment of the present disclosure, and the method can be executed by any electronic device.
[0056] Figure 1 A schematic diagram of a process of a cloth simulation method in an embodiment of the present disclosure is shown. Figure 1 As shown, the cloth simulation method provided in the embodiment of the present disclosure includes the following steps S101 to S105.
[0057] S101, constructing a finite element mesh of the cloth, where the finite element mesh includes a plurality of nodes and a plurality of static edges for connecting the plurality of nodes.
[0058] It should be noted that finite element analysis refers to the use of mathematical approximation methods to simulate real physical systems. By dividing complex structures into several simple and interacting elements (units), a finite number of unknown quantities can be used to simulate real physical systems with infinite unknown quantities.
[0059] In some embodiments, for cloth simulation, a pre-established cloth model may be divided into a plurality of triangular units, thereby obtaining a finite element mesh including a plurality of triangular units. The cloth model here may be a real clothing model or a cloth material sample model (for example, a rectangular piece of cloth) for simulation, which is not limited in the embodiments of the present disclosure.
[0060] For example, Figure 2 A schematic diagram showing a finite element mesh of a cloth.
[0061] exist Figure 2 In the simulation, the cloth model is divided into three triangular units, namely unit 0, unit 1 and unit 2, which together form a finite element mesh for cloth motion simulation. Each triangular unit includes three nodes and three static edges, and there are repeated nodes and static edges between adjacent triangular units.
[0062] Please continue to refer to Figure 2 , through observation, we can find that Figure 2 There are 5 independent nodes from node 0 to node 4, which can be represented by node numbers. For the static edges in the finite element mesh, in order to map them to the connection relationship between nodes, the static edges can be represented by the node numbers connected at both ends of each static edge. In other words, Figure 2 There are a total of 7 static edges: {0,1}, {0,3}, {0,4}, {1,2}, {1,3}, {2,3}, and {3,4}.
[0063] Those skilled in the art will know that Figure 2 The cloth model, unit shape and quantity shown in the figure are only for illustration. According to actual needs, cloth models and unit shapes of any shapes can be adopted, and the number of unit shapes can also be arbitrary, which is not limited in the embodiments of the present disclosure.
[0064] S102, simulating the motion state of the cloth based on the finite element mesh to obtain an initial simulation result of the cloth, wherein the initial simulation result includes motion positions and motion speeds of multiple nodes.
[0065] In some embodiments, the material properties (e.g., elastic modulus, Poisson's ratio, etc.) of each unit in the finite element mesh can be defined according to a general finite element analysis method, and boundary conditions (e.g., constraints, loads, etc.) can be defined at the same time, so that the motion state of the cloth can be simulated through the constructed finite element mesh to obtain an initial simulation result.
[0066] For example, the movement of the cloth during the simulation may be caused by the gravity of the cloth itself, or by the collision between the cloth and the cloth and / or the collision between the cloth and the rigid body. The rigid body that collides with the cloth may be a human body (the human body collides with the cloth during the movement) or other obstacles (the cloth collides with other obstacles after displacement), which is not limited in the embodiments of the present disclosure.
[0067] S103, for every two nodes among the multiple nodes, if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length, and there is no static edge between the two nodes, a dynamic edge is established between the two nodes.
[0068] As mentioned above, a large number of collisions may occur during the cloth simulation (collisions between cloth and / or collisions between cloth and rigid bodies). These collisions will cause interactions between nodes in the finite element mesh that are not connected by static edges, thereby generating new topological connections in the cloth's physical system. The topological connections generated by collisions are dynamic and may appear or disappear, without objective continuity. Therefore, collision detection is required for each node of the cloth in the initial simulation results.
[0069] Figure 3 A schematic diagram of a collision detection method between nodes in an initial simulation result is shown. Specifically, Figure 3 The collision between cloth nodes and the collision between cloth and rigid body are shown respectively.
[0070] In order to reduce the complexity of the neural network, the embodiment of the present disclosure may, for each two nodes among the plurality of nodes, if the distance between the two nodes in the initial simulation result is less than or equal to the preset distance length (i.e. Figure 3 ), it can be considered that the two nodes collide with each other.
[0071] In a finite element mesh, interconnected nodes can directly interact with each other. Therefore, the disclosed embodiment can establish dynamic edges between nodes that collide, thereby establishing a dynamic connection relationship between these nodes to characterize the interaction caused by the collision.
[0072] Based on this, Figure 3 If there is no static edge between the two nodes that collide with each other ( Figure 3 As shown by the solid line in the figure, a dynamic edge can be established between the two nodes ( Figure 3 denoted by dashed lines).
[0073] Among them, for the dynamic edges established in the initial simulation results, in order to be able to map them to the connection relationship between nodes, the dynamic edges can be represented by the node numbers connected at both ends of each dynamic edge.
[0074] S104, input the motion position, motion speed, static positions of multiple nodes in the finite element mesh, and connection relationships of multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result.
[0075] The connection relationship of the multiple nodes includes a connection relationship based on a static edge and a connection relationship based on a dynamic edge. The result correction includes a position correction for the motion position and a speed correction for the motion speed. The static positions of the multiple nodes in the finite element mesh can be understood as the positions of the multiple nodes in the finite element mesh constructed in S101, that is, the positions before the motion state simulation is performed using the finite element mesh.
[0076] It should be noted that the Graph Neural Networks (GNN) model is a type of machine learning model that learns and infers graph data (including nodes and edges). It can capture the local structure and global topological features of graph data, thereby effectively performing various machine learning tasks.
[0077] The disclosed embodiment can map multiple nodes in the above-mentioned finite element mesh to nodes in the graph data, and map the connection relationship between the multiple nodes to edges in the graph data, so that the graph neural network can capture the features in the finite element simulation results.
[0078] In some embodiments, among the various input quantities used to input the graph neural network model, the motion position and motion speed of the node can be mapped to the node information in the graph data. The connection relationship between the nodes, combined with the motion position and static position of the node, can be mapped to the edge information in the graph data, so that the graph neural network can process the result correction problem of finite element simulation.
[0079] S105, correcting the initial simulation result based on the result correction amount to obtain a final simulation result of the cloth model.
[0080] In some embodiments, for each node in the finite element mesh, by superimposing the movement position of the node in the initial simulation result with the position correction amount in the result correction amount, and superimposing the movement speed of the node in the initial simulation result with the speed correction amount in the result correction amount, the initial simulation result can be corrected to obtain the final simulation result of the cloth model.
[0081] Based on this, the disclosed embodiment can use the graph neural network to correct the errors in the finite element simulation results, thereby improving the accuracy of the finite element simulation results at a lower computational cost. In addition, for nodes that collide with each other during the cloth simulation process, the disclosed embodiment can establish dynamic edges between the colliding nodes, so that the graph neural network model can capture the irregular collisions that occur at each node in the finite element mesh during the cloth movement process, so that the corrected results can better simulate the cloth collision.
[0082] Combination of the above Figures 1 to 3 The overall inventive concept of the embodiment of the present disclosure is introduced. For ease of understanding, the following will be combined with Figures 4 to 7 , illustrating the specific structure of the graph neural network model in the embodiment of the present disclosure.
[0083] Figure 4 The overall structure diagram of the graph neural network model in the embodiment of the present disclosure is shown. Figure 4 As shown, the graph neural network model in the embodiment of the present disclosure may include an encoder, a feature processing unit, and a decoder.
[0084] based on Figure 4 In the graph neural network shown, the above S104 may specifically include:
[0085] S1041, input the motion position, motion speed, static positions of multiple nodes in the finite element mesh, and connection relationships of the multiple nodes into the encoder to obtain node features of the multiple nodes and edge features of the multiple mesh edges.
[0086] The multiple mesh edges include static edges initially existing in the finite element mesh and dynamic edges constructed based on collision detection.
[0087] S1042, input the node features and edge features into a feature processing unit to generate target node features of multiple nodes.
[0088] The feature processing unit is used to update the edge feature based on the node feature, and to update the node feature based on the updated edge feature, so as to obtain the target node feature.
[0089] S1043, input the target node feature into the decoder to obtain the result correction amount of the initial simulation result.
[0090] For example, Figure 5 A schematic diagram of an encoder in an embodiment of the present disclosure is shown.
[0091] like Figure 5 As shown, the encoder may include an edge encoding function And the node encoding function The above S1041 specifically includes: inputting the motion position, static position and connection relationship of the nodes into the edge coding function to obtain edge features of multiple mesh edges. Inputting the motion position and motion speed into the node coding function to obtain node features of multiple nodes.
[0092] In some embodiments, the edge encoding function may encode the length and direction of each mesh edge in the finite element mesh, and the length and direction of the mesh edge in the initial simulation result, as the edge feature of the mesh edge. ,in, For the mesh edge { , }Encoded edge features, is the edge encoding function, For the mesh edge { , }Vector representation (including length and direction) in the finite element mesh constructed in S101, For the mesh edge { , }Vector representation (including length and direction) in the initial simulation results. and are node numbers, mesh edges { , } indicates that the two endpoints of the mesh edge are nodes and nodes .
[0093] Among them, for each static edge among the multiple mesh edges, the edge encoding function is also used to determine the length and direction of the static edge in the finite element mesh based on the static position of each node connected to the static edge, and determine the length and direction of the static edge in the initial simulation results based on the motion position of each node connected to the static edge.
[0094] That is, for static edges, ,in, For Node The vector representation of the static position of For Node The vector representation of the static position of . Accordingly, ,in, For Node The vector representation of the motion position, For Node The vector representation of the motion position.
[0095] For each dynamic edge among the multiple mesh edges, the edge encoding function is further used to determine the length and direction of the dynamic edge in the initial simulation result based on the motion position of each node connected by the dynamic edge. The direction of the dynamic edge in the initial simulation result is determined as the direction of the dynamic edge in the finite element mesh, and the preset distance length is determined as the length of the dynamic edge in the finite element mesh.
[0096] That is, for dynamic edges, is calculated in the same way as for static edges. , since in the finite element mesh constructed by S101, the nodes and nodes There is no connection between them through any form of edge. In order to make the graph neural network aware of the changes in dynamic edges, ,in, The preset distance length for collision detection.
[0097] At this point, by and By inputting the edge encoding function, the encoder can encode the edge features of each mesh edge according to the change trend of each mesh edge before and after the cloth motion state simulation.
[0098] In some embodiments, the node encoding function may encode the movement position and movement speed of each node in the plurality of nodes as the node feature of the node. , in, The encoded node The node characteristics of is the node encoding function, For Node The vector representation of the motion position, For Node The vector representation of the movement speed (including the magnitude and direction of the movement speed).
[0099] For example, Figure 6 A schematic diagram showing a feature processing unit in an embodiment of the present disclosure.
[0100] like Figure 6 As shown, the feature processing unit may include at least one edge feature update function alternately arranged and at least one node feature update function Among them, the edge feature update function is used to update the edge feature based on the node feature, and the node feature update function is used to update the node feature based on the edge feature.
[0101] In the alternately set feature update functions (including edge feature update functions and node feature update functions), the first feature update function is an edge feature update function or a node feature update function, and the last feature update function is a node feature update function. That is, in order to make the result output by the last feature update function the target node feature, the last feature update function can be kept as the node feature update function, and the target node feature is the node feature updated by the last feature update function.
[0102] For example, the edge feature update function And node feature update function The alternate setting can be: → → →···→ → → , or: → →···→ → → .
[0103] Please continue to refer to Figure 6 In some embodiments, the edge feature update function may update the edge feature of each mesh edge among the plurality of mesh edges based on the node feature of each node connected to the mesh edge.
[0104] That is, the edge feature update function The implementation process can be expressed as: .in, For the mesh edge { , }Current edge features, For the mesh edge { , }Updated edge features, and Node and nodes The node characteristics of Update function for edge features.
[0105] Please continue to refer to Figure 6 In some embodiments, the node feature update function may update the node feature of each node among the plurality of nodes based on the edge feature of each mesh edge connected to the node.
[0106] That is, the node feature update function The implementation process can be expressed as: .in, For Node The current node characteristics, For Node Updated node features, To contain nodes The edge features of all mesh edges, To represent a node The adjacent domain of Update function for node features.
[0107] In addition, it can be understood that in the alternating feature update functions (including edge feature update functions and node feature update functions), except for the first feature update function, the node features used to output each edge feature update function are the node features updated by the previous node feature update function, and the edge features used to output each node feature update function are the edge features updated by the previous edge feature update function.
[0108] For example, Figure 7A schematic diagram of a decoder in an embodiment of the present disclosure is shown.
[0109] like Figure 7 As shown, the decoder may include a position decoding function and speed decoding function The above S1043 specifically includes: inputting the target node features into the position decoding function and the speed decoding function respectively to obtain the result correction amount.
[0110] Among them, the position decoding function The implementation process can be expressed as: .in, For Node The target node features, The node in the result correction The position correction value, is the position decoding function.
[0111] Speed decoding function The implementation process can be expressed as: .in, For Node The target node features, The node in the result correction The speed correction value, It is the speed decoding function.
[0112] Therefore, the initial simulation results are corrected based on the result correction amount, which can be expressed as: , .in, The corrected node The movement position, is the node in the initial simulation result Movement position; The corrected node The speed of movement, is the node in the initial simulation result speed of movement.
[0113] It should be noted that in the graph neural network model provided in the embodiments of the present disclosure, the encoder, feature processing unit and decoder can all be pre-trained multilayer perceptrons (MLP). In other words, the above-mentioned edge encoding function, node encoding function, edge feature update function, node feature update function, position decoding function and speed decoding function can all be implemented by a multilayer perceptron.
[0114] Among them, the multilayer perceptron is a feedforward artificial neural network model that can map multiple input data sets to a single output data set.
[0115] In some embodiments, the multi-layer perceptron can be a multi-layer perceptron with residual connections, thereby improving the learning ability of the graph neural network model.
[0116] It is worth noting that in the feature processing unit, the number of edge feature update functions can be multiple. In this case, each edge feature update function corresponds to a different multi-layer perceptron, and the parameters of different multi-layer perceptrons are independent of each other during the training process.
[0117] Similarly, in the feature processing unit, the number of node feature update functions may also be multiple. In this case, each node feature update function corresponds to a different multi-layer perceptron, and the parameters of different multi-layer perceptrons are independent of each other during the training process.
[0118] Combination of the above Figures 4 to 7 , which details the model structure and implementation method of the graph neural network model in the embodiments of the present disclosure.
[0119] The training process of the graph neural network model is introduced below.
[0120] Exemplarily, each function involved in the graph neural network model can be trained by supervised learning.
[0121] Specifically, the initial simulation results formed by the low-resolution finite element mesh can be used to extract the first parameter set for inputting the graph neural network model. At the same time, the target simulation results obtained by downsampling the simulation results formed by the high-resolution finite element mesh are used to extract the real second parameter set used as a reference for model training. Among them, the parameter types in the first parameter set and the second parameter set are the same, and the parameter types used for inputting the graph neural network model in S104 can be referred to.
[0122] By inputting the first parameter set into the graph neural network model to be trained, the predicted result correction (including position correction and speed correction) can be obtained. At the same time, the second parameter set can be input into the graph neural network model to be trained as a reference standard, so that the graph neural network model can perceive the difference between the predicted result correction and the actual result correction, and based on the loss between the two, complete the parameter adjustment of each function in the graph neural network model, and finally complete the training of the graph neural network model.
[0123] For example, the loss between the two can be expressed as as well as .in, is the loss of position correction, For Node The predicted position correction, For Node The actual position correction; is the loss of speed correction, For Node The predicted speed correction, For Node The actual speed correction.
[0124] Based on the same inventive concept, the present disclosure also provides a cloth simulation device in the following embodiments. Figure 1 The method embodiment shown is similar to that shown in FIG. 1 , so the implementation of the cloth simulation device embodiment can refer to the above Figure 1 The implementation of the illustrated method embodiment will not be described in detail in detail.
[0125] Figure 8 FIG. 2 is a schematic diagram showing the structure of a cloth simulation device according to an embodiment of the present disclosure. Figure 8 As shown, the cloth simulation device 800 includes: a construction module 801, a simulation module 802, a creation module 803, an output module 804, and a correction module 805.
[0126] Among them, the construction module 801 is used to construct a finite element mesh of the cloth, and the finite element mesh includes a plurality of nodes and a plurality of static edges for connecting the plurality of nodes.
[0127] The simulation module 802 is used to simulate the motion state of the cloth based on the finite element mesh to obtain the initial simulation result of the cloth, and the initial simulation result includes the motion position and motion speed of multiple nodes.
[0128] The establishment module 803 is used to establish a dynamic edge between every two nodes among the multiple nodes if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length and there is no static edge between the two nodes.
[0129] The output module 804 is used to input the motion position, motion speed, static positions of multiple nodes in the finite element mesh, and the connection relationship of multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result; wherein the connection relationship of multiple nodes includes a connection relationship based on static edges and a connection relationship based on dynamic edges, and the result correction amount includes a position correction amount for the motion position and a speed correction amount for the motion speed.
[0130] The correction module 805 is used to correct the initial simulation result based on the result correction amount to obtain the final simulation result of the cloth model.
[0131] In some embodiments, the graph neural network model includes an encoder, a feature processing unit, and a decoder. The output module 804 is specifically used to input the motion position, motion speed, static positions of multiple nodes in the finite element mesh, and the connection relationship of multiple nodes into the encoder to obtain node features of multiple nodes and edge features of multiple mesh edges; wherein the multiple mesh edges include each static edge and dynamic edges in the multiple static edges. The node features and edge features are input into the feature processing unit to generate target node features of multiple nodes; wherein the feature processing unit is used to update the edge features based on the node features, and update the node features based on the updated edge features. The target node features are input into the decoder to obtain the result correction amount of the initial simulation result.
[0132] In some embodiments, the encoder includes an edge encoding function and a node encoding function. The output module 804 is also used to input the motion position, static position and connection relationship of the node into the edge encoding function to obtain edge features of multiple mesh edges. The motion position and motion speed are input into the node encoding function to obtain node features of multiple nodes.
[0133] In some embodiments, the edge encoding function is used to encode the length and direction of each mesh edge in the finite element mesh of the plurality of mesh edges, as well as the length and direction of the mesh edge in the initial simulation result, as the edge feature of the mesh edge. Wherein, for each static edge in the plurality of mesh edges, the edge encoding function is also used to determine the length and direction of the static edge in the finite element mesh based on the static position of each node connected to the static edge; and to determine the length and direction of the static edge in the initial simulation result based on the motion position of each node connected to the static edge. For each dynamic edge in the plurality of mesh edges, the edge encoding function is also used to determine the length and direction of the dynamic edge in the initial simulation result based on the motion position of each node connected to the dynamic edge; and to determine the direction of the dynamic edge in the initial simulation result as the direction of the dynamic edge in the finite element mesh, and to determine the preset distance length as the length of the dynamic edge in the finite element mesh.
[0134] In some embodiments, the feature processing unit includes at least one edge feature update function and at least one node feature update function that are alternately set, the edge feature update function is used to update the edge feature based on the node feature, and the node feature update function is used to update the node feature based on the edge feature. In the alternately set feature update functions, the first feature update function is an edge feature update function or a node feature update function, the last feature update function is a node feature update function, and the result output by the last feature update function is the target node feature.
[0135] In some embodiments, the edge feature update function is specifically used to: for each mesh edge among the plurality of mesh edges, update the edge feature of the mesh edge based on the node feature of each node connected to the mesh edge.
[0136] In some embodiments, the node feature update function is specifically used to: for each node among the plurality of nodes, update the node feature of the node based on the edge feature of each mesh edge connected to the node.
[0137] In some embodiments, the decoder includes a position decoding function and a speed decoding function. The output module 804 is also used to input the target node feature into the position decoding function and the speed decoding function respectively to obtain the result correction amount.
[0138] In some embodiments, the encoder, feature processing unit, and decoder are all pre-trained multi-layer perceptrons.
[0139] Refer to the following Fig. 9 Detailed description of the electronic device 900 capable of implementing the embodiments of the present disclosure. Fig. 9 The electronic device 900 shown is merely an example and should not bring any limitation to the functions and scope of application of the embodiments of the present disclosure.
[0140] like Fig. 9 As shown, the electronic device 900 is in the form of a general-purpose computing device. The components of the electronic device 900 may include, but are not limited to: at least one processor 910, at least one memory 920, and a bus 930 connecting different system components (including the memory 920 and the processor 910).
[0141] The memory stores program codes, which can be executed by the processor 910, so that the processor 910 executes the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of the present disclosure.
[0142] In some embodiments, the processor 910 may further perform the following steps of the above method embodiment:
[0143] Constructing a finite element mesh of the cloth, the finite element mesh including a plurality of nodes and a plurality of static edges for connecting the plurality of nodes;
[0144] The motion state of the cloth is simulated based on the finite element mesh to obtain the initial simulation result of the cloth, which includes the motion position and motion speed of multiple nodes;
[0145] For every two nodes among the plurality of nodes, if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length, and there is no static edge between the two nodes, then a dynamic edge is established between the two nodes;
[0146] The motion position, motion speed, static positions of multiple nodes in the finite element mesh, and connection relationships of multiple nodes are input into a pre-trained graph neural network model to obtain result corrections for the initial simulation results; wherein the connection relationships of multiple nodes include connection relationships based on static edges and connection relationships based on dynamic edges, and the result corrections include position corrections for the motion position and speed corrections for the motion speed;
[0147] The initial simulation result is corrected based on the result correction amount to obtain the final simulation result of the cloth model.
[0148] The memory 920 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 9201 and / or a cache memory 9202 , and may further include a read-only memory (ROM) 9203 .
[0149] The memory 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0150] Bus 930 may be a bus representing one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
[0151] The electronic device 900 may also communicate with one or more external devices 940 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 900, and / or any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 950. Furthermore, the electronic device 900 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 960. Fig. 9 As shown, the network adapter 960 communicates with other modules of the electronic device 900 via the bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0152] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0153] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, which may be a readable signal medium or a readable storage medium. A program product capable of implementing the above-mentioned method of the present disclosure is stored thereon. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above-mentioned "Exemplary Method" section of the present disclosure.
[0154] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A cloth simulation method, characterized in that: include: Constructing a finite element mesh of the cloth, the finite element mesh comprising a plurality of nodes and a plurality of static edges for connecting the plurality of nodes; Simulating the motion state of the cloth based on the finite element mesh to obtain an initial simulation result of the cloth, wherein the initial simulation result includes the motion positions and motion speeds of the multiple nodes; For every two nodes among the plurality of nodes, if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length, and there is no static edge between the two nodes, then a dynamic edge is established between the two nodes; The motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes are input into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result; wherein the connection relationship of the multiple nodes includes a connection relationship based on static edges and a connection relationship based on dynamic edges, and the result correction amount includes a position correction amount for the motion position and a speed correction amount for the motion speed; The initial simulation result is corrected based on the result correction amount to obtain a final simulation result of the cloth model.
2. The method according to claim 1, characterized in that The graph neural network model includes an encoder, a feature processing unit and a decoder; The step of inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result includes: Inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into the encoder to obtain node features of the multiple nodes and edge features of multiple mesh edges; wherein the multiple mesh edges include each static edge of the multiple static edges and the dynamic edge; Inputting the node features and the edge features into the feature processing unit to generate target node features of the plurality of nodes; wherein the feature processing unit is used to update the edge features based on the node features, and to update the node features based on the updated edge features; The target node feature is input into the decoder to obtain a result correction amount of the initial simulation result.
3. The method according to claim 2, characterized in that The encoder includes an edge encoding function and a node encoding function; The step of inputting the motion position, the motion speed, the static positions of the plurality of nodes in the finite element mesh, and the connection relationship of the nodes into the encoder to obtain the node features of the plurality of nodes and the edge features of the plurality of mesh edges includes: Inputting the motion position, the static position and the connection relationship of the nodes into the edge encoding function to obtain edge features of the plurality of mesh edges; The movement position and the movement speed are input into the node encoding function to obtain the node features of the multiple nodes.
4. The method according to claim 3, characterized in that The edge encoding function is used to encode the length and direction of each mesh edge of the plurality of mesh edges in the finite element mesh, and the length and direction of the mesh edge in the initial simulation result, as edge features of the mesh edge; Wherein, for each static edge among the plurality of mesh edges, the edge encoding function is further used to determine the length and direction of the static edge in the finite element mesh based on the static position of each node connected to the static edge; and determine the length and direction of the static edge in the initial simulation result based on the motion position of each node connected to the static edge; For each dynamic edge among the multiple mesh edges, the edge encoding function is also used to determine the length and direction of the dynamic edge in the initial simulation result based on the motion position of each node connected by the dynamic edge; determine the direction of the dynamic edge in the initial simulation result as the direction of the dynamic edge in the finite element mesh, and determine the preset distance length as the length of the dynamic edge in the finite element mesh.
5. The method according to claim 2, characterized in that: The feature processing unit includes at least one edge feature update function and at least one node feature update function which are alternately arranged, wherein the edge feature update function is used to update the edge feature based on the node feature, and the node feature update function is used to update the node feature based on the edge feature; In the alternately set feature update functions, the first feature update function is the edge feature update function or the node feature update function, the last feature update function is the node feature update function, and the result output by the last feature update function is the target node feature.
6. The method according to claim 5, characterized in that The edge feature update function is specifically used for: For each mesh edge among the plurality of mesh edges, an edge feature of the mesh edge is updated based on a node feature of each node connected to the mesh edge.
7. The method according to claim 5, characterized in that The node feature update function is specifically used for: For each node among the plurality of nodes, a node feature of the node is updated based on an edge feature of each mesh edge connected to the node.
8. The method according to claim 2, characterized in that: The decoder includes a position decoding function and a speed decoding function; The step of inputting the target node feature into the decoder to obtain a result correction amount of the initial simulation result includes: The target node features are input into the position decoding function and the speed decoding function respectively to obtain the result correction amount.
9. The method according to claim 2, characterized in that: The encoder, the feature processing unit and the decoder are all pre-trained multi-layer perceptrons.
10. A cloth simulation device, characterized in that: include: A construction module, used for constructing a finite element mesh of the cloth, wherein the finite element mesh includes a plurality of nodes and a plurality of static edges for connecting the plurality of nodes; A simulation module, configured to simulate the motion state of the cloth based on the finite element mesh to obtain an initial simulation result of the cloth, wherein the initial simulation result includes the motion positions and motion speeds of the multiple nodes; An establishing module, configured to establish a dynamic edge between each two nodes of the plurality of nodes if the distance between the two nodes in the initial simulation result is less than or equal to a preset distance length and there is no static edge between the two nodes; An output module, used for inputting the motion position, the motion speed, the static positions of the multiple nodes in the finite element mesh, and the connection relationship of the multiple nodes into a pre-trained graph neural network model to obtain a result correction amount of the initial simulation result; wherein the connection relationship of the multiple nodes includes a connection relationship based on static edges and a connection relationship based on dynamic edges, and the result correction amount includes a position correction amount for the motion position and a speed correction amount for the motion speed; The correction module is used to correct the initial simulation result based on the result correction amount to obtain a final simulation result of the cloth model.
11. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 9 by executing the executable instructions.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
