Adaptive grid subdivision method and optimization method based on octree and space coding

Through the adaptive grid subdivision method based on octree and spatial coding, the problems of complex nesting and drastic transition between adjacent units in octree grid subdivision technology are solved, fast positioning and smooth transition are achieved, and the calculation efficiency and accuracy are improved.

CN120612449APending Publication Date: 2025-09-09BEIJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510647104.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-09-09

AI Technical Summary

Technical Problem

The existing octree mesh subdivision technology has problems such as complex mesh nesting, the inability to connect leaf nodes with each other, sharp transitions between adjacent units, and the initial unit being a single envelope cube unit, which leads to low computational efficiency and inaccurate numerical calculation results.

Method used

An adaptive grid subdivision method based on octree and spatial coding is adopted. By calculating the unique index key of each cell, an index-cell hash table is established to quickly locate the cell. Fast retrieval and smooth transition are achieved through hash search and hierarchical constraint of adjacent cells.

Benefits of technology

It achieves fast unit positioning, reduces subdivision levels, improves computational efficiency, and ensures the accuracy and smooth transition of numerical calculations, especially for models with a large aspect ratio, effectively reducing subdivision levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120612449A_ABST
    Figure CN120612449A_ABST
Patent Text Reader

Abstract

The invention provides a self-adaptive grid subdivision method based on an octree and space coding and a structure optimization method based on self-adaptive grid subdivision. The method comprises the following steps: performing three-dimensional initial unit division on a three-dimensional space of an object to be analyzed, and endowing each initial unit with a unique BaseID according to a spatial position; subdivision unit division is carried out on each initial unit in an octree mode; for the initial unit and the subdivision unit, determining the spatial code PathCode of the unit according to the hierarchy of the unit and the spatial offset in the hierarchy of the unit, and further determining the index of the unit based on the BaseID and the PathCode; storing the index and the corresponding unit into a hash table; and the corresponding unit can be quickly positioned through hash search. And the to-be-analyzed object is divided into a plurality of initial units which are close to the model as much as possible, and compared with a single initial unit, a corresponding subdivision effect can be achieved without deeper hierarchy division.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of spatial grid division, and in particular to an octree-based hexahedral grid adaptive subdivision method and a structure optimization method. Background Art

[0002] In Computer-Aided Engineering (CAE), meshing is a crucial part of pre-processing. The type, quantity, and quality of the meshing influence the efficiency and accuracy of subsequent numerical calculations. In three-dimensional analysis, hexahedral meshes are widely used in numerical analysis fields such as structural and fluid analysis due to their superior accuracy and numerical stability.

[0003] Traditional hexahedral meshes experience a sudden increase in the number of cells when refining, placing a heavy computational burden and significantly impacting subsequent computational efficiency. Adaptive mesh subdivision technology can identify features of varying scales and perform local subdivision in areas requiring high resolution, thereby controlling the overall cell count. The octree structure, due to its efficient spatial segmentation capabilities and simple form, has become a key implementation.

[0004] However, the existing octree mesh subdivision technology has the following problems:

[0005] 1. Complex grid nesting, resulting in a non-intuitive and non-transparent data structure;

[0006] 2. Leaf nodes cannot be associated with each other. If adjacent units are in different octree branches, the search steps will be lengthy.

[0007] 3. Lack of hierarchical constraints between adjacent units, resulting in sharp transitions between adjacent units, which can also lead to inaccurate numerical calculation results;

[0008] 4. The initial unit is a single enveloping cube unit. When facing a model with a particularly large aspect ratio, the initial unit needs to be initialized according to the longest side. The subsequent mesh subdivision level is deep and the number of nested layers is large. Summary of the Invention

[0009] In light of this, the present invention provides an octree-based adaptive subdivision method and optimization method for hexahedral meshes. This method abandons the original nested octree structure and uses a given formula to calculate the unique index key for each cell. This method then establishes an index-to-cell hash table, allowing for rapid location of the corresponding cell through hash lookup. Furthermore, this index calculation formula can accommodate the index numbering of multiple initial cells, allowing the object to be analyzed to be divided into multiple initial cells, thereby achieving the best possible fit to the model. Compared to a single initial cell, this method eliminates the need for deeper subdivision levels to achieve the desired subdivision effect.

[0010] In order to solve the above technical problems, the present invention is implemented as follows.

[0011] An adaptive mesh subdivision method based on octree and spatial coding, comprising:

[0012] Perform initial unit division in the three dimensions of x, y, and z for the object to be analyzed, obtaining initial units in the shape of x0×y0×z0 cubes; assign each initial unit a unique identifier Base_ID based on its spatial position, and specify the maximum subdivision level maxlevel;

