Cartesian grid wall surface distance calculation method for load balance under parallel framework, medium and equipment
By combining grid encryption and KD tree index structure under the parallel framework, the problem of computational load imbalance in Cartesian mesh wall distance calculation is solved, and more efficient adaptive Cartesian mesh generation and parallel computing are achieved.
Patent Information
- Application Number
- CN202411465654.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-21
AI Technical Summary
The prior art has a problem of computational load imbalance when calculating the wall distance of Cartesian grids, which affects the computing efficiency and scalability of large-scale parallel generation of adaptive Cartesian grids.
By using a combination of grid encryption and KD tree index structure under the parallel framework, it is predicted that the number of iterations of newly generated Cartesian grid cells in the KD tree is the same as the old one, and the partition weight is set based on this to consider the weight. Mesh partitioning.
It effectively alleviates the imbalance of computational load between processes, significantly shortens the time for calculating wall distances, and improves the efficiency and parallel scalability of adaptive Cartesian grid generation.
Smart Images

Figure CN119442360A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of fluid mechanics, and in particular relates to a method, medium and device for calculating the wall distance of a Cartesian grid with load balancing under a parallel framework. Background Art
[0002] As a grid type with simple generation, low memory requirements, high computational efficiency and high degree of automation, Cartesian grid has been a hot topic in computational fluid dynamics research in recent years. However, compared with body-fitting grids, the isotropy of Cartesian grids causes a sharp increase in the number of grids, which in turn causes a sharp increase in the time spent on wall distance calculations. Therefore, it is necessary to introduce large-scale parallel technology. At this time, the grid is partitioned with the help of a global grid encoding method based on space filling curves. By allowing the data under any single fork tree structure to be distributed in different processes, the global grid number can be used to effectively control the difference in the number of grids between processes, achieving load balance at the level of the number of grids.
[0003] Before calculating the wall distance, the object surface geometric model data set must be processed first. The most commonly used solution is to store the object surface triangle units and their related data in an array in order, and use the traversal method to search for the wall distance and corresponding object surface triangle units of each Cartesian grid. This solution is the most intuitive, but with the increase of the calculation scale, its computational complexity and time consumption will become unacceptable. The traditional ADT (Alternating Digital Tree) solution is used to store the object surface triangle units and their related data in the AD tree, which can greatly reduce the calculation time consumption, but the AD tree is not necessarily a balanced binary tree, and the search efficiency is unstable. The KDT (K-Dimensional Tree) solution is used to store the object surface triangle units and their related data in a balanced KD tree, which significantly improves the calculation efficiency. However, the introduction of large-scale parallel technology makes it so that when calculating the wall distance, different spatial Cartesian grid units correspond to different object surface triangle units, the number of iterations in the KD tree is different, and the required amount of calculation is also different. Although the grid load between processes is balanced, the calculation load is not balanced, which can easily cause significant differences in the calculation time consumption between processes, thereby affecting the overall calculation efficiency.
[0004] As the complexity of three-dimensional surface geometric models increases, the shape data information that needs to be processed increases, affecting the computational efficiency and scalability of large-scale parallel generation of adaptive Cartesian grids. Currently, there is no effective method to deal with the computational load imbalance problem when calculating Cartesian grid wall distances. Summary of the invention
[0005] In view of the deficiencies in the prior art, the present invention provides a method, medium and device for calculating the wall distance of a Cartesian grid with load balancing under a parallel framework.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a method for calculating wall distance of a Cartesian grid with load balancing in a parallel framework, comprising:
[0008] S1: Abstracting an object surface geometry model file from a complex real shape, wherein the object surface geometry model is formed by connecting multiple object surface triangle units through shared vertices;
[0009] S2: Reading vertex information of all object surface triangle units in the object surface geometric model file, and constructing a spatial bounding box based on each object surface triangle unit;
[0010] S3: Based on the object plane triangular unit and the spatial bounding box, establish an object plane data index structure based on a KD tree;
[0011] S4: placing the object surface geometric model in the flow field area required for calculation, and dividing the flow field area into Cartesian grids to obtain a series of isotropic cubic Cartesian grid units with grid surfaces parallel to the coordinate axes;
[0012] S5: Determine the Cartesian grid unit for which the wall distance needs to be calculated, search the KD tree to obtain the object plane triangle unit corresponding to the wall distance of the Cartesian grid unit, calculate the distance from the Cartesian grid unit to the object plane triangle unit and determine it as the wall distance, and record the number of searches for the Cartesian grid unit in the KD tree;
[0013] S6: Perform intersection and inside-outside judgment on all Cartesian grid cells, encrypt the Cartesian grid cells that intersect with the object plane triangle cells, and divide them into finer grid cells. The newly generated fine grid cells inherit the search times of the coarse grid cells in the KD tree, and the search times of the remaining grid cells that have not been encrypted in the KD tree are set to 0;
[0014] S7: before calculating the wall distance next time, a weight is set based on the number of searches for each Cartesian grid cell in the KD tree, and a grid parallel partition is performed considering the weight, and the Cartesian grid cells and related data are weighted and averaged to be allocated to different cores for calculation;
[0015] S8: Repeat steps S5 to S7 until the set number of mesh encryption times is reached; the obtained mesh parameters of the Cartesian mesh unit including the wall distance are used to numerically solve the object surface geometry model, and then obtain the outflow flow field of the real complex shape under the preset working conditions.
[0016] Optionally, in step S3, the KD tree is a balanced binary tree, and the data structure within its node includes: the object plane triangle unit corresponding to the node, the midpoint coordinate data of the object plane triangle unit, the bounding box data of the object plane triangle unit, the spatial range represented by the node, the partition plane that divides the space represented by the node into two left and right subspaces, the coordinate axis perpendicular to the partition plane, the left branch KD tree composed of all data located in the left subspace, the right branch KD tree composed of all data located in the right subspace, and the parent node of the node.
[0017] Optionally, step S3 specifically includes the following sub-steps:
[0018] S31: Enter the root node of the KD tree, select the x-axis as the coordinate axis stored in the node, and select the bounding box of the object surface geometric model as the spatial range represented by the node;
[0019] S32: for the spatial range represented by the node, the midpoint coordinates of all object plane triangular units in the space are obtained, and according to the coordinate axis stored in the node, the median of the midpoint coordinates on the coordinate axis is retrieved, and the object plane triangular unit corresponding to the median and its related data are stored in the node. The plane formed by all spatial points whose coordinates on the coordinate axis are equal to the median is the splitting plane stored in the node;
[0020] S33: Within the spatial range represented by the node, according to the coordinate axis stored in the node, the KD tree consisting of all object plane triangle units corresponding to the midpoint coordinates less than the median is the left branch KD tree of the node, and its bounding box is the left subspace of the node; the KD tree consisting of all object plane triangle units corresponding to the midpoint coordinates greater than the median is the right branch KD tree of the node, and its bounding box is the right subspace of the node;
[0021] S34: Enter the next layer of nodes, update the coordinate axes stored in the node in the order of x-axis, y-axis, and z-axis according to the number of layers of the node, and update the spatial range represented by the node according to the left and right subspaces divided by the parent node;
[0022] S35: Repeat steps S32 to S34 until all object plane triangle units are stored in the nodes.
[0023] Optionally, step S5 specifically includes the following sub-steps:
[0024] S51: For the Cartesian grid cell for which the wall distance needs to be calculated, set its initial search times N=0 in the KD tree;
[0025] S52: For the Cartesian grid cell for which the wall distance needs to be calculated, set its initial wall distance to L: if the grid cell is an initial Cartesian grid cell, L is the distance from the grid cell to the object surface triangle unit stored in the root node; if the grid cell is a fine grid cell newly generated after grid encryption, L is the wall distance of the coarse grid cell before grid encryption;
[0026] S53, starting from the root node of the KD tree, obtaining the object plane triangle unit stored in the root node, and setting the number of searches for the Cartesian grid unit N=1;
[0027] S54: Calculate the distance L from the Cartesian grid unit to the object plane triangle unit new , compare L with L new If L>L new , then update L = L new ;
[0028] S55: Enter the subtree, obtain the object plane triangle unit stored in the child node, and set the number of searches for the Cartesian grid unit N=N+1;
[0029] S56: Repeat steps S54 to S55 until the KD tree search is completed.
[0030] Optionally, in step S7, the grid parallel partitioning is to distribute and store all Cartesian grid units and related data in different cores when multiple cores participate in flow field calculation at the same time, and each core only performs calculation tasks for the Cartesian grid units stored therein.
[0031] Optionally, in step S7, the weight of the grid parallel partitioning is W=N+0.01, where N represents the number of searches of the Cartesian grid unit.
[0032] In a second aspect, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the load-balanced Cartesian grid wall distance calculation method under a parallel framework as described in the first aspect.
[0033] In a third aspect, the present invention provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the load-balanced Cartesian grid wall distance calculation method under the parallel framework as described in the first aspect is implemented.
[0034] The beneficial effect of the present invention is that the present invention combines the characteristics of the newly generated Cartesian grid units and the old Cartesian grid units before and after grid encryption, predicts that the new units and the old units correspond to the same object plane triangle unit when calculating the wall distance, so the number of iterations of the new units in the KD tree is the same as that of the old units. Based on the number of iterations of each unit in the KD tree after prediction, its partition weight is set proportional to the number of iterations, and the partition considering the weight is performed before calculating the wall distance, so that the imbalance of the calculation load between processes when calculating the wall distance is alleviated, and the time required for calculating the wall distance in the large-scale parallel generation of adaptive Cartesian grids is significantly shortened, thereby improving the efficiency of adaptive Cartesian grid generation and parallel scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 The present invention is a flow chart of a method for calculating the wall distance of a Cartesian grid with load balancing under a parallel framework.
[0036] Figure 2 Schematic diagram of generating a KD tree based on the midpoints of object plane triangle units in one embodiment of the present invention.
[0037] Figure 3 It is a schematic diagram of mesh partitioning based on a Z-shaped space filling curve before mesh encryption in one embodiment of the present invention.
[0038] Figure 4 This is a schematic diagram of initial mesh partitioning without considering weights based on a Z-shaped space filling curve after mesh encryption in one embodiment of the present invention.
[0039] Figure 5 Schematic diagram of the number of iterations required to calculate the wall distance based on the KD tree before mesh encryption in one embodiment of the present invention.
[0040] Figure 6 Schematic diagram of the number of iterations required to calculate the wall distance based on the KD tree after mesh encryption in one embodiment of the present invention.
[0041] Figure 7 It is a schematic diagram of grid partitioning taking weights into consideration after optimization based on a Z-shaped space filling curve and the number of iterations after grid encryption in one embodiment of the present invention.
[0042] Figure 8 This is a comparison diagram of the initial grid partitioning without considering weights after grid encryption and the grid partitioning considering weights after optimization in one embodiment of the present invention.
[0043] Fig. 9 Schematic diagram of an adaptive Cartesian grid constructed based on the ONERA-M6 wing model in one embodiment of the present invention.
[0044] Fig.10Schematic diagram of an adaptive Cartesian grid constructed based on a DLR-F6 wing-body assembly model in one embodiment of the present invention.
[0045] Fig.11 Schematic diagram of generating an adaptive Cartesian grid and missile details based on a SU-27 fighter model in one embodiment of the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0047] In one embodiment, if Figure 1 As shown, the present invention proposes a load-balanced Cartesian grid wall distance calculation method under a parallel framework, comprising the following steps:
[0048] S1: Based on the complex shape information existing in the three-dimensional fluid mechanics problem, obtain the object surface geometry model file. The object surface geometry model file refers to a file that uses a certain number of triangle units to approximate the complex shape and stores the triangle units in a specified order to abstract the object surface geometry model from the real complex shape. The triangle unit is also the object surface triangle unit, which is the basic unit that constitutes the object surface geometry model. It is connected by sharing vertices to form the surface of the object surface geometry model.
[0049] S2: Read all the vertex information of the object surface triangle units in the object surface geometry model file, and construct a spatial bounding box based on the dimensional range of each unit. The spatial bounding box refers to a simple cuboid that completely encloses the specified object and is as close to the object as possible.
[0050] S3: Based on the object surface triangular unit and the spatial bounding box, establish the object surface data index structure, namely the KD tree.
[0051] S4: The object surface geometry model is placed in the flow field area required for calculation, and the flow field area is divided into Cartesian grids to obtain a series of isotropic cubic units with grid surfaces parallel to the coordinate axes, namely Cartesian grid units.
[0052] S5: Determine the Cartesian grid cell for which the wall distance needs to be calculated. The wall distance refers to the shortest distance from the midpoint of the Cartesian grid cell to the object surface geometry model. The object surface geometry model is composed of a certain number of object surface triangle units. Therefore, the wall distance is the minimum value of the distance between the midpoint of the Cartesian grid cell and all object surface triangle units. Enter the KD tree, search in the KD tree, obtain the object surface triangle unit corresponding to the wall distance of the Cartesian grid cell, calculate the distance from the Cartesian grid cell to the object surface triangle unit and determine it as the wall distance L, and record the number of searches N for the grid cell in the KD tree.
[0053] S6: After performing intersection determination, inside-outside determination and other grid generation related calculations on all Cartesian grid cells, grid encryption is performed to divide the Cartesian grid cells into several finer grid cells. The newly generated fine grid cells inherit the number of searches N of the coarse grid cells in the KD tree, and the number of searches N of the remaining grid cells that have not been encrypted in the KD tree is 0.
[0054] S7: Before calculating the wall distance next time, weights are set based on the number of grid cell searches in the KD tree, and weighted grid parallel partitioning is performed. Grid parallel partitioning means that when multiple cores are simultaneously involved in flow field calculations, all Cartesian grid cells and related data are distributed and stored in different cores, and each core only performs calculation tasks for the Cartesian grid cells stored inside it. Distributed storage can directly distribute Cartesian grid cells and related data to different cores evenly according to the number of grid cells, that is, grid parallel partitioning without considering weights; or Cartesian grid cells and related data can be weighted and evenly distributed to different cores by setting the grid parallel partition weights of each Cartesian grid cell, that is, grid parallel partitioning considering weights.
[0055] S8: Repeat steps S5 to S7. The number of times the mesh is refined depends on the flow field resolution required.
[0056] Using the above method, the grid parameters of the Cartesian grid unit, including the wall distance, can be obtained quickly and efficiently, so as to carry out numerical solution of the surface geometry model and obtain the outflow field of the complex real shape under the preset working conditions.
[0057] In step S3, the KD tree is a balanced binary tree, and the data structure in its node includes: the object plane triangle unit corresponding to the node, the midpoint coordinate data of the object plane triangle unit, the bounding box data of the object plane triangle unit, the spatial range represented by the node, the dividing plane that divides the space represented by the node into two left and right subspaces, the coordinate axis perpendicular to the dividing plane, the left branch KD tree composed of all data in the left subspace, the right branch KD tree composed of all data in the right subspace, and the parent node of the node.
[0058] It should be noted that the algorithm steps described in this embodiment are all given in two dimensions, and the area where the mesh is specified is only to more clearly illustrate the principle and implementation method. The units that need to be meshed in the actual mesh generation process depend on the specific application and design requirements of the technical solution. Professional and technical personnel can use different constraints for each specific geometric shape information to implement the described functions, but such implementation should not be considered to be beyond the scope of this application.
[0059] In this embodiment, based on the midpoint coordinate information of all object plane triangle units in the object plane geometric model file, the left and right subtrees are divided by finding the median object plane triangle unit in the direction of the current split axis, and the split axis is changed progressively with the number of layers, and the object plane triangle units and their related data are stored in the KD tree, such as Figure 2 shown.
[0060] In this embodiment, for a 4×4 Cartesian grid, Figure 3 After global grid encoding and parallel grid partitioning of the Z-shaped space filling curve shown in the figure, all Cartesian grid cells can be evenly divided into four processes according to their number. Figure 4 After the Cartesian grid units in the dotted box area are encrypted, the global grid code is updated using a Z-type space filling curve, and the grid is initially partitioned in parallel without considering the weight. This can also make the number of grids in the four processes equal to 7, achieving load balance at the level of the number of grids.
[0061] Take the surface geometry model and Cartesian grid as an example, Figure 5 and Figure 6 As shown in the figure, since the geometric model of the object surface remains unchanged after the mesh is encrypted, if the Cartesian mesh unit is not encrypted, that is, the mesh unit remains unchanged, there is no need to recalculate the wall distance, so the number of searches for the mesh unit in the KD tree N=0; if the mesh unit is a newly generated mesh unit after the mesh is encrypted, the wall distance needs to be recalculated, so the number of searches for the mesh unit in the KD tree N>0 (the number in the parentheses represents the actual number of searches for the corresponding mesh unit in the KD tree).
[0062] like Figure 7As shown, the present embodiment provides a method for calculating the wall distance of a Cartesian grid with load balance under a parallel framework. Combining the characteristics of the newly generated Cartesian grid units and the old Cartesian grid units before and after grid encryption, it is predicted that the new units and the old units correspond to the same object plane triangle unit when calculating the wall distance. Therefore, the number of iterations of the new units in the KD tree is the same as that of the old units, and the number of iterations of the remaining units that have not undergone grid encryption in the KD tree should be 0 (the numbers in the square brackets represent the predicted number of searches for the corresponding grid units in the KD tree). Based on the number of iterations of each unit in the KD tree after prediction, its partition weight is set proportional to the number of iterations, and the global grid encoding is performed in combination with the Z-type space filling curve. The grid is partitioned in parallel with weight after optimization before calculating the wall distance. At this time, the number of grids in the four processes is 4, 5, 11, and 8, respectively, and load balance is not achieved at the level of the number of grids.
[0063] Combining the two different grid partitioning methods and the actual number of searches of Cartesian grid cells in the KD tree after grid encryption in this embodiment, as shown in FIG. Figure 8 As shown in the figure, when the grid parallel partitioning without considering the weight is adopted, the total number of iterations of process 1 is the largest among the four processes, which is 24 times; the total number of iterations of process 2 is the smallest, which is 4 times. The maximum number of iterations between the processes is 20. Although the load balance is achieved at the level of the number of grids, the calculation load between the processes is extremely unbalanced. When the grid parallel partitioning with weights is adopted after optimization, the total number of iterations of process 1 is the largest among the four processes, which is 16 times; the total number of iterations of process 2 and process 4 is the smallest, which is 12 times. The maximum number of iterations between the processes is 4. Although the load balance is not achieved at the level of the number of grids, the imbalance of the calculation load between processes when calculating the wall distance is alleviated, and the time required to calculate the wall distance in the process of large-scale parallel generation of adaptive Cartesian grids is significantly shortened, which improves the efficiency of adaptive Cartesian grid generation and parallel scalability.
[0064] The ONERA-M6 wing model, the DLR-F6 wing-body assembly model, and the SU-27 fighter model are provided below to illustrate the specific application of the method of this embodiment. Fig. 9 , Fig.10 and Fig.11 As shown in the figure, each model performs mesh encryption operations for different times, and the other parameters remain unchanged, using 64 cores in parallel.
[0065] Table 1 Comparison of wall distance calculation running time using different grid partitioning methods
[0066]
[0067] In another embodiment, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the load-balanced Cartesian grid wall distance calculation method under a parallel framework as described in the above embodiment.
[0068] In another embodiment, the present invention proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the load-balanced Cartesian grid wall distance calculation method under the parallel framework as described in the above embodiment is implemented.
[0069] In the embodiments disclosed in the present application, the computer storage medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. The computer storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the above. More specific examples of computer storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0070] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0071] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework, characterized in that: include: S1: Abstracting an object surface geometry model file from a complex real shape, wherein the object surface geometry model is formed by connecting multiple object surface triangle units through shared vertices; S2: Reading vertex information of all object surface triangle units in the object surface geometric model file, and constructing a spatial bounding box based on each object surface triangle unit; S3: Based on the object plane triangular unit and the spatial bounding box, establish an object plane data index structure based on a KD tree; S4: placing the object surface geometric model in the flow field area required for calculation, and dividing the flow field area into Cartesian grids to obtain a series of isotropic cubic Cartesian grid units with grid surfaces parallel to the coordinate axes; S5: Determine the Cartesian grid unit for which the wall distance needs to be calculated, search the KD tree to obtain the object plane triangle unit corresponding to the wall distance of the Cartesian grid unit, calculate the distance from the Cartesian grid unit to the object plane triangle unit and determine it as the wall distance, and record the number of searches for the Cartesian grid unit in the KD tree; S6: Perform intersection and inside-outside judgment on all Cartesian grid cells, encrypt the Cartesian grid cells that intersect with the object plane triangle cells, and divide them into finer grid cells. The newly generated fine grid cells inherit the search times of the coarse grid cells in the KD tree, and the search times of the remaining grid cells that have not been encrypted in the KD tree are set to 0; S7: before calculating the wall distance next time, a weight is set based on the number of searches for each Cartesian grid cell in the KD tree, and a grid parallel partition is performed considering the weight, and the Cartesian grid cells and related data are weighted and averaged to be allocated to different cores for calculation; S8: Repeat steps S5 to S7 until the set number of mesh encryption times is reached; the obtained mesh parameters of the Cartesian mesh unit including the wall distance are used to numerically solve the object surface geometry model, and then obtain the outflow flow field of the real complex shape under the preset working conditions.
2. The method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework according to claim 1, characterized in that: In step S3, the KD tree is a balanced binary tree, and the data structure in its node includes: the object plane triangle unit corresponding to the node, the midpoint coordinate data of the object plane triangle unit, the bounding box data of the object plane triangle unit, the spatial range represented by the node, the dividing plane that divides the space represented by the node into two left and right subspaces, the coordinate axis perpendicular to the dividing plane, the left branch KD tree composed of all data in the left subspace, the right branch KD tree composed of all data in the right subspace, and the parent node of the node.
3. The method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework according to claim 2, characterized in that: Step S3 specifically includes the following sub-steps: S31: Enter the root node of the KD tree, select the x-axis as the coordinate axis stored in the node, and select the bounding box of the object surface geometric model as the spatial range represented by the node; S32: for the spatial range represented by the node, the midpoint coordinates of all object plane triangular units in the space are obtained, and according to the coordinate axis stored in the node, the median of the midpoint coordinates on the coordinate axis is retrieved, and the object plane triangular unit corresponding to the median and its related data are stored in the node. The plane formed by all spatial points whose coordinates on the coordinate axis are equal to the median is the splitting plane stored in the node; S33: Within the spatial range represented by the node, according to the coordinate axis stored in the node, the KD tree consisting of all object plane triangle units corresponding to the midpoint coordinates less than the median is the left branch KD tree of the node, and its bounding box is the left subspace of the node; the KD tree consisting of all object plane triangle units corresponding to the midpoint coordinates greater than the median is the right branch KD tree of the node, and its bounding box is the right subspace of the node; S34: Enter the next layer of nodes, update the coordinate axes stored in the node in the order of x-axis, y-axis, and z-axis according to the number of layers of the node, and update the spatial range represented by the node according to the left and right subspaces divided by the parent node; S35: Repeat steps S32 to S34 until all object plane triangle units are stored in the nodes.
4. The method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework according to claim 2, characterized in that: Step S5 specifically includes the following sub-steps: S51: For the Cartesian grid cell for which the wall distance needs to be calculated, set its initial search times N in the KD tree to 0; S52: For the Cartesian grid cell for which the wall distance needs to be calculated, set its initial wall distance to L: if the grid cell is an initial Cartesian grid cell, L is the distance from the grid cell to the object surface triangle unit stored in the root node; if the grid cell is a fine grid cell newly generated after grid encryption, L is the wall distance of the coarse grid cell before grid encryption; S53, starting from the root node of the KD tree, obtaining the object plane triangle unit stored in the root node, and setting the number of searches for the Cartesian grid unit N=1; S54: Calculate the distance L from the Cartesian grid unit to the object plane triangle unit new , compare L with L new If L>L new , then update L = L new ; S55: Enter the subtree, obtain the object plane triangle unit stored in the child node, and set the number of searches for the Cartesian grid unit N=N+1; S56: Repeat steps S54 to S55 until the KD tree search is completed.
5. The method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework according to claim 1, characterized in that: In step S7, the grid parallel partitioning is to distribute and store all Cartesian grid units and related data in different cores when multiple cores participate in flow field calculation at the same time, and each core only performs calculation tasks for the Cartesian grid units stored therein.
6. The method for calculating the wall distance of a Cartesian grid with load balancing in a parallel framework according to claim 5, characterized in that: In step S7, the weight of the grid parallel partitioning is W=N+0.01, where N represents the number of searches of the Cartesian grid unit.
7. A computer-readable storage medium storing a computer program, characterized in that: The computer program enables a computer to execute the load-balanced Cartesian grid wall distance calculation method under a parallel framework as described in any one of claims 1 to 6.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for calculating the wall distance of a Cartesian grid with load balancing under a parallel framework as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and device for calculating wall distance under Cartesian grid
CN115357849A
Obstacle detecting apparatus and method, and storage medium which stores program for implementing the method
US20010018640A1