An efficient local mesh refinement method and system based on OpenFOAM
By identifying and merging local grid sets in OpenFOAM, efficient local grid encryption of the computational domain is achieved, solving the time-consuming problem of multiple iterations in traditional methods and improving grid division efficiency and calculation speed.
Patent Information
- Application Number
- CN202411786738.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-12-06
AI Technical Summary
When performing local mesh encryption on the computational domain in OpenFOAM, traditional methods require multiple iterations and consume a lot of computing resources, which is especially inefficient when multiple local areas are involved.
An efficient local mesh encryption method based on OpenFOAM is proposed. By identifying and modeling the target object, generating the background mesh, determining the area to be encrypted, merging the local mesh sets, and using the global mesh set for one-time encryption, it reduces repeated operations and improves efficiency.
It significantly reduces the meshing steps and time, improves computational efficiency, and greatly reduces computational costs and resource consumption, especially when multiple local areas need to be encrypted.
Smart Images

Figure CN119788326B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a pre-processing method for computational fluid dynamics (CFD), and in particular to an OpenFOAM-based efficient local grid encryption method and system. Background Art
[0002] Computational fluid dynamics (CFD) is a method widely used in engineering, environmental science, and other fields. It can simulate the complex phenomena of liquid and gas flows and their interactions with solids. To perform CFD simulations, the computational domain must first be meshed so that the relevant equations can be solved.
[0003] OpenFOAM is an open-source CFD toolbox that provides a wide range of simulation capabilities and tools. Meshing the computational domain is a fundamental and crucial task in OpenFOAM. While OpenFOAM offers a variety of tools to assist users with meshing, traditional methods often involve multiple iterations and divisions, especially when refining specific regions within the simulation.
[0004] refineHexMesh is a command in OpenFOAM for structural mesh refinement. Although this command is very effective in local meshing, when a large number of local areas are involved, the user needs to run the command multiple times for each area, which consumes a lot of time and computing resources. Summary of the Invention
[0005] To reduce the computational steps and time required for meshing the computational domain and improve meshing efficiency, this paper proposes a fast meshing method based on OpenFOAM pre-processing. This method is particularly suitable for applications requiring encryption of multiple local regions. Using this meshing method significantly reduces the computational steps and time required for pre-processing prior to fluid numerical simulation, thereby improving meshing efficiency. This method is suitable for meshing complex computational domains in fields such as fluid dynamics simulation, heat conduction simulation, and structural mechanics simulation.
[0006] The technical solutions of the present invention are as follows:
[0007] 1. An efficient local mesh refinement method based on OpenFOAM
[0008] (1) Obtain the target object, identify and model the target object, and obtain an initial target model;
[0009] (2) Using OpenFOAM to mesh the computational domain corresponding to the initial target model, the background mesh is obtained;
[0010] (3) Determine several areas in the computational domain where the local grids to be encrypted are located according to actual needs, and record the IDs corresponding to the background grids contained in each area to form a local grid set;
[0011] (4) After merging the local grid sets corresponding to the several areas where the local grids to be encrypted are located, a global grid set is obtained;
[0012] (5) After meshing the global grid set, all encrypted local grids are obtained, and then the target model is updated to complete the encryption of the local grids.
[0013] In (3) above, the shape of the region includes a cuboid and a sphere.
[0014] Said (4) is specifically:
[0015] First, the background grid IDs in each local grid set are extracted, and then the duplicate background grid IDs are removed and the remaining background grid IDs are sorted to obtain the global grid set.
[0016] The target objects include target objects in the fields of fluid dynamics simulation, heat conduction simulation, and structural mechanics simulation.
[0017] 2. An efficient local mesh refinement system based on OpenFOAM
[0018] A target model building unit, used to obtain a target object and identify and model the target object;
[0019] A background grid division unit is used to grid the computational domain corresponding to the initial target model;
[0020] A local grid set generation unit is used to determine several areas in the computational domain where the local grids to be encrypted are located according to actual needs and to generate local grid sets corresponding to different areas;
[0021] A global grid set generating unit is used to merge local grid sets corresponding to several areas where the local grids to be encrypted are located;
[0022] The encrypted mesh division unit is used to divide the global mesh set into meshes to obtain all encrypted local meshes.
[0023] 3. A computer device
[0024] The device includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the OpenFOAM-based efficient local grid encryption method when executing the computer program.
[0025] 4. A Computer-Readable Storage Medium
[0026] The medium stores a computer program, which, when executed by a processor, implements the steps of the OpenFOAM-based efficient local grid encryption method.
[0027] 5. A computer program product
[0028] The product includes a computer program / instruction, which, when executed by a processor, implements the steps of the OpenFOAM-based efficient local grid encryption method.
[0029] The beneficial effects of the present invention are:
[0030] The present invention simplifies local grid division, which originally requires multiple steps to complete, into one step, thereby significantly improving calculation efficiency.
[0031] The present invention can efficiently divide multiple local grid sets at one time, significantly improving the efficiency and speed of grid division, especially when a large number of local grids need to be divided, which can greatly reduce the grid division time.
[0032] In addition, the present invention has good scalability and can easily cope with more complex grid division requirements, thereby achieving efficient division of local encrypted grids in the computational domain. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The present invention is further described with reference to the accompanying drawings. However, the embodiments in the accompanying drawings do not constitute any limitation to the present invention. A person skilled in the art can obtain other drawings based on the following drawings without creative effort.
[0034] Figure 1 The grid division of bubble groups with different volume fractions; (a) is the grid division when the volume fraction α is 40%, and (b) is the grid division when the volume fraction α is 10%.
[0035] Figure 2 The grid cases with and without local encryption of bubble clusters; (a) is the grid case without local encryption of bubble clusters, and (b) is the grid case with local encryption of bubble clusters.
[0036] Figure 3 The difference between the traditional method of local grid encryption and the method adopted by the present invention; (a) is a schematic diagram of the traditional method of local grid encryption, and (b) is a schematic diagram of the method adopted by the present invention.
[0037] Figure 4 These are the implementation steps of the local grid encryption method adopted by the present invention.
[0038] Figure 5The time required for the encryption process is the difference between the traditional local grid encryption method and the local grid encryption method adopted by the present invention.
[0039] Figure 6 Verification of the calculation results after local meshing for a bubble cluster with a volume fraction of 1%. DETAILED DESCRIPTION
[0040] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.
[0041] Example
[0042] This embodiment is the pre-processing part of the calculation of sparse bubble group collapse, specifically involving the grid division of bubble group. The study of direct numerical simulation of bubble group collapse is crucial to revealing the cavitation mechanism, and therefore has become a hot research field. In the actual cavitation process, the volume fraction of the cavitation area varies widely, with a minimum of less than 0.1% and a maximum of more than 40%. Therefore, it is necessary to study bubble groups within different volume fraction ranges. When calculating the collapse of bubble groups, the grid resolution at the bubble is crucial to the calculation results and directly affects the convergence of the calculation. For this reason, it is necessary to ensure that the grid resolution at the bubble is high enough during the calculation process. In order to save the number of grids, the bubble group grid is usually refined by layer-by-layer encryption, which is characterized by a higher grid resolution in the bubble group area, and the farther away from the bubble group, the lower the grid resolution.
[0043] like Figure 1 (a) and Figure 1 As shown in (b), the grid division of a bubble group containing 13 bubbles is taken as an example. While ensuring the consistency of the grid resolution at the bubbles, if the local grid encryption scheme is not adopted, when the volume fraction of the bubble group is 40%, the total number of grids is 1.54 million; when the volume fraction is 10%, the total number of grids increases to 5.68 million. This shows that the number of grids increases significantly with the decrease of the volume fraction. The reason for this result is that in the bubble group with a volume fraction of 10%, the distance between the bubbles is far, and the larger area in the middle of the bubble also maintains the same grid resolution as the bubble. This part of the grid is actually wasted. Therefore, in order to improve computational efficiency, it is necessary to fully consider the changes in the distance between bubbles and the volume fraction when designing the grid, so as to optimize the grid division and reduce unnecessary waste of computing resources.
[0044] The use of local mesh refinement technology can significantly reduce the number of meshes while ensuring that the mesh resolution at the bubble location remains unchanged. Take the mesh division of a bubble group with 13 bubbles and a volume fraction of 10% as an example. Figure 2 As shown in (a), the total number of grids when the local grid division scheme is adopted is 1.81 million; Figure 2 As shown in (b), the total number of grids when the local grid partitioning scheme is not adopted is 5.68 million. This shows that local grid partitioning significantly reduces the total number of grids, thereby improving computational efficiency.
[0045] Figure 3 The comparison between the steps of the traditional grid local encryption method and the encryption method proposed in this invention is shown. Figure 3 As shown in (a), the traditional mesh local encryption step requires performing a local encryption operation on each bubble in the bubble group. In OpenFOAM, each time a local encryption is performed, all meshes in the computational domain need to be traversed, which is a relatively time-consuming process. In contrast, the present invention proposes a method such as Figure 3 As shown in (b), only one local refinement operation is required to refine the meshes near all bubbles in the bubble cluster. This means that there is no need to traverse all the divided meshes multiple times, which greatly saves the time required for mesh refinement.
[0046] In this embodiment, the local grid encryption steps of the present invention are as follows:
[0047] like Figure 4 As shown, the present invention proposes an efficient local mesh encryption method based on OpenFOAM, which includes the following steps:
[0048] (1) Acquire the target object and identify and model the target object to obtain an initial target model; the target object includes target objects in the fields of fluid dynamics simulation, heat conduction simulation, and structural mechanics simulation.
[0049] (2) Using OpenFOAM to mesh the computational domain corresponding to the initial target model, the background mesh is obtained;
[0050] (3) According to actual needs (local areas where accurate calculation results are desired), several areas in the computational domain where the local grids to be encrypted are located are determined, which are recorded as local encryption areas c1…cn. The IDs of the background grids contained in each area are recorded and form a local grid set. With the center of each bubble in the bubble group as the center, the coordinates of the cuboid outside the bubble are determined and marked using the setSet command in OpenFOAM. That is, the IDs of all the grids in the background grid that are inside the cuboid are found and stored in the c1…cn file.
[0051] (4) After merging the local grid sets corresponding to the several areas where the local grids to be encrypted are located, a global grid set is obtained, which is recorded as a combinedSet file;
[0052] (4) Specifically:
[0053] First, the background grid IDs in each local grid set are extracted, and then the duplicate background grid IDs are removed and the remaining background grid IDs are sorted to obtain the global grid set.
[0054] (5) After using the refineHexMesh command in OpenFOAM to mesh the global mesh set (i.e., binary division operation), all encrypted local meshes are obtained, and then the meshes that have not been locally encrypted are replaced with the newly divided meshes, that is, the target model is updated and the encryption of the local meshes is completed. It can also be viewed using third-party software such as ParaView, and then the calculation process such as bubble group collapse is executed. After a mesh encryption operation is performed on a certain background mesh, its mesh size is half of the original one and the mesh resolution is twice the original one. The method proposed in the present invention realizes the function of obtaining a local mesh set that meets the local encryption requirements in the background mesh and encrypting multiple areas that need to be locally encrypted at the same time. This not only accurately captures all the mesh IDs that need to be encrypted in the background mesh, but also avoids the problem of too long total mesh division time caused by dividing each local mesh set individually multiple times. It can achieve efficient division of local meshes in the computational domain, especially when there are a large number of local meshes that need to be divided, which can significantly reduce the mesh division time.
[0055] From the above encryption steps, it can be seen that the more bubbles in a bubble group need to be locally encrypted, the more obvious the superiority of the local mesh encryption method of the present invention is. In order to further quantify the effect of the local mesh encryption of the present invention, the bubble groups with a number of bubbles ranging from 13 to 646 were statistically analyzed, and the time required for the traditional local mesh encryption method and the encryption method of the present invention were compared. Figure 5 The results show that the more bubbles required, the faster the local mesh encryption time required by the present invention compared to traditional encryption methods. Specifically, when the number of bubbles reaches hundreds, the time required is more than 20 times faster than the traditional method; and when the number of bubbles reaches 646, the speed is nearly 100 times faster.
[0056] In addition, when the bubble group is relatively sparse, multiple local encryption operations can be performed on each bubble. According to the characteristics of the mesh encryption method of the present invention, when the mesh resolution at the bubble is consistent, the more times the local mesh is encrypted around each bubble, the smaller the total amount of mesh will be. The local mesh encryption method used in the present invention is more efficient than the traditional local encryption method. Figure 6 As shown in the figure, taking a bubble group with a volume fraction of 1% as an example, the relationship between the number of local mesh refinements performed for each bubble and the final total number of meshes is compared, as well as the difference between the evolution of the calculated bubble group collapse radius and the collapse sound pressure. Figure 6(a) is the grid distribution after a local grid division of a bubble group with a volume fraction of 1%. Figure 6 (b) is the number of times of local refinement and the corresponding total number of grids when the grid resolution near the bubble is the same. Figure 6 (c) shows the evolution of the equivalent radius of the bubble group over time obtained by simulation with different densification times of the grid near the bubble. Figure 6 (d) shows the temporal evolution of the acoustic pressure radiated by the bubble cluster, obtained by simulating different mesh densifications near the bubble. The results show that increasing the number of local densifications at the bubble site reduces the total number of meshes, and the calculated results are consistent, achieving the same accuracy.
[0057] The present invention also proposes an efficient local mesh encryption system based on OpenFOAM, comprising:
[0058] A target model building unit, used to obtain a target object and identify and model the target object;
[0059] A background grid division unit is used to grid the computational domain corresponding to the initial target model;
[0060] A local grid set generation unit is used to determine several areas in the computational domain where the local grids to be encrypted are located according to actual needs and to generate local grid sets corresponding to different areas;
[0061] A global grid set generating unit is used to merge local grid sets corresponding to several areas where the local grids to be encrypted are located;
[0062] The encrypted mesh division unit is used to divide the global mesh set into meshes to obtain all encrypted local meshes.
[0063] The present invention also proposes a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the efficient local grid encryption method based on OpenFOAM are implemented.
[0064] The present invention also proposes a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the efficient local grid encryption method based on OpenFOAM are implemented.
[0065] The present invention also proposes a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of an efficient local grid encryption method based on OpenFOAM.
[0066] Finally, it should be noted that the above embodiments and explanations are intended only to illustrate the technical solutions of the present invention and are not intended to limit the present invention. It should be understood by those skilled in the art that modifications or equivalent substitutions to the technical solutions of the present invention may be made without departing from the spirit and scope of the technical solutions disclosed herein, and all such modifications or equivalent substitutions shall be encompassed within the scope of protection of the claims of the present invention.
Claims
1. An efficient local mesh encryption method based on OpenFOAM, characterized in that: The following steps are involved: (1) Acquire the target object, identify and model the target object, and obtain an initial target model; (2) Using OpenFOAM to mesh the computational domain corresponding to the initial target model, the background mesh is obtained; (3) Determine several areas in the computational domain where the local grids to be encrypted are located according to actual needs, and record the IDs corresponding to the background grids contained in each area to form a local grid set; (4) After merging the local grid sets corresponding to the several areas where the local grids to be encrypted are located, a global grid set is obtained; (5) After meshing the global grid set, all encrypted local grids are obtained, and then the target model is updated to complete the encryption of the local grids.
2. The efficient local mesh encryption method based on OpenFOAM according to claim 1, characterized in that: In (3) above, the shape of the region includes a cuboid and a sphere.
3. The efficient local mesh encryption method based on OpenFOAM according to claim 1, characterized in that: Said (4) is specifically: First, the background grid IDs in each local grid set are extracted, and then the duplicate background grid IDs are removed and the remaining background grid IDs are sorted to obtain the global grid set.
4. The efficient local mesh encryption method based on OpenFOAM according to claim 1, characterized in that: The target objects include target objects in the fields of fluid dynamics simulation, heat conduction simulation, and structural mechanics simulation.
5. An efficient local mesh encryption system based on OpenFOAM, characterized by: include: A target model building unit, used to obtain a target object and identify and model the target object; A background grid division unit is used to grid the computational domain corresponding to the initial target model; A local grid set generation unit is used to determine several areas in the computational domain where the local grids to be encrypted are located according to actual needs and to generate local grid sets corresponding to different areas; A global grid set generating unit is used to merge local grid sets corresponding to several areas where the local grids to be encrypted are located; The encrypted mesh division unit is used to divide the global mesh set into meshes to obtain all encrypted local meshes.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
8. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Self-gravity simulation method based on distance control grid encryption
CN115640720A
Local grid encryption method and device for embedded discrete fracture model
CN117390998A