[0013] Under the maximum subdivision level maxlevel limit, the octree method is used to divide the subdivision units for each initial unit;

[0014] For the initial unit and the subdivision unit, the spatial code Path_Code of the unit is determined according to the level of the unit and the spatial offset in the level, and the index Key of the unit is determined according to the unique identifier Base_ID of the initial unit to which the unit belongs, the spatial code Path_Code and the maximum subdivision level maxlevel;

[0015] Store the index key and the corresponding unit in the hash table;

[0016] During retrieval, the unique identifier Base_ID of the initial unit to be indexed is determined according to the spatial position Position of the unit to be indexed; the spatial code Path_Code is determined according to the spatial position Position, the level and the spatial offset of the unit to be indexed; the index Key of the unit to be indexed is determined according to the unique identifier Base_ID, the spatial code Path_Code and the maximum subdivision level maxlevel; and the unit information is obtained from the hash table according to the index Key.

[0017] Preferably, the initial unit unique identifier Base_ID is determined as follows:

[0018] The unique identifier of the initial unit, Base_ID, is the unit number of level 0. The Base_ID of the parent and child units is the same. The Base_ID is expressed as:

[0019] Base_ID=i+(x0×j)+(x0×y0×k)

[0020] Among them, i, j, and k are the serial numbers of the three dimensions of the initial unit, i∈[0, x0-1], j∈[0, y0-1], and k∈[0, z0-1].

[0021] Preferably, the spatial code Path_Code is set as follows:

[0022] The initial unit is divided into 8 sub-units according to the way each unit is divided into the maxlevel layer, and the virtual units; spatially encode the virtual units of each layer;

[0023] For the virtual unit of level=0, the spatial code Path_Code=0;

[0024] For virtual units with level ≥ 1, the spatial coding Path_Code is At the beginning, the encoding is performed with an incremental step of 1; the order of the incremental encoding is in the order of the parent node spatial encoding from small to large;

[0025] When determining the spatial coding of the initial unit and the subdivided unit, it is determined according to the virtual units corresponding to the initial unit and the subdivided unit.

[0026] Preferably, in the subdivision unit division step, the spatial code Path_Code is determined in the following manner:

[0027] The spatial code of the initial unit Path_Code=0;

[0028] After a unit A is subdivided, the spatial coding of the subunits after subdivision is determined according to the spatial coding of unit A and the offset Δ of the subunit in all subunits of unit A:

[0029] Child_Path_Code=Path_Code*8+Δ

[0030] The value range of Δ is 1 to 8.

[0031] Preferably, in the retrieval step, the spatial code Path_Code is determined in the following manner:

[0032] Step a1: Get the spatial position coordinates of the unit to be indexed Position = (x p ,y p ,z p ), the level of the unit to be indexed, and the size of the unit to be indexed;

[0033] Step a2: Initialize the value of Path_Code to Path_Code of level=0, Path_Code=0;

[0034] Step a3: Calculate the offset dx, dy, dz of the unit to be indexed relative to the initial unit in three dimensions; dx = x p %(size·2 level ),dy=y p %(size·2 level ),dz=z p %(size·2 level ), where % is the remainder operation;

[0035] Step a4: Set level variable l = 1;

[0036] Step a5: Convert the offset of the current level l into a three-bit binary code x bit ,y bit ,z bit :

[0037] x bit =floor(dx / (size·2 level-l ))%2

[0038] y bit =floor(dy / (size·2 level-l ))%2

[0039] z bit =floor(dz / (size·2 level-l ))%2

[0040] Among them, floor() means rounding down;

[0041] Step a6: Encode the three-digit binary code x bit ,y bit ,z bit Convert to decimal path code 10 :

[0042] code 10 =x bit ×4+x bit ×2+z bit +1

[0043] Step a7: Update Path_Code to: Path_Code×8+code 10 ;

[0044] Step a8: Determine whether the level variable l is equal to level. If so, output the current Path_Code; otherwise, continue the loop calculation, let l be incremented by 1, and then return to step a5.

[0045] Preferably, the retrieval step further includes retrieving neighboring units of the unit to be indexed:

[0046] The unit size of the unit to be indexed is size, the level it is at is level, and the unique identifier of the initial unit is Base_ID;

[0047] Based on the spatial position Position of the cell to be indexed, obtain the spatial position Position' of the neighboring cell by adding or subtracting the size;

[0048] According to the spatial position Position' of the neighboring cell, the level of the cell to be indexed, and the size of the cell to be indexed, the spatial code Path_Code' of the neighboring cell is determined using steps a2-a8;

[0049] Determine the index Key' of the neighboring cell based on the Base_ID of the initial cell, the spatial code Path_Code' of the neighboring cell, and the set maximum subdivision level maxlevel;

