Grasshopper-C #-UDEC-based numerical model parameterization construction method
By customizing the graph generation algorithm and C# plug-in to generate "txt" format documents in Grasshopper, the problems of limited graphics types and low quality when generating block model diagrams by UDEC built-in commands are solved, and efficient and accurate numerical model generation is achieved, which improves the practicality of the simulation.
Patent Information
- Application Number
- CN202510112105.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-16
AI Technical Summary
When using UDEC built-in commands to create block model diagrams, the generated graphics are limited in type and low in quality, and it is impossible to generate numerical models efficiently and accurately.
By using the C# programming language and RhinoCommon API in Rhino's Grasshopper, custom Delaunay, Quad and Voronoi graph generation algorithms are implemented, parameterized mesh models are established and iteratively optimized, and the generated model parameters are passed into the custom C# plug-in to generate the "txt" format document, and imported it into UDEC to generate the parameterized mesh model.
It realizes high-quality grid model generation, improves the efficiency and accuracy of UDEC modeling, overcomes the original modeling defects in UDEC, and improves the practicality of simulation.
Smart Images

Figure CN120012532A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of experimental simulation, and specifically is a parameterized construction method based on Grasshopper-C#-UDEC numerical model. Background Art
[0002] Block discrete element method is an extended method based on the discrete element method, which is mainly used to simulate the mechanical behavior of materials or structures with significant discontinuous characteristics, such as rock mass, masonry, etc. It combines the ideas of discrete element method and block mechanics, decomposes the overall simulation material into a series of block units, and describes its overall behavior through contact, collision, sliding and separation between blocks. With the rapid development of computer technology, numerical simulation has become an important means to study the block discrete element method. Numerical simulation can efficiently and flexibly simulate the degree of block discretization under different conditions, and plays an important role in understanding the mechanical properties of rock mass and the basis of numerical simulation. By establishing a parametric model, the influence of factors such as different crack density, direction and opening on the strength and deformation of rock mass can be studied, providing an important basis for engineering design and stability assessment; it can provide a deeper understanding of the mechanical behavior of rock mass, improve the accuracy and reliability of numerical simulation, and provide strong support for engineering practice and geological research.
[0003] Currently, when using UDEC built-in commands to create block model diagrams, there are the following shortcomings: First, Grasshopper provides technical support for parametric modeling, but the quality of Delaunay graphics generated by its built-in battery is limited. Therefore, the secondary development of Grasshopper modeling functions and the pursuit of higher quality mesh models are more important. Secondly, the Delaunay algorithm, Quad algorithm, and Voronoi algorithm built into UDEC will generate flat and uneven blocks at the model boundary when generating blocks. More importantly, the CAD file still needs to be processed before generating a model in UDEC. For projects with frequent iterations, it is impossible to generate numerical models efficiently and accurately. Parametric models have the advantages of flexibility, editability, automation, and batch modeling. Therefore, it is of great significance and broad application scenarios to invent a method for automatically and efficiently generating numerical models. Summary of the invention
[0004] Aiming at the problems of limited types of generated graphics and low quality when using built-in commands of UDEC to create block model diagrams, the present invention provides a parametric construction method of numerical model based on Grasshopper-C#-UDEC.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: a parametric construction method based on Grasshopper-C#-UDEC numerical model, comprising the following steps:
[0006] 1) Secondary development based on the parametric modeling function of Grasshopper in Rhino. In Grasshopper of Rhino, the C# programming language and the API inside RhinoCommon are used to generate triangle meshes, quadrilateral meshes and Voronoi meshes inside the boundary of any geometric plane. The parametric mesh model is established and iterative algorithm optimization is implemented in Rhino using the custom Delaunay graphics generation algorithm, the custom Quad graphics generation algorithm and the custom Voronoi graphics generation algorithm. The generated Delaunay mesh model is optimized using the iterative algorithm.
[0007] 2) In the data text processing and output module, extract the parameter information of the mesh model generated in step 1). Specifically, first extract the vertices of each Delaunay mesh model; pass the extracted vertices to the Point battery built into Grasshopper, and then extract each line segment in the Delaunay mesh model, and pass the extracted line segments to the Curve battery built into Grasshopper.
[0008] 3) In UDEC quick reading and modeling, extract the rock column information and save it in an Excel table, automatically read the Excel table, and pass the read information into the custom UDEC automatic generation plug-in. At the same time, use the built-in command of UDEC to process the data text generated in step 2), pass the corresponding Grasshopper cell into the custom UDEC automatic generation plug-in, automatically generate a "txt" format document, and then import it into UDEC to generate a parametric grid model.
[0009] Step 1) involves using the built-in batteries in Rhino's Grasshopper. These mainly include Point, Curve, and Mesh batteries.
[0010] The parameterized mesh model generated in step 1) can reflect the mesh characteristics after mesh division, and can record the mesh point coordinates, mesh line segment data type information and basic mesh division results through the Panel battery.
[0011] The basic mesh division results include: a line composed of several short line segments, each of which is determined by two mesh points; the mesh boundary is composed of several triangular mesh surfaces, each of which is determined by three mesh points;
[0012] In step 2), the mesh model generated in step 1) is processed: the point and line information in the model diagram is linked to the battery built into Grasshopper as parameters so that a "txt" format document can be generated later; in step 3), the parameter information in the custom C# plug-in comes from the parameter information of the battery in step 2).
[0013] In step 3), the battery in step 2) is transferred to the custom C# plug-in to generate a "txt" format document, and the "call" command of UDEC is used to read the "txt" document to run the modeling program to generate the UDEC model diagram.
[0014] Step 1) implements parametric modeling of Grasshopper, selects a two-dimensional grid model for the grid block model, and the "txt" document data type format in step 3) corresponds to the two-dimensional grid data format.
[0015] In step 1) to step 3), Grasshopper parametric modeling is redeveloped using a custom C# algorithm, and the generated model parameters are passed into a custom C# plug-in to generate a "txt" format document, which is read in UDEC to generate a parametric numerical model.
[0016] The beneficial effects of the present invention relative to the prior art are as follows: the present invention utilizes the efficient processing capability of C# to conduct secondary development of Grasshopper parametric modeling, so that it can adapt to more types of model diagrams. In addition, the automatic reading of custom "txt" documents greatly improves the efficiency of UDEC modeling. This method not only overcomes the most primitive modeling defects in UDEC, but also improves the accuracy and practicality of the simulation. This innovative method will bring new ideas to the field of block discrete elements and provide strong technical support for engineering practice and geological research. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The present invention will be further described below in conjunction with the accompanying drawings:
[0018] Figure 1 It is a flow chart designed by the present invention;
[0019] Figure 2 It is a triangular mesh, a quadrilateral mesh, and a Voronoi schematic diagram of the present invention;
[0020] Figure 3 It is a battery pack used by the present invention to realize Grasshopper to establish a grid model;
[0021] Figure 4 It is a schematic diagram of data parameters for quick reading and modeling of UDEC of the present invention;
[0022] Figure 5 It is the effect diagram of the UDEC numerical model of the present invention;
[0023] Figure 6 is a schematic diagram of the triangular mesh optimization of the present invention;
[0024] Figure 7 It is a battery pack used by the present invention to realize quick reading and modeling of UDEC;
[0025] In the figure: 1. Delauany diagram generated by discrete points; 2. Quad diagram generated by discrete points; 3. Voronoi diagram generated by discrete points; 4. Delauany diagram generated by edge length control; 5. Optimized Delauany diagram generated when the number of iterations is 35; 6. Delauany diagram generated when the number of iterations is 10. DETAILED DESCRIPTION
[0026] like Figures 1 to 5 As shown, the present invention provides a parametric construction method of a numerical model based on Grasshopper-C#-UDEC, which decomposes the overall simulation material into a series of block units through the block discrete element method, so as to more accurately simulate the mechanical behavior of the rock mass. The present invention has carried out secondary development of Grasshopper parametric modeling, so that it can adapt to more types of model diagrams; at the same time, the present invention also realizes iterative optimization of custom algorithms, so that users can flexibly adjust model parameters according to actual needs and optimize simulation results. More importantly, in UDEC modeling, UDEC reads custom "txt" format documents, which greatly shortens the graphic modeling time and improves modeling efficiency.
[0027] According to the following Figures 1 to 5 , the present invention is further described. The present invention generates a parametric model based on the Grasshopper-C#-UDEC numerical model parametric construction method. The specific steps are as follows:
[0028] 1) Secondary development based on the parametric modeling function of Grasshopper in Rhino. In Grasshopper of Rhino, the C# programming language and the API inside RhinoCommon are used to generate triangle meshes, quadrilateral meshes and Voronoi meshes inside the boundary of any geometric plane. The parametric mesh model is established and iterative algorithm optimization is implemented in Rhino using the custom Delaunay graphics generation algorithm, the custom Quad graphics generation algorithm and the custom Voronoi graphics generation algorithm. The generated Delaunay mesh model is optimized using the iterative algorithm.
[0029] The specific steps are as follows:
[0030] ① Use C#Script built-in batteries in Rhino's Grasshopper to build an environment for subsequent programming.
[0031] ② The model to be processed or the new model is transferred to the Geometry cell of Grasshopper. Then the Boundary curve method is used to control the generation of discrete points inside the boundary. The maximum number of attempts is set to avoid process deadlock caused by too many iterations, and the points that conform to the Poisson distribution law are output in the form of a point list.
[0032] ③ Use Node2List and Solver.Solve_Mesh methods to generate discrete points that satisfy the Poisson distribution. In the custom C# plug-in, use Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces() statement to convert the two-dimensional discrete points generated in ② into recognizable triangle vertices in Grasshopper and then generate a triangular mesh.
[0033] ④ Extract the side length of the triangular mesh in ③ and calculate the total length, count the number of triangular meshes in ③, and calculate the average length of the triangular mesh excluding the boundary from the total length of all sides of the triangular mesh and the number of triangular meshes. The rule for controlling the generation of equally separated scattered points on the boundary line of the model is: the average length of the triangular mesh inside the model and the side length on each boundary line satisfy the multiplication and division relationship, and the value of the side length divided by the average length is passed into the attribute DivideByCount of Curve to finally generate the boundary line equally divided points. And pass the average length into the scaling function offset. Then use the algorithm for generating the triangular mesh in step ③ again to generate a triangular mesh with uniform boundaries, such as Figure 2 shown.
[0034] ⑤Generate a quadrilateral mesh in Grasshopper; use steps ①-④ to generate a triangular mesh, use the ConvertToQuads custom method, first create a quadrilateral counter QuadCount to store the generated quadrilaterals, to ensure that the generated quadrilaterals meet the characteristics of numerical simulation and to ensure that legal and valid quadrilaterals are generated; use the sorted method to control the traversal rules of discrete points clockwise and delete unprocessed triangular mesh faces; use the AreFacesOverlapping() custom function method to check whether the generated quadrilateral mesh has overlapping areas; use the IsConvex() custom method to check whether the generated quadrilateral is a convex quadrilateral, if so, return a convex polygon. If not, decompose the concave quadrilateral into two triangles. And output the final quadrilateral mesh information, such as Figure 2 shown.
[0035] ⑥ Generate a Voronoi mesh in Grasshopper; use ①-④ to generate a triangular mesh, and then use the GenerateVoronoiDiagram custom method to create a list to store the boundaries and vertices of the Voronoi mesh. Generate Voronoi mesh vertices by using the ComputeCircumcenter custom method. The generation principle is to calculate the cross product of the triangular mesh vertex vectors. Return the generated Voronoi mesh vertices to the GenerateVoronoiDiagram method body. Generate Voronoi mesh edges by using the ComputeVoronoiEdges custom method. The generation principle is to connect each Voronoi mesh vertex. Return the generated Voronoi mesh boundary to the GenerateVoronoiDiagram method body, and output the final Voronoi mesh information, such as Figure 2 shown.
[0036] When generating discrete points on the boundaries of triangular meshes, quadrilateral meshes, and Voronoi meshes, the discrete points on the boundary line Curve satisfy the equal division principle, and the generation steps are the same as ④.
[0037] ⑦ In step 1), pass the built-in battery Geometry, and follow the process logic of step 1) for battery processing. Pass the Geometry battery to the boundary input of the C#Script plug-in, pass the maximum and minimum side length values, set the maximum side length to 10, and the minimum side length to 5. Use the PoissonDiskSampling() custom function method to generate discrete points that satisfy the Poisson disk distribution. Control the specific distribution of discrete points according to the custom radius class method, where the calculation method of the radius class is determined by the value of the maxLength input terminal of the maximum side length of the triangle mesh and the value of the minimum side length minLength. Set the maxAttempts iteration parameter to optimize the triangulated network. This example sets the number of iterations to 10.
[0038] ⑧In step 1), pass the built-in battery Geometry, and follow the process logic of step 1) for battery processing. Pass the Geometry battery to the boundary input of the C#Script plug-in, pass the maximum area and minimum area, set the maximum area value to 10, and the minimum area value to 5. Use the PoissonDiskSampling() custom function method to generate discrete points that satisfy the Poisson disk distribution. Control the specific distribution of discrete points according to the custom radius class method, where the calculation method of the radius class is determined by the value of the maximum area input maxArea of the triangle mesh and the value of the minimum area minArea. Set the maxAttempts iteration parameter to optimize the triangulated network. This example sets the number of iterations to 35.
[0039] ⑨ In ⑦ to ⑧, the logic of generating the triangular mesh is the same as in step 1). Figure 6 shown.
[0040] In step 1), the point, line and surface units of the grid model are parametrically established. In a specific example, the Grasshopper built-in battery Geometry is used to frame the geometric plane; the Grasshopper built-in battery Curve is used to express the generated line segment parameters; and the Grasshopper built-in battery Point is used to express the point parameters. Specific or randomly set models can be passed into the Geometry battery.
[0041] In step 1), the algorithm for generating a triangular mesh controlled by the maximum side length and the minimum side length is considered to be an optimization of the algorithm for generating a triangular mesh in step 1). It uses the side length as a parameter and adds an iteration function to generate a triangular mesh.
[0042] In step 1), the algorithm for generating a triangular mesh controlled by the maximum area and the minimum area is considered to be an optimization of the algorithm for generating a triangular mesh in step 1). It uses the area as a parameter and adds an iteration function to generate a triangular mesh.
[0043] In step 1), in the method of generating the Delaunay graph to control the maximum and minimum side lengths and areas, the value of the number of iterations maxAttempts is related to the quality of the Delauany graph. In this model, a Delaunay graph with 10 iterations and a Delaunay graph with 35 iterations are generated respectively. By comparison, the Delaunay graph with 35 iterations has higher quality. Figure 5 shown.
[0044] Step 1) Use custom C# plug-in and built-in battery to build a grid model. The algorithms involved in ①-⑧ are all reflected in the custom plug-in. The main battery group is as follows Figure 3 shown.
[0045] 2) In the data text processing and output module, extract the parameter information of the mesh generated in step 1). Specifically, first extract the vertices of each Delaunay mesh; pass the extracted vertices to the Point battery built into Grasshopper, then extract each line segment in the Delaunay graph, and pass the extracted line segments to the Curve battery built into Grasshopper.
[0046] The specific steps are as follows:
[0047] ① Use C#Script built-in batteries in Rhino's Grasshopper to build an environment for subsequent programming.
[0048] ② Transfer the points and lines of the parametric model diagram generated in step 1) to the built-in Point and Curve batteries of Grasshopper to facilitate the subsequent generation of UDEC command flow.
[0049] ③ Pass the Point battery generated in the example to the input point of the C#Script plug-in, and set the input point data type to List <point3d>points; Get the value of 5% of the length of a side of a triangular mesh among all triangular meshes, and require that the side length is the minimum side length in the model. Pass this value to the input end arcnum of the C#Script plug-in, and set the data type to double arcnum; Pass the Curve battery generated in the example to the input end curves of the C#Script plug-in, and set the data type to List <object>curves; take the boundaries of blocks in different regions and extract the center point inside the boundary, pass it as a parameter to the input end cutPoints of the C#Script plug-in, and set the data type to DataTree <point3d>cutPoints;
[0050] In step 2), some batteries in Grasshopper are used, mainly including Point, Curve and Mesh batteries.
[0051] The parametric model diagram generated in step 2) can reflect the mesh text data after meshing, and specifically records the mesh coordinates, mesh line segment data type information, and basic entity meshing results.
[0052] 3) In UDEC quick reading and modeling, extract the rock column information and save it in an Excel table, automatically read the Excel table, and pass the read information into the custom UDEC automatic generation plug-in. At the same time, use the UDEC built-in command to process the data text generated in step 2), pass the corresponding Grasshopper cell into the custom UDEC automatic generation plug-in, automatically generate a "txt" format document, and then import it into UDEC to generate a parametric grid model;
[0053] The specific steps are as follows:
[0054] ① Create a custom C# plug-in. The points input of the plug-in corresponds to the UDEC command function to generate the Polygon model boundary; the arcnum input of the plug-in is used to calculate the arc angle length; the curves output of the plug-in corresponds to the Block cut crack function; the data input of the plug-in is responsible for reading Excel table data and handing it over to the atblock command for block area division.
[0055] ②Execute the algorithm compiled in the custom C#Script plug-in and write it into a "txt" format document named: "3.txt". The ";" symbol is a code comment. The first two lines are code descriptions and do not play any role. The following lines are code-related functions. polygon is used to frame the boundary of the numerical model; block cut crack is a numerical simulation of the mesh model parameters passed in by ①, so as to establish a numerical model containing triangulated networks or quadrilaterals under different block layers; atblock is used to cut rectangular areas to generate different layers of blocks. Figure 4 shown.
[0056] ③ Import the 3.txt document generated in ② into the UDEC command run box. Use the UDEC "call" command to read the custom "3.txt" document generated in ②. After running, it will be found that when processing large models, the efficiency of generating models is significantly higher than that of UDEC internal commands. Figure 5 shown.
[0057] Step 3) Use a custom C# plug-in to generate a "txt" format document. The algorithms involved in ①-③ are all reflected in the custom plug-in. The battery pack is as follows Figure 7 shown.
[0058] Finally, it should be noted that the above examples are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above examples, those skilled in the art should understand that they can still modify the technical solutions described in the above examples, or replace some or all of the technical features therein with equivalents. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present invention. < / object>
Claims
1. A parametric construction method of numerical model based on Grasshopper-C#-UDEC, characterized by: The following steps are involved: 1) Secondary development based on the parametric modeling function of Grasshopper in Rhino: In Grasshopper of Rhino, use the C# programming language and the API inside RhinoCommon to generate triangle meshes, quadrilateral meshes and Voronoi meshes inside the boundary of any geometric plane; use the custom Delaunay graphics generation algorithm, custom Quad graphics generation algorithm and custom Voronoi graphics generation algorithm to implement parametric mesh model establishment and iterative algorithm optimization in Rhino, and use the iterative algorithm to optimize the generated Delaunay mesh model; 2) In the data text processing and output module, extract the parameter information of the mesh model generated in step 1): first extract the vertices of each Delaunay mesh model, and pass the extracted vertices to the Point battery built into Grasshopper, then extract each line segment in the Delaunay mesh model, and pass the extracted line segments to the Curve battery built into Grasshopper; 3) In UDEC quick reading and modeling, the rock column information is extracted and saved in an Excel table, the Excel table is automatically read, and the read information is transferred to the custom UDEC automatic generation plug-in; At the same time, the data text generated in step 2) is processed using the built-in commands of UDEC, and the corresponding Grasshopper battery is transferred to the customized UDEC automatic generation plug-in. After the txt format document is automatically generated, it is imported into UDEC to generate a parametric mesh model.
2. The parametric construction method of the numerical model based on Grasshopper-C#-UDEC according to claim 1, characterized in that: In step 1), use the C#Script plug-in in Grasshopper to edit the mesh division battery, and generate a mesh model in combination with the built-in battery in Grasshopper.
3. The parametric construction method based on Grasshopper-C#-UDEC numerical model according to claim 1, characterized in that: In step 1), the mathematical distribution model of the discrete points generated within the boundary range serves the meshing of the parameterized Delaunay, Quad and Voronoi mesh models.
4. The parametric construction method based on Grasshopper-C#-UDEC numerical model according to claim 1, characterized in that: The generation of the parameterized Delaunay mesh model in step 1) involves three different algorithms, namely: introducing discrete points that satisfy the Poisson distribution model and using a custom Delauany partitioning algorithm to generate a triangular mesh model; a triangular mesh optimization algorithm that controls the maximum and minimum side lengths of the triangular mesh; a triangular mesh optimization algorithm that controls the maximum and minimum area of the triangular mesh; and after the triangular mesh model is generated, any one of the triangular mesh optimization algorithms is used to generate a Delaunay mesh model.
5. The parametric construction method of the numerical model based on Grasshopper-C#-UDEC according to claim 1, characterized in that: Step 2) involves utilizing the built-in batteries in Rhino's Grasshopper, including Point, Curve, and Mesh batteries.
6. A parametric construction method based on Grasshopper-C#-UDEC numerical model according to claim 1 or 2 or 3 or 4 or 5, characterized in that: Step 1) is a secondary development of Grasshopper parametric modeling, which realizes the meshing inside any boundary and optimizes the meshing algorithm.
7. The parametric construction method based on Grasshopper-C#-UDEC numerical model according to claim 1, characterized in that: Step 2) Inherit the mesh model generated in step 1); link the points and lines in the model to the built-in battery in Grasshopper so that UDEC can quickly read and generate a numerical model later.
8. The parametric construction method of the numerical model based on Grasshopper-C#-UDEC according to claim 1, characterized in that: In step 3), the implementation method of UDEC's quick reading and modeling is to develop a custom C# battery, including storing the data in the Execl table into the panel battery and automatically reading it; reading the point and line information and passing it as parameters into the custom battery algorithm, generating a "txt" format document, reading it in UDEC and implementing the construction of a parametric numerical model.
9. A parametric construction method based on Grasshopper-C#-UDEC numerical model according to claim 7 or 8, characterized in that: Step 1) Implement graphical parametric modeling of Grasshopper; Step 2) Implement text data processing; Step 3) Implement parametric "txt" format document creation and implement parametric construction of UDEC model.