A large-scale parallel grid generation method and system suitable for numerical reactors
Parallel grid generation is implemented in the HXT algorithm through the OpenMP framework and lock-free atomic operations. Combining the grid generator and solver solves the problems of multi-thread blocking and disk I/O overhead, and improves the efficiency and efficiency of large-scale grid generation. Parallelism enables efficient grid generation and display.
Patent Information
- Application Number
- CN202011495076.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2040-12-17
AI Technical Summary
Existing parallel grid generation algorithms have multi-thread blocking problems when expanding the number of threads. The interface design is unreasonable and the separation of the grid generator and solver results in high disk I/O overhead and cannot efficiently handle large-scale grid generation tasks.
Use the OpenMP framework to implement parallelization of the HXT algorithm and the grid generator, solve the problems of multi-thread conflicts and low interface efficiency through lock-free atomic operations and thread private containers, and combine the grid generator with the solver to avoid disk I/O Overhead, realize the direct utilization of grid data in memory.
It significantly reduces grid generation time, improves parallelism, shortens grid generation time, avoids disk I/O overhead, and provides a graphical interface to display solution results.
Smart Images

Figure CN112464540B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a large-scale parallel grid generation method and system in the field of numerical simulation, and in particular to a method and system for accelerating grid generation by parallelization and reducing lock granularity in a numerical reactor scenario. Background Art
[0002] Nuclear reactor engineering is a complex engineering project involving multiple disciplines such as materials science, thermodynamics, and mechanics. The bending deformation of reactor core components and the flow-induced vibration of fuel rods caused by the combined effects of high temperature, irradiation, pressure and other factors will lead to wear of the core component cladding, difficulty in loading and unloading, component damage and fatigue damage. Therefore, the analysis of the deformation of reactor core components and flow-induced vibration is of great significance to ensure the safe operation of the reactor. In practical work, numerical methods are generally used to analyze the bending deformation of core components. Numerical reactors are based on multi-physics coupling calculations and large-scale parallel calculations, and use advanced computer software such as thermal hydraulics, fuel, structural mechanics, and materials to conduct all-round and refined numerical simulations of reactors to complete a realistic or beyond-realistic research platform for reactors.
[0003] At present, the parallel capability of high-performance numerical simulation software lags far behind the parallel capability that hardware can provide, and it is in urgent need of optimization. In most cases, it is not the solver that restricts the parallel capability of numerical simulation software, but the grid generation stage that takes up more computing time. Therefore, improving the parallel efficiency of grid generation and shortening the grid generation time are the keys to improving the parallel computing capability of numerical simulation software. Hundreds of millions or even billions of grids pose a huge challenge to grid generators. Traditional serial grid generation methods are not capable of this magnitude of grid generation tasks in terms of time and memory, so parallel grid generation methods have gradually become a research hotspot.
[0004] At present, most parallel grid generation algorithms do not make full use of shared memory structures and cannot take advantage of the multi-layer architecture of supercomputers. In addition, most parallel grid generation algorithms can only be expanded to about 16 threads. When running under more threads, the waiting time between threads is constantly increasing, and the efficiency is reduced. Marot et al. proposed a parallel grid generation algorithm (hextreme, hereinafter referred to as HXT algorithm) and integrated it into the open source grid generator Gmsh. The HXT algorithm has designed a sophisticated data structure and is more efficient than other open source grid generators. This method only takes one-third of the time of other generators to generate a grid of the same size.
[0005] However, the HXT algorithm still has the following problems: 1) When expanded to about 64 threads, there is a multi-thread blocking problem, and each thread waits for each other; 2) The conversion interface between the HXT algorithm and the grid generator Gmsh is not designed reasonably, and the serial conversion is time-consuming; 3) The grid generator and the solver are not combined, and there is disk I / O overhead. Summary of the invention
[0006] The purpose of the present invention is to address the deficiencies of the prior art and propose a large-scale parallel grid generation method suitable for numerical reactors, which effectively shortens the calculation time of large-scale grid generation and solves the problem of generating tens of billions of grids from a numerical reactor model of 712 full core components.
[0007] The present invention proposes to realize the parallelization of HXT algorithm and mesh generator Gmsh conversion interface based on OpenMP framework, and combines mesh generator with solver to realize the correct use of parallel meshing results by solver, avoiding extra disk I / O overhead and greatly reducing user cost. At the same time, the present invention proposes to balance the load of 712 full core component models to 37 computing nodes, and finally realizes the generation of tens of billions of meshes for reactor core components.
[0008] Specifically, in order to solve the above technical problems, the present invention provides the following technical solutions:
[0009] A large-scale parallel grid generation method suitable for numerical reactors, characterized in that the method comprises:
[0010] Step 1: The numerical reactor assembly model consists of a number of core assemblies, which are equally divided into n groups of core assemblies;
[0011] Step 2: Generate a 2D mesh for each core component using the 3D finite element mesh generator Gmsh, and convert the 2D mesh format using the Gmsh2Hxt preprocessing function;
[0012] Step 3: Construct the 3D initial mesh from the 2D mesh after format conversion;
[0013] The construction here is a conventional technical operation in this field, so it is not explained in detail;
[0014] Step 4: Based on lock-free atomic operations, use multi-threading to perform parallel mesh refinement operations on the 3D initial mesh:
[0015] Each thread performs the following operations:
[0016] a) Get the grid number num.
[0017] b) Determine whether num is empty, if so, execute step c), if not, execute step d);
[0018] c) Add one to the current maximum grid number and set it as the latest grid number;
[0019] d) Determine whether num is greater than the current maximum grid number. If so, set num as the latest grid number. If not, add 1 to the current maximum grid number and set it as the latest grid number.
[0020] Each thread executes step a and step b simultaneously. If two or more threads need to execute step c or step d, one thread needs to wait for the other thread to complete execution. If two threads execute step c and step d respectively, they will be executed simultaneously.
[0021] The existing HXT algorithm uses critical sections to wrap steps a to d. If and only if one thread completes all steps a to d, other threads can start to execute from step a. That is, the existing method does not achieve true parallelism in the grid construction process. The method proposed in the present invention can enable multiple threads to construct a grid at the same time. Steps a and b can be executed synchronously by multiple threads, and lock-free atomic operations are used inside steps c and d to ensure thread safety.
[0022] The following example uses two threads constructing a grid simultaneously, assuming that it takes time T to execute each step.
[0023] Original method: Thread 1 executes step a to step d step by step, which takes 3T (only one of step c and d is executed). After thread 1 is finished, thread 2 starts to execute, which also takes 3T. The two threads take a total of 6T.
[0024] The method of the present invention: Thread 1 starts to execute step a and step b, while thread 2 also executes step a and step b, which takes 2T. If both threads need to execute step c, one thread needs to wait for the other thread to complete execution, which takes 2T. If one of the two threads executes step c and the other executes step d, they can be executed synchronously, which takes 1T. In summary, the method of the present invention takes a total of 3 to 4T.
[0025] It can be seen that, in the case of using two threads, the method of the present invention can save about 33% to 50% of the time in constructing the grid compared with the existing method.
[0026] Step 4: Determine whether the refined mesh meets the requirements. If it meets the mesh size requirements, proceed to step 5, otherwise proceed to step 3.
[0027] Step 5: Execute the Hxt2Gmsh function to convert the refined mesh into a Gmsh mesh.
[0028] 5.1 Divide the N grids refined in step (4) equally into M threads, with each thread getting N / M grid cells.
[0029] Each of the 5.2M threads uses the Hxt2Gmsh function to perform conversion operations, and pushes the converted Gmsh grid cells into the private container of each thread.
[0030] 5.3 After the conversion is completed, merge each private container into the global container to obtain the required Gmsh grid.
[0031] Using multithreaded parallelism to increase the conversion rate is a common method in the industry, but directly pressing the results of multithreaded conversion into a global container will cause thread safety issues. A common solution is to lock the global container, but this will cause a decrease in conversion efficiency. The present invention proposes using a thread-private container to store the conversion results, and finally merging the thread-private container into the global container. This method can improve conversion efficiency while ensuring thread safety.
[0032] Another object of the present invention is to provide a large-scale parallel grid generation system suitable for numerical reactors, including a data acquisition module, a grid generation module, a solver module, and a post-processing display module.
[0033] The data acquisition module is used to acquire the model data of the numerical reactor components, and divides the data into n groups of core components; and then transmits the data to the grid generation module;
[0034] The grid generation module is used to realize grid generation and save it to the memory; the grid generation module adopts the above-mentioned grid generation method.
[0035] The solver module is a mesh generator class embedded in the original solver input terminal; it is used to directly read the generated mesh data from the memory.
[0036] The grid generator class implements a loading method for filling grid cells, and the filling method uses a method of calling a wrapper class. The specific implementation of the wrapper class includes: creating a class, and implementing an internal method to fill the grid data structure; creating a python configuration script to check whether the dependent library environment is available.
[0037] The post-processing display module is used to display the grid data transmitted by the solver module in a graphical form and generate a post-processing file.
[0038] The existing solution grid generator and solver exist independently. The generated grid file needs to be written to the hard disk first, and then the solver reads it from the hard disk, which takes a long time to read / write the disk. The present invention proposes to embed the grid generator class at the input end of the original solver. The generated result does not need to be written to the hard disk, but can be directly read from the memory, which greatly shortens the required time. In addition, the method proposed in the present invention implements the filling of grid data inside the packaging class, which can solve the problem of the solver's strong dependence on the grid generator. The method proposed in the present invention does not need to modify the original solver code and meets the software engineering specifications.
[0039] The beneficial effects of the present invention are:
[0040] (1) Constructing grid cells based on lock-free atomic operations to reduce conflicts between multiple threads, accelerate grid refinement, and solve multi-thread blocking problems;
[0041] (2) Use the OpenMP parallel framework to perform multi-threaded grid cell conversion, first put the conversion results into the thread private container, wait for the conversion to end, and then merge the grid cells in the private container into the global container to solve the problem of low efficiency of the interface between the algorithm and the grid generator;
[0042] (3) The grid generation method of the present invention can greatly improve the parallelism of the grid construction method and reduce the critical area. Moreover, the grid generation rate can be increased and the grid generation time can be shortened while ensuring the quality of grid generation. The present invention has certain engineering application value.
[0043] (4) The parallel grid generation system of the present invention avoids disk I / O overhead and provides a graphical interface for displaying solution results. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is the flow chart of HXT algorithm.
[0045] Figure 2 This is a conversion diagram of step 5 of the existing HXT algorithm.
[0046] Figure 3 This is a schematic diagram of multi-threaded grid conversion in improved step 5 of the present invention.
[0047] Figure 4 This is a comparison chart of the mesh generation rate between the existing HXT version and the version of the present invention.
[0048] Figure 5 It is a set (19 roots) of component models and their top and bottom 2D grids.
[0049] Figure 6 It is a visualization diagram of the mesh solution results of the entire core assembly. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. The components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations. All features disclosed in this specification, or steps in all methods or processes disclosed, except for mutually exclusive features and / or steps, can be combined in any way.
[0051] Any feature disclosed in this specification (including any additional claims, abstract and drawings) may be replaced by other equivalent or alternative features with similar purposes unless otherwise stated. Unless otherwise stated, each feature is only an example of a series of equivalent or similar features.
[0052] A large-scale parallel grid generation system suitable for numerical reactors includes a data acquisition module, a grid generation module, a solver module, and a post-processing display module.
[0053] The data acquisition module is used to acquire the model data of the numerical reactor components, and divides the data into n groups of core components; and then transmits the data to the grid generation module;
[0054] The grid generation module is used to realize grid generation and save it to the memory; the grid generation module adopts the above-mentioned grid generation method.
[0055] Reference Figure 5 As shown, the mesh data includes three parts: a three-dimensional mesh of the component model, a two-dimensional mesh at the top of the component model, and a two-dimensional mesh at the bottom of the component model. The two-dimensional mesh at the bottom of the component model is used to fix the bottom of the component, and the two-dimensional mesh at the top of the component model is used to measure the displacement after thermal expansion.
[0056] The solver module embeds a mesh generator class at the original solver input end; it is used to directly read the generated mesh data from the memory, add boundary conditions, material properties, temperature and other physical conditions, and solve the mesh data.
[0057] The physical conditions are as follows:
[0058] Material thermal expansion coefficient: α = 1.626 × 10 -5 +3.83×10 -9 ×T
[0059] Material density: 7800kg / m3
[0060] Elastic modulus: 2.05E11 Pa
[0061] Poisson's ratio: 0.3
[0062] Initial temperature: 300℃
[0063] Final temperature: 500℃
[0064] The grid generator class implements a loading method for filling grid cells, and the filling method uses a method of calling a wrapper class. The specific implementation of the wrapper class includes: creating a class, and implementing an internal method to fill the grid data structure; creating a python configuration script to check whether the dependent library environment is available.
[0065] Reference Figure 6 As shown, the post-processing display module is used to display the grid data transmitted by the solver module in a graphical form and generate a post-processing file.
[0066] The existing solution grid generator and solver exist independently. The generated grid file needs to be written to the hard disk first, and then the solver reads it from the hard disk, which takes a long time to read / write the disk. The present invention proposes to embed the grid generator class at the input end of the original solver. The generated result does not need to be written to the hard disk, but can be directly read from the memory, which greatly shortens the required time. In addition, the method proposed in the present invention implements the filling of grid data inside the packaging class, which can solve the problem of the solver's strong dependence on the grid generator. The method proposed in the present invention does not need to modify the original solver code and meets the software engineering specifications.
[0067] Reference Figure 1 , a large-scale parallel grid generation method suitable for numerical reactors is specifically:
[0068] Step 1: The numerical reactor assembly model consists of 712 core assemblies, which are divided into 37 groups, each with about 19 core assemblies;
[0069] Step 2: Read the GEO format geometry model files on each of the 37 computing nodes, use the 3D finite element mesh generator Gmsh to generate a 2D mesh for each core component, and convert the 2D mesh format using the Gmsh2Hxt preprocessing function;
[0070] Step 3: Construct the 3D initial mesh from the 2D mesh after format conversion;
[0071] The construction here is a conventional technical operation in this field, so it is not explained in detail;
[0072] Step 4: Use the OpenMP parallel framework to perform parallel mesh refinement operations on the three-dimensional initial mesh based on lock-free atomic operations. Multi-threaded parallel generation of tens of billions of three-dimensional meshes, with a single-node mesh volume of approximately 280 million.
[0073] Each thread performs the following operations:
[0074] a) Get the grid number num.
[0075] b) Determine whether num is empty, if so, execute step c), if not, execute step d);
[0076] c) Add one to the current maximum grid number and set it as the latest grid number;
[0077] d) Determine whether num is greater than the current maximum grid number. If so, set num as the latest grid number. If not, add 1 to the current maximum grid number and set it as the latest grid number.
[0078] Each thread executes step a and step b simultaneously. If two or more threads need to execute step c or step d, one thread needs to wait for the other thread to complete execution. If two threads execute step c and step d respectively, they will be executed simultaneously.
[0079] like Figure 1 The existing HXT algorithm uses critical sections to wrap steps a to d. If and only if one thread completes all steps a to d, other threads can start to execute from step a. That is, the existing method does not achieve true parallelism in the grid construction process. The method proposed in the present invention can enable multiple threads to construct a grid at the same time. Steps a and b can be executed synchronously by multiple threads, and lock-free atomic operations are used inside steps c and d to ensure thread safety.
[0080] The following example uses two threads constructing a grid simultaneously, assuming that it takes time T to execute each step.
[0081] Existing HXT method: Thread 1 executes step a to step d step by step, which takes 3T (only one of step c and d is executed). After thread 1 is completed, thread 2 starts to execute, which also takes 3T. The two threads take a total of 6T.
[0082] The method of the present invention: Thread 1 starts to execute step a and step b, while thread 2 also executes step a and step b, which takes 2T. If both threads need to execute step c, one thread needs to wait for the other thread to complete execution, which takes 2T. If one of the two threads executes step c and the other executes step d, they can be executed synchronously, which takes 1T. In summary, the method of the present invention takes a total of 3 to 4T.
[0083] It can be seen that, in the case of using two threads, the method of the present invention can save about 33% to 50% of the time in constructing the grid compared with the existing method.
[0084] Step 4: Determine whether the refined mesh meets the requirements. If it meets the mesh size requirements, proceed to step 5, otherwise proceed to step 3.
[0085] Step 5: Execute the Hxt2Gmsh function to convert the refined mesh into a Gmsh mesh.
[0086] 5.1 Divide the N grids refined in step (4) equally into M threads, with each thread getting N / M grid cells.
[0087] Each of the 5.2M threads uses the Hxt2Gmsh function to perform conversion operations, and pushes the converted Gmsh grid cells into the private container of each thread.
[0088] 5.3 After the conversion is completed, merge each private container into the global container to obtain the required Gmsh grid.
[0089] Step 5 of the existing HXT algorithm refers to Figure 2 As shown, single-thread conversion is adopted, and the calculation time is long. The multi-thread parallel conversion proposed by the present invention refers to Figure 3 As shown, OpenMP multi-threaded conversion is adopted, and thread-private containers are innovatively introduced to solve the bottleneck of global containers.
[0090] OpenMP (Open Multi-Processing) is a set of multi-threaded concurrent programming APIs that support cross-platform shared memory. It uses C, C++ and Fortran languages and can run on most processor systems and operating systems. OpenMP supports three methods: critical section, lock, and lock-free atomic operation to achieve synchronization between threads. According to statistics, the time consumption of the above three methods accounts for about 7:3:1. Correspondingly, the application scenario restrictions of lock-free atomic operation are also more stringent.
[0091] The present invention proposes to use lock-free atomic operations to replace the critical section in the open source version to update the grid number, which can reduce the time consumption to one seventh of the original. In addition, the critical section of the original version is limited to the entire construction method, that is, only one thread can execute the code of the construction method at the same time, and other threads are in a blocked waiting state. The present invention proposes to use lock-free atomic operations to reduce the scope of action to the code line that modifies the grid number, and multiple threads can execute the grid construction method code segment at the same time.
[0092] The numerical reactor consists of 712 core components. In order to ensure the high precision requirements of numerical simulation, the model needs to be divided into billions or even tens of billions of grids in practical applications. The existing solutions based on shared memory architecture cannot store such huge grid files due to the limited memory size of a single computing node. The present invention proposes to divide the 712 core components of the whole core into 37 groups, with about 19 components in each group. Figure 5, which shows a group of 19 equally divided components. Then, mesh generation was performed on each of the 37 computing nodes. In the end, each group of model divisions generated about 280 million meshes, and the number of meshes for the entire core component exceeded 10 billion. Since the task load of mesh generation was balanced to 37 different computing nodes, the tasks that each computing node needed to process were greatly reduced.
[0093] Compared with the shared memory architecture solution, this solution avoids the use of expensive high-performance servers with large memory, and only requires a cheap ordinary server cluster, and effectively shortens the calculation time. Figure 4 .
[0094] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A large-scale parallel grid generation method suitable for numerical reactors, characterized in that The method includes: Step 1: The numerical reactor assembly model consists of a number of core assemblies, which are equally divided into n groups of core assemblies; Step 2: Generate a 2D mesh for each core component using the 3D finite element mesh generator Gmsh, and convert the 2D mesh format using the Gmsh2Hxt preprocessing function; Step 3: Construct the 3D initial mesh from the 2D mesh after format conversion; Step 4: Based on lock-free atomic operations, multi-threading is used to perform parallel mesh refinement operations on the 3D initial mesh; Each thread performs the following operations: a) Get the grid number num; b) Determine whether num is empty, if so, execute step c), if not, execute step d); c) Add one to the current maximum grid number and set it as the latest grid number; d) Determine whether num is greater than the current maximum grid number. If so, set num to the latest grid number. If not, add 1 to the current maximum grid number and set it as the latest grid number. Each thread executes step a and step b simultaneously. If two or more threads need to execute step c or step d, one thread needs to wait for the other thread to complete execution. If two threads execute step c and step d respectively, they will be executed simultaneously. Step 5: Determine whether the refined mesh meets the requirements; if it meets the mesh size requirements, execute step 6, otherwise execute step 4; Step 6: Execute the Hxt2Gmsh function to convert the refined mesh into a Gmsh mesh; specifically: 5.1 Divide the N grids refined in step 4 equally into M threads, with each thread getting N / M grid cells; 5.2 Each of the M threads uses the Hxt2Gmsh function to perform the conversion operation, and pushes the converted Gmsh grid cells into the private container of each thread; 5.3 After the conversion is completed, merge each private container into the global container to obtain the required Gmsh grid.
2. A large-scale parallel grid generation system suitable for numerical reactors for implementing the method of claim 1, characterized in that It includes data acquisition module, grid generation module, solver module and post-processing display module; The data acquisition module is used to acquire the model data of the numerical reactor components, and divides the data into n groups of core components; and then transmits the data to the grid generation module; The grid generation module is used to realize grid generation and save it to the memory; the grid generation module adopts the above-mentioned grid generation method; The solver module is a mesh generator class embedded in the original solver input terminal; Used to read the above generated grid data directly from the memory; The grid generator class implements a loading method for filling grid cells internally; The post-processing display module is used to display the grid data transmitted by the solver module in a graphical form and generate a post-processing file.
3. A large-scale parallel grid generation system suitable for numerical reactors as claimed in claim 2, characterized in that The grid cell filling method inside the grid generator class calls the method of the wrapper class.
4. A large-scale parallel grid generation system suitable for numerical reactors as claimed in claim 3, characterized in that The specific implementation of the packaging class includes: creating a class, and implementing internal methods to fill the grid data structure; creating a python configuration script to check whether the dependent library environment is available.