[0050] If there is an index Key' in the hash table, the cell information of the neighboring cell is obtained from the hash table according to the index Key'; if there is no index Key', the spatial code Path_Code' of the parent cell of the neighboring cell is determined according to the spatial coding relationship between the parent and child cells, and the index Key' of the parent cell is determined according to the Base_ID, Path_Code' and maxlevel, and the corresponding cell information is found from the hash table again; if it is still not found, the spatial code and index of the higher-level parent cell are determined again until the cell information is found from the hash table.

[0051] Preferably, the index Key is determined as follows:

[0052]

[0053] Preferably, in the subdivision unit division step, the smoothness of the neighboring units is further checked. If the level of the neighboring unit differs from the level of the current division unit by 1 or more levels, the transition is considered to be unsmooth. The neighboring units are subdivided into grids to perform hierarchical constraints so that the ratio of adjacent grid sizes is 2:1; and constraint diffusion is achieved by performing hierarchical constraints on the neighbors of the neighboring units.

[0054] Preferably, the unit information stored in the hash table includes:

[0055] ●Maximum subdivision level maxlevel: defined by the user, all units have the same maxlevel value;

[0056] ●Unit size;

[0057] ●Unit level: All initial units have a level of 0, and the level of each sub-unit generated increases by 1;

[0058] ●Unit space position Position: expressed by the coordinates of the specified vertex among the 8 vertices of the cube;

[0059] ●Index Key;

[0060] ●The unique identifier of the initial unit, Base_ID;

[0061] ●Spatial coding Path_Code;

[0062] ●Subdivision flag isSubdivided: 0 / 1 is used to indicate whether the unit is subdivided.

[0063] The present invention also provides a structural optimization method based on adaptive grid subdivision, which is characterized by comprising:

[0064] Taking the structure to be optimized as the object to be analyzed, the adaptive grid subdivision method based on octree and spatial coding according to any one of claims 1 to 9 is used to perform unit subdivision;

[0065] Finite element analysis is performed based on the unit subdivision results of the object to be analyzed. During the analysis, the unit information is obtained by using the retrieval step of the adaptive mesh subdivision method based on octree and spatial encoding.

[0066] Based on the finite element analysis results, the structure to be optimized is optimized.

[0067] Beneficial effects:

[0068] (1) This invention abandons the original nested structure of the octree and ensures that each cell has a unique index key through the given formula. The index and the corresponding cell are stored in a hash table, which can quickly locate the cell by index without the need for nested layers.

[0069] (2) This index calculation formula can satisfy the index numbering of multiple initial units, allowing the object to be analyzed to be divided into multiple initial units, thereby being as close to the model as possible. Compared with a single initial unit, a deeper division level is not required to achieve the corresponding subdivision effect. In particular, for models with a large aspect ratio, the number of subdivision levels can be effectively reduced.

[0070] (3) The present invention can calculate the position of adjacent cells through the position relationship Position and cell size size, and then calculate the key of the adjacent cells, so as to quickly find neighboring cells.

[0071] (4) This overcomes the drawback of the octree structure where branches cannot be interconnected. For neighboring cells, hierarchical constraints can be further imposed on them. For example, the ratio of adjacent cells to each other is limited to 2:1, allowing for a smooth transition in size. Furthermore, constraints can be propagated recursively so that the entire grid satisfies the constraints. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 These are the basic attributes contained in each unit of the present invention.

[0073] Figure 2Schematic diagram of a voxel unit and eight vertices.

[0074] Figure 3 This is the design of the value scheme of Path_Code at different levels of the present invention.

[0075] Figure 4 This is the calculation process of Path_Code during the search process in an embodiment of the present invention.

[0076] Figure 5 This is a flow chart of a grid subdivision solution with hierarchical constraints in embodiment 3 of the present invention. DETAILED DESCRIPTION

[0077] The basic attributes of each unit in the embodiment of the present invention are as follows: Figure 1 Shown, including:

[0078] ●Maximum subdivision level maxlevel: defined by the user, the maxlevel value of all units is the same.

[0079] ●Unit size: the side length of the unit;

[0080] ●Unit level: All initial units have a level of 0, and the level of each sub-unit generated increases by 1 each time it is subdivided; the maximum level is maxlevel.

[0081] ●Unit space position Position: It is expressed by the coordinates of the specified vertex among the 8 vertices of the cube; Figure 2 The figure shows a voxel unit, the coordinate origin is O, and the coordinate of the specified vertex 1 is the position of the voxel unit.

[0082] ●Unit index key;

[0083] ● Initial unit unique identifier Base_ID: Assuming that the object to be analyzed is divided into x0×y0×z0 initial units, the value range of the initial unit Base_ID is 0 to (x0×y0×z0-1);

[0084] ● Spatial code Path_Code: Contains unit subdivision information and parent-child relationships, determined by the unit's level and spatial offset within the level;

[0085] ●Subdivision flag isSubdivided: indicates whether the unit is subdivided. 0 means it is not subdivided, that is, there is no subunit; 1 means it is subdivided.

[0086] The following describes in detail the hexahedral mesh adaptive subdivision method and the structure optimization method based on the subdivision method of the present invention with reference to several embodiments.

[0087] Example 1

[0088] This embodiment provides an octree-based hexahedral mesh adaptive subdivision and indexing method. The method includes the following steps:

[0089] (1) Set multiple initial cells. For the three-dimensional space of the object to be analyzed, perform initial cell division in the x, y, and z dimensions. Assume that the division is x0 × y0 × z0 initial cells. Assign each initial cell a unique identifier, Base_ID, based on its spatial position, and specify the maximum subdivision level, maxlevel.

[0090] The unique identifier of the initial unit, Base_ID, is the unit number of level 0. The subunits of each layer of the initial unit share the Base_ID of the initial unit, that is, in the same initial unit, the Base_ID of the parent and child units is the same. The Base_ID is determined as follows:

[0091] Base_ID=i+(x0×j)+(x0×y0×k) (1)

[0092] Here, i, j, and k are the ordinal numbers of the three dimensions of the initial unit, i∈[0, x0-1], j∈[0, y0-1], and k∈[0, z0-1]. This method of determining Base_ID can sort the initial units in the order of the x-, y-, and z-directions, making the initial unit numbering regular.

[0093] For the maximum subdivision level maxlevel, only one maxlevel needs to be specified for each initial unit. The maxlevels of different initial units can be different.

[0094] (2) Grid subdivision: Under the maximum subdivision level limit, an octree method is used to divide each initial unit into subdivision units.

[0095] In this step, meshing is performed for each initial cell. The meshing is refined layer by layer. Local areas (such as the engine's exterior) can be meshed at different levels as needed, allowing for different analysis accuracies. Some cells have subcells, while others do not. These are marked using the "isSubdivided" field.

[0096] (3) Determine the unit index key. For the initial unit and subdivided unit, determine the unit's spatial code Path_Code based on the unit's level and spatial offset in the level. Determine the unit's index key based on the unique identifier Base_ID of the initial unit to which the unit belongs, the spatial code Path_Code, and the maximum subdivided level maxlevel.

[0097] (3.1) Determine the spatial code Path_Code of the unit

[0098] like Figure 3 As shown in Figure 2, the design principles of spatial coding Path_Code are:

[0099] The initial unit is divided into 8 sub-units according to the way each unit is divided into the maxlevel layer, and the virtual units; spatially encode the virtual units of each layer;

[0100] For the virtual unit of level=0, the spatial code Path_Code=0;

[0101] For virtual units with level ≥ 1, the spatial coding Path_Code is At the beginning, the encoding is performed with an incremental step of 1; the order of the incremental encoding is based on the order of the parent node spatial encoding from small to large.

[0102] The virtual unit is not the actual initial unit and refinement unit. When determining the spatial coding of the initial unit and refinement unit, the spatial coding of the virtual unit at the position is used as the Path_Code of the initial unit / refinement unit according to the position of the initial unit and refinement unit.

[0103] The above is the design principle of the spatial coding Path_Code. According to the above principle, it can be found that the spatial coding Path_Code of the initial unit is 0. For the subdivided unit, according to the level of the subdivided unit and the spatial offset n of the unit in the level, the Path_Code of the subdivided unit can be determined as:

[0104]

[0105] Furthermore, according to the parent-child relationship of the above-mentioned spatial coding, when the Path_Code of a certain unit is determined, preferably, the spatial coding Patent_Path_Code of the parent unit and the spatial coding Child_Path_Code of the child unit can be obtained by simple calculation according to the Pat_Path_Code:

[0106] Patent_Path_Code=floor((Path_Code-1) / 8) (2)

[0107] Child_Path_Code=Path_Code*8+Δ (3)

[0108] Where Δ is the offset of the subunit among all subunits belonging to the same parent unit, and the value range of Δ is 1 to 8. For example Figure 3 For the second unit from the left of level 2, the delta is 2. floor() means round down.

[0109] In addition, the offset of the child unit relative to the parent unit is also implicit in the Path_Code. The three-digit binary code (000-111) and the offset are mapped one-to-one: (Path_Code-1)%8, which is the remainder of Path_Code minus one divided by eight. The corresponding relationship is shown in Table 1.

[0110] Table 1 Correspondence between Path_Code and spatial coding

[0111]

[0112] (3.2) Determine the unit index key

[0113] The calculation method of each unit index Key is:

[0114]

[0115] Base_ID is used to distinguish different initial units, and Provides a range of index selection space, including no index duplication even at the maximum subdivision level. Path_Code is used to distinguish different units within the same initial unit.

[0116] (4) Hash storage: Store the index key and the corresponding unit in the hash table.

[0117] (5) Unit information retrieval. Determine the unique identifier Base_ID of the initial unit to which the unit to be indexed belongs based on the spatial position Position of the unit to be indexed; determine the spatial code Path_Code based on the spatial position Position of the unit to be indexed, the level it is at, and the spatial offset; determine the index key of the unit to be indexed based on the unique identifier Base_ID, the spatial code Path_Code, and the maximum subdivision level maxlevel; obtain the unit information from the hash table based on the index key.

[0118] In this step, the unique identifier Base_ID of the initial unit is determined according to the spatial position Position of the unit to be indexed: Get the spatial position coordinates of the unit to be indexed Position = (x p ,y p ,z p ), the size of the current index unit 当前 ; The initial unit size of the current unit初始 And the size of the current unit to be indexed 当前 The conversion can be calculated using the following formula: size 初始 =size 当前 *(2 level ); Calculate the offsets i, j, k of the initial unit to which the indexed unit belongs in three dimensions, i = floor (x p / (size 当前 2 level )), j = floor (y p / (size 当前 2 level )), k = floor(z p / (size 当前 2 level )); floor() means rounding down. Substitute i, j, and k into formula (1) to obtain Base_ID.

[0119] In this section, see Figure 4 The process of determining the spatial code Path_Code according to the spatial position Position of the unit to be indexed specifically includes:

[0120] Step a1: Get the spatial position coordinates of the unit to be indexed Position = (x p ,y p ,z p ), the level of the unit to be indexed, and the size of the unit to be indexed;

[0121] Step a2: Initialize the value of Path_Code to Path_Code of level=0, Path_Code=0;

[0122] Step a3: Calculate the offset dx, dy, dz of the unit to be indexed relative to the initial unit in three dimensions; dx = x p %(size·2 level ),dy=y p %(size·2 level ),dz=z p %(size·2 level ), where % is the remainder operation;

[0123] Step a4: Set level variable l = 1;

[0124] Step a5: Convert the offset of the current level l into a three-bit binary code x bit ,y bit ,z bit :

[0125] xbit =floor(dx / (size·2 level-l ))%2

[0126] y bit =floor(dy / (size·2 level-l ))%2

[0127] z bit =floor(dz / (size·2 level-l ))%2

[0128] Step a6: Encode the three-digit binary code x bit ,y bit ,z bit Convert to decimal path code 10 :

[0129] code 10 =x bit ×4+x bit ×2+z bit +1

[0130] Here's the code 10 That is, the specific value of Δ in formula (3).

[0131] Step a7: Update Path_Code to: Path_Code×8+code 10 ;

[0132] Step a8: Determine whether the level variable l is equal to level. If so, output the current Path_Code; otherwise, continue the loop calculation, let l be incremented by 1, and then return to step a5.

[0133] Obtain Base_ID and Path_Code through the above steps. Given the maximum partition level maxlevel, substitute it into formula (4) to obtain the index Key.

[0134] It should be noted that although this embodiment separates grid subdivision, index key calculation, and hash storage into three steps, this is for ease of explanation and does not limit the process to completing subdivision first, then calculating the index, and finally storing the data. These three steps can be completed alternately. For example, after each subdivision level is completed, the index of the subdivision unit can be calculated and stored in the hash table.

[0135] Example 2

[0136] In this embodiment, based on the above-mentioned embodiment 1, in the process of retrieving unit information, neighboring units may also be retrieved.

[0137] In the search phase, the unit size of the unit to be indexed is size, the level it is at is level, and the unique identifier of the initial unit is Base_ID. Then the solution for retrieving neighboring units is:

[0138] Based on the spatial position Position of the cell to be indexed, obtain the spatial position Position' of the neighboring cell by adding or subtracting the size;

[0139] According to the spatial position Position' of the neighbor unit, the level of the unit to be indexed, and the size of the unit to be indexed, use Figure 4 The same process is performed, and steps a2-a8 are executed to determine the spatial code Path_Code' of the neighboring cell;

[0140] According to the Base_ID of the initial unit, the spatial code Path_Code' of the neighbor unit and the maximum subdivision level maxlevel, the index Key' of the neighbor unit is determined using formula (4);

[0141] If the hash table contains the index Key', the cell information of the neighboring cell is obtained from the hash table based on the index Key'; if the index Key' is not present, it means that the neighboring cell may not exist because the division level is different from that of the current cell. At this time, based on the spatial coding relationship between the parent and child cells (Formula (3)), the spatial coding Path_Code' of the parent cell of the neighboring cell is determined. Based on the Base_ID, Path_Code' and maxlevel, the index Key' of the parent cell is calculated again using Formula (4), and then the corresponding cell information is retrieved from the hash table again. If it is still not found, the spatial coding and index of the parent cell at a higher level are determined again until the cell information is retrieved from the hash table.

[0142] Example 3

[0143] In the first embodiment, when executing the unit subdivision of step (2), the smoothness of the neighboring units can be further checked for each subdivision layer. If the level of the neighboring unit differs from the level of the current unit by 1 or more, the transition is considered to be not smooth. For example, the level of the current unit is 1, and the level of the neighboring unit is 0. The difference between the two levels is only 1 level, and the side length meets the 2:1 rule. However, the current unit is about to be subdivided into 8 sub-units of level 2, so the neighboring unit of level 0 will not meet the constraint condition. The present invention performs hierarchical constraints on the neighboring units by subdividing them so that the ratio of adjacent grid sizes is 2:1; and diffuses the hierarchical constraints on the neighbors of the neighboring units.

[0144] After adding the hierarchical constraint rules, the grid subdivision process includes initial cell calculation and storage, one subdivision and attribute calculation and hash storage, hierarchical constraints of cell-level neighboring cells, another subdivision and attribute calculation and hash storage, hierarchical constraints of cell-level neighboring cells, and repeated iterative subdivision until the maximum subdivision level maxlevel is reached.

[0145] like Figure 5 As shown in FIG, the above iterative subdivision process is specifically as follows:

[0146] Step A: Import the topology optimization structure from the preliminary analysis. Initialize the design domain, i.e., initialize the mesh. Each initial mesh level is 0, and a Base_ID is assigned. The cell density (subdivision criterion), the size of each cell, and the position of each cell are obtained. The user defines the maximum subdivision level (maxlevel). The index key of the initial cell is calculated using formula (4). The initial cell information is stored in a hash table.

[0147] Step B: Traverse all initial cells, subdivide the initial grid according to the cell density, obtain sub-cells, calculate the key value of each sub-cell, and update the cell. Figure 1 , and store the new unit in the hash table.

[0148] Step C: Find the neighboring cells of the current cell according to the position information Position and obtain the level information of the neighboring cells. If the adjacent cell level constraints are not met, the neighboring cells are also subdivided and constraint diffusion is implemented recursively in sequence.

[0149] Step D: Determine whether the maximum subdivision level maxlevel has been reached. If not, return to step B and continue subdividing. If the maximum subdivision level has been reached, the division is completed.

[0150] In this embodiment, the specific implementation process for grid subdivision with hierarchical constraints is as follows:

[0151] Step 1: Initialize the grid. All cells are currently at level 0, i.e., level = 0. Check whether level is less than maxlevel; if not, terminate immediately; if so, retrieve the key values ​​of all cells from the hash table and proceed to step 2.

[0152] Step 2: Traverse all cells. Define the current cell as cell, and determine whether the current cell cell has been subdivided (judge whether isSubdivided = 1?) and whether it meets the subdivision conditions (judge whether it is at the model boundary?): If it has been subdivided isSubdivided = 1, search for the next cell; if it has not been subdivided isSubdivided = 0, but if it does not meet the subdivision conditions, search for the next cell; if it has not been subdivided isSubdivided = 0 and meets the subdivision conditions, go to Step 2.1.

[0153] Step 2.1: The current cell is cell, initialize newCell and newNode;

[0154] Step 2.2: Subdivide cell into 8 cells, and store the generated 8 new cells and 19 new nodes into newCell and newNode respectively;

[0155] Step 2.3: Judge whether to add hierarchical constraints, that is, the hierarchical difference between adjacent cells cannot be greater than 2. If not, the subdivision of cell ends, go to Step 3; if so, go to Step 2.4.

[0156] Step 2.4: Search and obtain neighbor cells Neighbors of the same level or lower level. Traverse all neighbor cells, and define the current neighbor cell as neighbor. Judge whether neighbor has not been subdivided and the cell level is less than cell (neighbor.isSubdivided = 0 and neighbor.level < cell.level): If not, traverse the next neighbor cell; if so, go back to Step 2.1 (recursion) to generate otherCell and otherNode, that is, the new cells and new nodes generated by the subdivision of the neighbor cell.

[0157] Step 2.5: Judge whether otherCell and otherNode are empty: If so, the subdivision of the current cell cell ends, go to Step 3; if not, add otherCell and otherNode to newCell and newNode respectively, the subdivision of the current cell cell ends, go to Step 3.

[0158] Step 3: Judge whether there are new cells newCell and new nodes: If so, store newCell and new nodes into the hash table, go to Step 4; if not, directly go to Step 4.

[0159] Step 4: Judge whether the traversal is over: If so, end; if not, return to Step 2.

[0160] Example 4

[0161] This embodiment applies the mesh refinement and indexing of the above embodiment to structure optimization.

[0162] Topology optimization (TO) is an algorithm that seeks the best material distribution under given constraints. Variable density methods, represented by the solid isotropic material penalty method (SIMP), have been widely studied and applied because of their small number of design variables, simple process, and applicability to design domains of arbitrary shapes. Finite element analysis, as a key step, uses numerical calculations to update various field variables such as sensitivity fields, density fields, and material parameter fields until the convergence criteria are reached and the optimal structure is obtained. The three-dimensional structural topology optimization problem faces problems such as high computational cost and insufficiently smooth boundaries. Most topology optimization methods still use fixed meshes to discretize the design domain. As the design domain is subdivided, the number of meshes increases exponentially, and the amount of computation increases sharply. This will obviously increase the computational burden or make it impossible to simulate high-resolution boundaries.

[0163] The adaptive meshing method proposed in this paper is applied to the topology optimization of three-dimensional structures. Local mesh refinement is performed on the structure's boundaries, while other areas are represented by a coarse mesh. This avoids the increased computational complexity caused by global mesh refinement while maintaining high resolution of the optimization results.

[0164] The implementation scheme of this embodiment is:

[0165] First, the structure to be optimized is used as the object to be analyzed. Steps (1) to (4) in the above scheme are used to subdivide the unit, determine the index key, and store it in the hash table. The structure to be optimized can be an engine structure, etc.

[0166] Then, based on the unit subdivision results of the object to be analyzed, finite element analysis is performed; during the analysis process, the unit information retrieval step of link (5) is used to obtain unit information.

[0167] Finally, based on the finite element analysis results, the structure to be optimized is optimized. The specific optimization method is not the focus of the present invention and will not be described here.

[0168] The above specific embodiments merely illustrate the design principles of the present invention. The shapes and names of the components described herein may vary and are not limiting. Therefore, those skilled in the art may modify or substitute equivalents for the technical solutions described in the above embodiments. Such modifications and substitutions, without departing from the inventive spirit and technical solutions of the present invention, shall fall within the scope of protection of the present invention.

Claims

1. An adaptive grid subdivision method based on octree and spatial coding, characterized in that: include: Perform initial unit division of the three-dimensional space of the object to be analyzed in the three dimensions of x, y, and z to obtain initial units in the shape of x0×y0×z0 cubes; Assign each initial unit a unique identifier Base_ID based on its spatial position and specify the maximum subdivision level maxlevel; Under the maximum subdivision level maxlevel limit, the octree method is used to divide the subdivision units for each initial unit; For the initial unit and the subdivision unit, the spatial code Path_Code of the unit is determined according to the level of the unit and the spatial offset in the level, and the index Key of the unit is determined according to the unique identifier Base_ID of the initial unit to which the unit belongs, the spatial code Path_Code and the maximum subdivision level maxlevel; Store the index key and the corresponding unit in the hash table; During retrieval, the unique identifier Base_ID of the initial unit to be indexed is determined according to the spatial position Position of the unit to be indexed; the spatial code Path_Code is determined according to the spatial position Position, the level and the spatial offset of the unit to be indexed; the index Key of the unit to be indexed is determined according to the unique identifier Base_ID, the spatial code Path_Code and the maximum subdivision level maxlevel; and the unit information is obtained from the hash table according to the index Key.

2. The method according to claim 1, wherein The method for determining the unique identifier Base_ID of the initial unit is as follows: The unique identifier of the initial unit, Base_ID, is the unit number of level 0. The Base_ID of the parent and child units is the same. The Base_ID is expressed as: Base_ID=i+(x0×j)+(x0×y0×k) Among them, i, j, and k are the serial numbers of the three dimensions of the initial unit, i∈[0, x0-1], j∈[0, y0-1], and k∈[0, z0-1].

3. The method according to claim 1, wherein The setting method of the spatial code Path_Code is: The initial unit is divided into 8 sub-units according to the way each unit is divided into the maxlevel layer, and the virtual units; spatially encode the virtual units of each layer; For the virtual unit of level=0, the spatial code Path_Code=0; For virtual units of level ≥ 1, spatial encoding Initially, the encoding is performed with an incrementing step of 1; The order of increasing coding is in the order of the parent node spatial coding from small to large; When determining the spatial coding of the initial unit and the subdivided unit, it is determined according to the virtual units corresponding to the initial unit and the subdivided unit.

4. The method according to claim 3, wherein In the subdivision unit division step, the spatial code Path_Code is determined as follows: The spatial code of the initial unit Path_Code=0; After a unit A is subdivided, the spatial coding of the subunits after subdivision is determined according to the spatial coding of unit A and the offset Δ of the subunit in all subunits of unit A: Child_Path_Code=Path_Code*8+Δ The value range of Δ is 1 to 8.

5. The method according to claim 3, wherein In the retrieval step, the method for determining the spatial code Path_Code is: Step a1: Get the spatial position coordinates of the unit to be indexed Position = (x p ,y p ,z p ), the level of the unit to be indexed, and the size of the unit to be indexed; Step a2: Initialize the value of Path_Code to Path_Code of level=0, Path_Code=0; Step a3: Calculate the offset dx, dy, dz of the unit to be indexed relative to the initial unit in three dimensions; dx = x p %(size·2 level ),dy=y p %(size·2 level ),dz=z p %(size·2 level ), where % is the remainder operation; Step a4: Set level variable l = 1; Step a5: Convert the offset of the current level l into a three-bit binary code x bit ,y bit ,z bit : x bit =floor(dx / (size·2 level-l ))%2 y bit =floor(dy / (size·2 level-l ))%2 z bit =floor(dz / (size·2 level-l ))%2 Among them, floor() means rounding down; Step a6: Encode the three-digit binary code x bit ,y bit ,z bit Convert to decimal path code 10 : code 10 =x bit ×4+x bit ×2+z bit +1 Step a7: Update Path_Code to: Path_Code×8+code 10 ; Step a8: Determine whether the level variable l is equal to level. If so, output the current Path_Code; otherwise, continue the loop calculation, let l be incremented by 1, and then return to step a5.

6. The method according to claim 5, wherein The retrieval step further includes retrieving neighboring cells of the cell to be indexed: The unit size of the unit to be indexed is size, the level it is at is level, and the unique identifier of the initial unit is Base_ID; Based on the spatial position Position of the cell to be indexed, obtain the spatial position Position' of the neighboring cell by adding or subtracting the size; According to the spatial position Position' of the neighboring cell, the level of the cell to be indexed, and the size of the cell to be indexed, the spatial code Path_Code' of the neighboring cell is determined using steps a2-a8; Determine the index Key' of the neighboring cell according to the Base_ID of the initial cell, the spatial code Path_Code' of the neighboring cell, and the set maximum subdivision level maxlevel; If there is an index Key' in the hash table, the cell information of the neighboring cell is obtained from the hash table according to the index Key'; if there is no index Key', the spatial code Path_Code' of the parent cell of the neighboring cell is determined according to the spatial coding relationship between the parent and child cells, and the index Key' of the parent cell is determined according to the Base_ID, Path_Code' and maxlevel, and the corresponding cell information is found from the hash table again; if it is still not found, the spatial code and index of the higher-level parent cell are determined again until the cell information is found from the hash table.

7. The method according to claim 1, wherein The index key is determined as follows:

8. The method according to claim 1, wherein In the subdivision unit division step, the smoothness of the neighboring units is further checked. If the level of the neighboring unit differs from the level of the current division unit by 1 or more levels, the transition is considered to be unsmooth. The neighboring units are subdivided into grids to perform hierarchical constraints so that the ratio of adjacent grid sizes is 2:1; and constraint diffusion is achieved by performing hierarchical constraints on the neighbors of the neighboring units.

9. The method according to claim 1, wherein The unit information stored in the hash table includes: ●Maximum subdivision level maxlevel: defined by the user, all units have the same maxlevel value; ●Unit size; ●Unit level: All initial units have a level of 0, and the level of each sub-unit generated increases by 1; ●Unit space position Position: expressed by the coordinates of the specified vertex among the 8 vertices of the cube; ●Index Key; ●The unique identifier of the initial unit, Base_ID; ●Spatial coding Path_Code; ●Subdivision flag isSubdivided: 0 / 1 is used to indicate whether the unit is subdivided.

10. A structural optimization method based on adaptive grid subdivision, characterized in that: include: Taking the structure to be optimized as the object to be analyzed, the adaptive grid subdivision method based on octree and spatial coding according to any one of claims 1 to 9 is used to perform unit subdivision; Finite element analysis is performed based on the unit subdivision results of the object to be analyzed. During the analysis, the unit information is obtained by using the retrieval step of the adaptive mesh subdivision method based on octree and spatial encoding. Based on the finite element analysis results, the structure to be optimized is optimized.