A Hilbert encoding method and device for three-dimensional distributed Cartesian grid

By define the storage structure of the basic state linker and the Hilbert encoder in the three -dimensional distributed Descartes mesh system, construct the hierarchical transformation group model of the octopus structure, and instantize the Hilbert encoder on each processor, solve the solution The problem of low efficiency of the Hilbert encoding algorithm has realized the fast and automated Hilbert encoding to support high -performance parallel computing and dynamic load balance.

CN119166158BActive Publication Date: 2025-01-24CALCULATION AERODYNAMICS INST CHINA AERODYNAMICS RES & DEV CENT
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411648485.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-01-24
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

The existing Hilbert fill curve theory is incomplete, resulting in the low automation level and execution efficiency of most Hilbert encoding algorithms, which fail to replace the relatively simple Morton encoding in engineering applications, and it is difficult to fully reflect its own geometric advantages.

Method used

A Hilbert coding method and device for a three-dimensional distributed Cartesian grid is proposed. By defining the storage structure of the basic state linker and Hilbert encoder, the memory manager is called to construct a hierarchical transformation group model of the Cartesian grid octree structure. The Hilbert encoder is instantiated synchronously on each processor, and the global reduction operation is performed through the message passing interface to calculate the lower bound of the coordinate components of the three-dimensional Cartesian grid area in parallel, and generates the Cartesian grid octree node Hilbert coding.

Benefits of technology

It achieves rapid automation of Hilbert coding for large-scale distributed Cartesian grid systems, improves coding efficiency, supports the dynamic load balancing process in high-performance parallel computing, and significantly improves the performance and speed of flow field numerical simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166158B_ABST
    Figure CN119166158B_ABST
Patent Text Reader

Abstract

The present application discloses a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid, which relates to the fields of computer science and information processing technology, defines the storage structure of a basic state linker and a Hilbert encoder, calls a memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure, calls the memory manager in the initialization phase, instantiates the Hilbert encoder synchronously on each processor, performs global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in three-dimensional space, generates the Hilbert encoding of the Cartesian grid octree node on each processor using the Hilbert encoder, destroys the Hilbert encoder and releases the storage space of the Hilbert encoder for each processor. For the Cartesian grid, the Hilbert code calculation of the octree node center is realized in each parallel adaptive process, thereby realizing a dynamic load balancing process, and providing support for high-performance numerical simulation of flow fields on large Cartesian grids.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer science and information processing technology, and in particular to a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid. Background Art

[0002] In the field of computational fluid dynamics, adaptive Cartesian grids can obtain more accurate flow field results or capture fine flow field structures such as shock waves, shear layers or vortices by dynamically adjusting the local unit scale with the least amount of grids. Before the calculation begins, the spatial distribution of the grid blocks can be geometrically adapted, and during the calculation process, the flow field solution can also be adapted according to the characteristics of the flow field.

[0003] In the distributed memory management mode, the octree nodes corresponding to the three-dimensional Cartesian grid need to generate space-filling curves based on binary coding to achieve dynamic balance of computing load. Among the many space-filling curves, the Hilbert curve has good clustering properties, which effectively reduces the spatial jumps when the computing unit is traversed on the local processor and improves the convergence quality of the overall flow field. Therefore, it has received increasing attention in the high-performance computing of large-scale Cartesian grid flow fields.

[0004] The Hilbert coding efficiency of computing units is one of the key factors affecting load distribution and memory access in distributed adaptive Cartesian grid systems. However, due to the incompleteness of the existing Hilbert filling curve theory, the automation level and execution efficiency of most Hilbert coding algorithms are poor. In many engineering applications, they have not been able to replace the relatively simple Morton coding, and their own geometric advantages are difficult to fully reflect. Therefore, how to construct a fast and automated coding model for Hilbert space filling curves is one of the problems that need to be solved in the development of high-performance flow field simulators for large-scale Cartesian grids. Summary of the invention

[0005] The purpose of this application is to overcome the existing technical defects and provide a Hilbert coding method and device for a three-dimensional distributed Cartesian grid, which can accurately and quickly implement Hilbert coding of a large distributed Cartesian grid system, thereby providing effective technical support for the dynamic load balancing process required for high-performance parallel computing.

[0006] The purpose of this application is achieved through the following technical solutions:

[0007] In a first aspect, the present application proposes a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid, the method comprising:

[0008] Step S1, defining the storage structure of the basic state linker and the Hilbert encoder;

[0009] Step S2: Based on the storage structure, call the memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure;

[0010] Step S3, calling the memory manager in the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure, and synchronously instantiating the Hilbert encoder on each processor;

[0011] Step S4, performing global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in the three-dimensional space, and generating the Hilbert code of the Cartesian grid octree node on each processor using a Hilbert encoder;

[0012] Step S5: After the adaptive numerical simulation process of the Cartesian grid solver is completed, the Hilbert encoder is destroyed and the storage space of the Hilbert encoder is released for each processor.

[0013] In a possible implementation, the abstract data type of the basic status linker is named MYBasicStatus, including a signed integer variable index, an unsigned integer array series, and a MYBasicStatus pointer type array child;

[0014] The signed integer variable index is used to store the number of the current basic state linker in the finite sequence of all basic state linkers;

[0015] Unsigned integer array series is used to store the Hilbert decimal code sequence in the current state;

[0016] MYBasicStatus pointer type array child, used to store the first address of the child object of the current basic status linker;

[0017] In the constructor of MYBasicStatus, the unsigned integer array series and the MYBasicStatus pointer type array child are dynamically generated through the memory manager and each element of the MYBasicStatus pointer type array child is a null address value NULL;

[0018] In the destructor of MYBasicStatus, the storage space of the unsigned integer array series and the MYBasicStatus pointer type array child is released through the memory manager.

[0019] In a possible implementation, the abstract data type of the Hilbert encoder is named MYCodeGenerator, and includes an array hilbertToMortonMapping, an array mortonToHilbertMapping, and an array rentToChildMapping, wherein the array hilbertToMortonMapping is used to record the mapping relationship from Hilbert decimal code to Morton decimal code in the finite sequence of all basic state linkers, the array mortonToHilbertMapping is used to record the mapping relationship from Morton decimal code to Hilbert decimal code in the finite sequence of all basic state linkers, and the array parentToChildMapping is used to record the state number mapping relationship from the parent node to its child node in the finite sequence of all basic state linkers;

[0020] In the constructor of MYCodeGenerator, the first addresses of the arrays hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping are all set to NULL;

[0021] In the destructor of MYCodeGenerator, the storage space of the array hilbertToMortonMapping, the array mortonToHilbertMapping, and the array parentToChildMapping are all released through the memory manager.

[0022] In a possible implementation, step S2, the step of calling the dynamic memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure based on the storage structure, includes:

[0023] Step 21: Call the C++ Standard Template Library <vector>The header file declares the vector container group, which stores the first address of each element of the finite sequence of all basic state linkers;

[0024] Step 22, calling the constructor of MYBasicStatus to instantiate the initial basic status linker, setting the transformation of the internal member representation of the initial basic status linker to the identity transformation, and storing the first address into the vector container group through the push_back operation of the vector container;

[0025] Step 23, construct a Boolean variable indicator logic and set the initial value of the Boolean variable indicator logic to true, and construct a while type loop process to generate the remaining basic state linkers;

[0026] Step 24, record the final length of the vector container group through the signed integer register variable msize, and allocate dynamic memory for the arrays hilbertToMortonMapping, mortonToHilbertMapping, and rentToChildMapping of the Hilbert encoder;

[0027] Step 25, traverse each element in the vector container group and set the value of the internal member variable of each element;

[0028] Step 26, updating the internal member array parentToChildMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group, and the inner loop sequentially traverses the child objects of each element, and uses the internal member variables of the child objects to sequentially update the element values ​​of parentToChildMapping;

[0029] Step 27, updating the internal member array hilbertToMortonMapping and array mortonToHilbertMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group and extracts the first address of the internal member array of each element, and the inner loop sequentially traverses the Hilbert decimal code value stored in each element, and maps the Hilbert decimal code value to the corresponding Morton decimal code in combination with the array mcode;

[0030] Step 28: traverse the vector container group, release the dynamic memory occupied by each basic state linker in turn, and complete the construction of the hierarchical transformation group model of the Cartesian grid octree structure.

[0031] In a possible implementation manner, the steps of the while-type loop process in step 23 include:

[0032] Step 231, declare signed integer register variables p and q and set their initial values ​​to -1;

[0033] Step 232, traverse the first address of each basic state linker in the vector container group, if there is a null address value NULL in the child address value in the first address, use the signed integer register variable p to record the number of the current basic state linker in the vector container group, and use the signed integer register variable q to record the number of the first child address pointing to the null address value NULL in the current basic state linker;

[0034] Step 233, check the value of the signed integer register variable q, if the initial value -1 remains unchanged, then jump out of the while loop immediately, otherwise execute steps 234 to 236;

[0035] Step 234, in the basic state linker located by the signed integer register variable p, traverse the elements in the member variable, and map each element into a Morton decimal code sequence in sequence in combination with the array mcode, and store the result in the unsigned integer register array source;

[0036] Step 235, declare an unsigned integer register array stream, and call the C++ Standard Template Library <bitset>The header file declares a bit operation container target. In the basic state linker located by the register variable p, the child pointer located by the register variable q is classified and processed, and the Morton decimal code m is mapped to stream[j] in combination with the data array hcode;

[0037] Step 236, traverse the current dynamic vector container group, compare the consistency of the internal member series of each basic state linker group[i] in the vector container group with the value stored in the unsigned integer register array stream, if the consistency is established during the traversal process, point the child pointer located by the register variable q to the first address of the current basic state linker group[i] and jump out of the traversal process, if the consistency is not established during the entire traversal process, use the memory manager to dynamically generate a new basic state linker object, copy the value of the unsigned integer register array stream to the internal member series of status, store the first address of status in group through the push_back operation of the vector container, and point the child pointer located by the register variable q to the first address of status.

[0038] In a possible implementation, the steps of classifying the child pointer located by the register variable q and mapping the Morton decimal code m to stream[j] in combination with the data array hcode include:

[0039] When the value of q is 0 or 4, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target, convert the binary sequence of target into Morton decimal code m, and finally map m to stream[j] in combination with the array hcode;

[0040] When the value of q is 3 or 7, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with the array hcode;

[0041] When the value of q is 1, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode;

[0042] When the value of q is 6, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode;

[0043] When the value of q is 2 or 5, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode.

[0044] In a possible implementation, step S4, performing a global reduction operation through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in the three-dimensional space, and using a Hilbert encoder to generate the Hilbert code of the Cartesian grid octree node on each processor, includes:

[0045] Step S41, declare three unsigned integer register variables i, j, k, which are used to store the Gauss coordinates of the center of the octree node octalNode;

[0046] Step S42: Call the C++ Standard Template Library <bitset>The header file declares three bit operation containers xg, yg, and zg, and copies the values ​​of i, j, and k to the bit operation containers xg, yg, and zg in sequence;

[0047] Step S43, declare an unsigned long integer register variable code and an unsigned integer register variable s to store the basic state number, and the unsigned long integer register variable code is used to store the Hilbert code of the octalNode center;

[0048] Step S44, sequentially combine the binary bit values ​​of the current xg, yg, zg to form a local Morton decimal code m, calculate the local Hilbert decimal code h according to the member array mortonToHilbertMapping of the Hilbert encoder, update the Hilbert code of the octalNode center, update the register variable s according to the member array parentToChildMapping of the Hilbert encoder, and then proceed to the next traversal process. When the traversal process is completed, the value of the register variable code is used as the Hilbert decimal code value of the octalNode center.

[0049] In one possible implementation, an unsigned integer register variable , unsigned integer register variable , unsigned integer register variable ,in( , , ) is the lower bound of the physical coordinates of the octalNode in the x, y, and z coordinate axes. ( , , ) is the physical coordinate upper bound of the octree node octalNode in the x, y, and z coordinate axis directions. is the C++ floor function, ( , , ) is the infimum of the x, y, and z coordinate components of the Cartesian grid region in three-dimensional space.

[0050] In a second aspect, the present application proposes a Hilbert encoding device for a three-dimensional distributed Cartesian grid, the device comprising:

[0051] Definition module, used to define the storage structure of the basic state linker and Hilbert encoder;

[0052] A calling module, used for calling a memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure based on a storage structure;

[0053] An instantiation module is used to call the memory manager during the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure and to synchronously instantiate the Hilbert encoder on each processor;

[0054] The encoding module is used to perform global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in the three-dimensional space, and generate the Hilbert code of the Cartesian grid octree node on each processor using a Hilbert encoder;

[0055] The release module is used to destroy the Hilbert encoder and release the storage space of the Hilbert encoder for each processor after the adaptive numerical simulation process of the Cartesian grid solver is completed.

[0056] The above main scheme of the present application and its further options can be freely combined to form multiple schemes, all of which are schemes that can be adopted and claimed for protection in the present application; and in the present application, (non-conflicting options) options and other options can also be freely combined. After understanding the scheme of the present application, those skilled in the art can understand that there are many combinations based on the existing technology and common knowledge, all of which are technical schemes to be protected by the present application, and they are not exhaustively listed here.

[0057] The present application discloses a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid, which relates to the fields of computer science and information processing technology, defines the storage structure of a basic state linker and a Hilbert encoder, calls a memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure, calls the memory manager in the initialization phase, instantiates the Hilbert encoder synchronously on each processor, performs global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in three-dimensional space, generates the Hilbert encoding of the Cartesian grid octree node on each processor using the Hilbert encoder, and finally destroys the Hilbert encoder and releases the storage space of the Hilbert encoder for each processor. For the Cartesian grid, the Hilbert code calculation of the octree node center can be realized in each step of the parallel adaptive process, thereby realizing a dynamic load balancing process, and providing support for high-performance flow field numerical simulation on large Cartesian grids. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 A flow chart of a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid proposed in an embodiment of the present application is shown.

[0060] Figure 2 A schematic diagram of a basic state linker proposed in an embodiment of the present application is shown.

[0061] Figure 3 A schematic diagram of the Hilbert encoder proposed in an embodiment of the present application is shown.

[0062] Figure 4 A schematic diagram showing the relative relationship between the initial local Morton code and the local Hilbert code is shown.

[0063] FIG. 5 is a grid decomposition diagram when 12 processors are used for numerical simulation in an embodiment of the present invention. DETAILED DESCRIPTION

[0064] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.

[0065] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.

[0066] In the prior art, the Hilbert coding efficiency of computing units is one of the key factors affecting load distribution and memory access in distributed adaptive Cartesian grid systems. However, because the Hilbert filling curve theory is not yet complete, the automation level and execution efficiency of most Hilbert coding algorithms are poor. In many engineering applications, they have not been able to replace the relatively simple Morton coding, and their own geometric advantages are difficult to fully reflect. Therefore, constructing a fast and automated coding model for the Hilbert space filling curve is one of the problems that need to be solved in the development of high-performance flow field simulators for large-scale Cartesian grids.

[0067] Therefore, in order to solve the above technical problems, the embodiment of the present application proposes a Hilbert coding method and device for a three-dimensional distributed Cartesian grid, which can improve the efficiency of large-scale data set processing, especially when performing high-performance flow field numerical simulation. It is mainly divided into two points: the construction of a hierarchical transformation group model and the parallel calculation of Hilbert coding, wherein the construction of the hierarchical transformation group model is used to automatically construct a mapping sequence without manual intervention in a large number of parameter settings. By defining a basic state linker data type and using loop logic, the finite mapping sequence required for Hilbert coding is automatically generated. In the parallel calculation of Hilbert coding, in order to speed up the coding process, efficient bit operation techniques are combined to perform fast coding on the octree nodes of each level.

[0068] The Hilbert coding method and device for a three-dimensional distributed Cartesian grid proposed in the embodiment of the present application significantly improve the coding efficiency, especially when processing large-scale data sets (such as tens of millions and above). For large-scale Cartesian grid applications, such as fluid mechanics simulations, the advantages of this coding method are particularly prominent, so that in each round of parallel adaptive processing, the Hilbert code calculation of the octree node center can be completed quickly, thereby achieving dynamic load balancing. Therefore, computing resources can be allocated more efficiently, ensuring that all computing units work under high load, reducing idle time, and enhancing the performance and speed of the simulation as a whole, which will be described in detail below.

[0069] Please refer to Figure 1 , Figure 1 A flow chart of a Hilbert encoding method and device for a three-dimensional distributed Cartesian grid proposed in an embodiment of the present application is shown. The method runs in a standard C++ programming environment and includes:

[0070] Step S1, defining the storage structure of the basic state linker and the Hilbert encoder.

[0071] The storage structure of the basic state linker is a data structure used to store and manage the state transition information required in the process of building the Hilbert code, while the storage structure of the Hilbert encoder is designed to perform the actual encoding process.

[0072] The abstract data type of the basic status linker is named MYBasicStatus, which includes a signed integer variable index, an unsigned integer array series, and a MYBasicStatus pointer type array child;

[0073] The signed integer variable index is used to store the number of the current basic state linker in the finite sequence of all basic state linkers;

[0074] Unsigned integer array series is used to store the Hilbert decimal code sequence in the current state;

[0075] MYBasicStatus pointer type array child, used to store the first address of the child object of the current basic status linker;

[0076] In the constructor of MYBasicStatus, the unsigned integer array series and the MYBasicStatus pointer type array child are dynamically generated through the memory manager and each element of the MYBasicStatus pointer type array child is a null address value NULL;

[0077] In the destructor of MYBasicStatus, the storage space of the unsigned integer array series and the MYBasicStatus pointer type array child is released through the memory manager.

[0078] Figure 2 A schematic diagram of the basic state linker proposed in an embodiment of the present application is shown, wherein three access interfaces A, B, and C point to the global number, Hilbert decimal code sequence, and child object first address of the basic state linker, respectively. The basic state linker MYBasicStatus contains a global number, a Hilbert decimal code sequence, and a child object first address array, and the elements in the child object first address array are NULL, indicating a null address value. The signed integer variable index is used to uniquely mark the position of each MYBasicStatus instance in all basic state linker sequences. The unsigned integer array series with a length of 8 is used to save the Hilbert decimal code sequence in the current state. The array length is 8 because the Hilbert curve will generate 8 child nodes in each dimension division, corresponding to the structure of the octree.

[0079] The 8-length MYBasicStatus pointer type array child stores the addresses of the 8 child state linkers derived from the current state linker. Each "child" represents the next level or stage in the state space. When initialized, these pointers are set to NULL to indicate that they do not yet point to a specific sub-state, which will be gradually filled in when the Hilbert code is dynamically generated.

[0080] When creating a MYBasicStatus instance, the constructor not only allocates dynamic memory for the series and child arrays, but also ensures the effective allocation of resources through the memory manager. Memory will be adapted and allocated at runtime according to actual needs. In the destructor, when a MYBasicStatus instance is no longer needed, the destructor is automatically triggered and is responsible for releasing the memory space previously allocated to the series and child arrays through the memory manager to prevent memory leaks.

[0081] The abstract data type of the Hilbert encoder is named MYCodeGenerator, which includes the array hilbertToMortonMapping, the array mortonToHilbertMapping and the array rentToChildMapping. The array hilbertToMortonMapping is used to record the mapping relationship from Hilbert decimal code to Morton decimal code in the finite sequence of all basic state linkers. The array mortonToHilbertMapping is used to record the mapping relationship from Morton decimal code to Hilbert decimal code in the finite sequence of all basic state linkers. The array parentToChildMapping is used to record the mapping relationship from the parent node to its child node in the finite sequence of all basic state linkers.

[0082] In the constructor of MYCodeGenerator, the first addresses of the arrays hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping are all set to NULL;

[0083] In the destructor of MYCodeGenerator, the storage space of the array hilbertToMortonMapping, the array mortonToHilbertMapping, and the array parentToChildMapping are all released through the memory manager.

[0084] Figure 3 A schematic diagram of the Hilbert encoder proposed in an embodiment of the present application is shown. MYCodeGenerator, as an abstract data type, includes hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping, wherein the hilbertToMortonMapping array stores the mapping relationship from Hilbert decimal code to Morton decimal code. The mortonToHilbertMapping array is used to record the mapping from Morton decimal code to Hilbert decimal code, and provides a reverse search capability, so that both the conversion from Hilbert to Morton and from Morton to Hilbert can be performed efficiently. The parentToChildMapping array records the number mapping between each parent state and its direct child state in the sequence of all basic state linkers.

[0085] When the constructor instantiates MYCodeGenerator, the first addresses of the three arrays are initialized to NULL, and memory is dynamically allocated according to actual needs in subsequent operations. When the MYCodeGenerator instance is no longer used, its destructor is responsible for releasing the memory space occupied by the above three arrays. The release operation is performed through the memory manager to ensure proper management of resources and avoid memory leaks.

[0086] Step S2: Based on the storage structure, call the memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure.

[0087] Step S2 constructs a Cartesian grid octree structured hierarchical transformation group model by calling a dynamic memory manager. The hierarchical transformation group model is constructed by a dynamic memory manager, and memory allocation is performed on demand, so that memory resources are managed flexibly and efficiently.

[0088] Figure 4 The diagram shows the relative relationship between the initial local Morton code and the local Hilbert code. The arrows indicate the mapping relationship between the Morton decimal code and the Hilbert decimal code. For example, 1 in the Morton decimal code is mapped to 0 in the Hilbert decimal code, 2 in the Morton decimal code is mapped to 1 in the Hilbert decimal code, and so on. The mapping relationship between the local Morton decimal code and the local Hilbert decimal code is defined in the local Gauss coordinate system to meet the data processing requirements of a specific area or subspace. It uses the hcode and mcode arrays, and records the mapping relationship between local codes through two unsigned integer arrays of length 8. The hcode array stores the mapping from the local Morton decimal code to the local Hilbert decimal code, while the mcode array stores the mapping from the local Hilbert decimal code to the local Morton decimal code. The two arrays are inverse operations to each other, ensuring that the two encoding methods can be freely converted.

[0089] Step S2 includes:

[0090] Step 21: Call the C++ Standard Template Library <vector>The header file declares the vector container group, which stores the first address of each element of the finite sequence of all basic state linkers.

[0091] Step 21 introduces the C++ Standard Template Library <vector>The header file declares a vector container named group. This container is used to store pointers to "basic state linker" objects and is initialized to empty.

[0092] Step 22, call the constructor of MYBasicStatus to instantiate the initial basic status linker, set the transformation of the internal member representation of the initial basic status linker to the identity transformation, and store the first address into the vector container group through the push_back operation of the vector container.

[0093] Create the initial basic state linker by calling the constructor of the MYBasicStatus class to instantiate the object and set its internal representation transform to the identity transform, indicating that there is no change in the initial state. Then add the address of this instance to the group vector declared earlier.

[0094] Step 23: construct a Boolean variable indicator logic and set the initial value of the Boolean variable indicator logic to true, and construct a while loop process to generate the remaining basic state linkers.

[0095] Step 23 introduces a Boolean variable logic, which is initially set to true and controls a while loop. The purpose of this loop is to generate all other basic state linkers except the initial basic state linker, and the loop is executed continuously.

[0096] The steps of the while loop process in step 23 include:

[0097] Step 231, declare signed integer register variables p and q and set their initial values ​​to -1.

[0098] Two signed integer register variables p and q are introduced, whose scope covers the entire while loop and are initialized to -1. p is used to record the position of the basic state linker containing an empty substate link (i.e. NULL) in the group, and q is used to record the index of the first empty substate found in the corresponding basic state linker.

[0099] Step 232, traverse the first address of each basic state linker in the vector container group. If there is a null address value NULL in the child address value in the first address, use the signed integer register variable p to record the number of the current basic state linker in the vector container group and use the signed integer register variable q to record the number of the first child address pointing to the null address value NULL in the current basic state linker.

[0100] Traverse the first address of each basic state linker in the vector container group, check whether the child address of each basic state linker is complete, and once a NULL value is found, use p and q to record the location information of the missing state.

[0101] Step 233, check the value of the signed integer register variable q. If the initial value -1 remains unchanged, immediately exit the while loop; otherwise, execute steps 234 to 236.

[0102] Check the value of q. If it is still -1, it means that all the child links of the basic state linker are complete, so the loop ends. Otherwise, execute the subsequent steps to fill in the missing links.

[0103] Step 234, in the basic state linker located by the signed integer register variable p, traverse the elements in the member variable, and map each element into a Morton decimal code sequence in sequence in combination with the array mcode, and store the result in the unsigned integer register array source.

[0104] For the basic state linker marked with p, combined with the array mcode, the Hilbert code in its series member variable is mapped to the Morton code and stored in the register array source.

[0105] Step 235, declare an unsigned integer register array stream, and call the C++ Standard Template Library <bitset>The header file declares a bit operation container target. In the basic state linker located by the register variable p, the child pointer located by the register variable q is classified and processed, and the Morton decimal code m is mapped to stream[j] in combination with the data array hcode.

[0106] The source array is mapped to the new array stream after specific operations are performed according to the value of q. Different values ​​of q determine different bit operation logics, such as bit swapping and inversion, which essentially adjusts the layout of the encoding to conform to specific generation rules or patterns so that a new state linker can be correctly matched or generated.

[0107] The steps of classifying the child pointers located by the register variable q and mapping the Morton decimal code m to stream[j] in combination with the data array hcode include:

[0108] When the value of q is 0 or 4, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target, convert the binary sequence of target into Morton decimal code m, and finally map m to stream[j] in combination with the array hcode;

[0109] When the value of q is 3 or 7, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with the array hcode;

[0110] When the value of q is 1, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode;

[0111] When the value of q is 6, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode;

[0112] When the value of q is 2 or 5, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode.

[0113] Step 236, traverse the current dynamic vector container group, compare the consistency of the internal member series of each basic state linker group[i] in the vector container group with the value stored in the unsigned integer register array stream, if the consistency is established during the traversal process, point the child pointer located by the register variable q to the first address of the current basic state linker group[i] and jump out of the traversal process, if the consistency is not established during the entire traversal process, use the memory manager to dynamically generate a new basic state linker object, copy the value of the unsigned integer register array stream to the internal member series of status, store the first address of status in group through the push_back operation of the vector container, and point the child pointer located by the register variable q to the first address of status.

[0114] Traverse the current dynamic vector container group, and compare the consistency of the internal member series of each basic state linker group[i] (the subscript i ranges from 0 to nsize-1, where nsize is the length of the vector container group) in the group with the value stored in the register array stream. If the consistency is established during the traversal process, the child pointer located by the register variable q is pointed to the first address of the current basic state linker group[i] and the traversal process is exited. If the consistency is not established during the entire traversal process, a new basic state linker object status is first dynamically generated using the memory manager, and then the value of the register array stream is copied to the internal member series of status, and then the first address of status is stored in group through the push_back operation of the vector container, and finally the child pointer located by the register variable q is pointed to the first address of status. That is, the state represented by stream is compared with all existing states in group. If a match is found, the matching state is used to complete the previously found empty substate. If there is no match, a new basic state linker is created, initialized with the value of stream, added to group, and used to complete the missing substate.

[0115] Step 24: Record the final length of the vector container group through the signed integer register variable msize, and allocate dynamic memory for the arrays hilbertToMortonMapping, mortonToHilbertMapping, and rentToChildMapping of the Hilbert encoder.

[0116] Step 24 determines the memory space required for three important arrays inside the Hilbert encoder by calculating the size of the group vector msize. These three arrays are hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping. Since each basic state linker may have up to 8 sub-states, multiplying the total number of states (msize) gives the maximum number of array elements required, so each is pre-allocated with dynamic memory of length 8*msize.

[0117] Step 25: Traverse each element in the vector container group and set the value of the internal member variable of each element.

[0118] Traverse each element group[i] of the vector container group (the subscript i ranges from 0 to msize-1), and set the value of the internal member variable index of group[i] to i.

[0119] Step 26, updating the internal member array parentToChildMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group, and the inner loop sequentially traverses the child objects of each element, and uses the internal member variables of the child objects to sequentially update the element values ​​of parentToChildMapping;

[0120] The internal member array parentToChildMapping of the Hilbert encoder is updated through a double loop process. The outer loop iterates through each element group[i] of the vector container group in turn (the range of subscript i is 0 to msize-1), and the inner loop iterates through the 8 child objects of group[i] in turn, and uses the internal member variables index of these child objects to update the element values ​​of parentToChildMapping in turn.

[0121] Step 27, update the internal member array hilbertToMortonMapping and array mortonToHilbertMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group and extracts the first address of the internal member array of each element, and the inner loop sequentially traverses the Hilbert decimal code value stored in each element, and maps the Hilbert decimal code value to the corresponding Morton decimal code in combination with the array mcode.

[0122] The internal member arrays hilbertToMortonMapping and mortonToHilbertMapping of the Hilbert encoder are updated through a double loop process. The outer loop sequentially traverses each element group[i] of the vector container group (the subscript i ranges from 0 to msize-1) and extracts the first address series of the internal member array of group[i]. The inner loop sequentially traverses the Hilbert decimal code value h stored in each element of series, and maps h to the corresponding Morton decimal code m in combination with the array mcode. The update process can be expressed as mortonToHilbertMapping [8*i+m]=h and hilbertToMortonMapping [8*i+h]=m.

[0123] Step 28: traverse the vector container group, release the dynamic memory occupied by each basic state linker in turn, and complete the construction of the hierarchical transformation group model of the Cartesian grid octree structure.

[0124] Traverse the vector container group and release the dynamic memory occupied by each basic state linker in turn. The basic state linker, a custom data type, is used to calculate the element values ​​of the three general arrays hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping in the Hilbert encoder.

[0125] Step S2 realizes efficient construction of the core data structure of the Hilbert encoder by using dynamic memory management, custom data structure and efficient loop traversal strategy. After step S2 is completed, the dynamic memory occupied by the basic state linker needs to be released in time.

[0126] Step S3: In the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure, the memory manager is called to synchronously instantiate the Hilbert encoder on each processor.

[0127] In the distributed memory management mode, the system's memory is distributed across multiple processor nodes, each node has its own private memory space, and data and computing tasks can be processed in parallel. Since the storage values ​​of the encoder's internal member arrays are constant, once calculated, they can be reused to avoid the overhead of recalculation each time they are used, so the Hilbert encoder needs to be instantiated.

[0128] In order to ensure the consistency of encoder instances on all processors, it is necessary to coordinate through the memory manager and use the distributed memory management mechanism to allocate the necessary memory space on each processor to store the Hilbert encoder object. In addition, broadcast or similar communication protocols can be used to ensure that the instantiation operations on all processors occur simultaneously, or at least ensure that all instances have been initialized before any operations that depend on this encoder are performed.

[0129] Step S4, performing global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in the three-dimensional space, and using a Hilbert encoder to generate the Hilbert code of the Cartesian grid octree node on each processor.

[0130] The Hilbert code of the Cartesian grid octree node is generated in parallel on each processor. Through the MPI global reduction function interface, the infimum of the x, y, and z coordinate components of the Cartesian grid region in three-dimensional space is calculated in parallel ( , , ). According to C++ programming practices, the depth of the octree root node is set to 0, and the depth of the traversal downwards increases by 1. On each processor, given an octree node octalNode, let its depth in the octree be level.

[0131] Step S4 includes:

[0132] Step S41, declare three unsigned integer register variables i, j, k, which are used to store the Gauss coordinates of the center of the octal node octalNode (the center of the octalNode is the geometric center of the cuboid corresponding to the octal node octalNode in the three-dimensional space), where , , , ( , , ) is the lower bound of the physical coordinates of the octalNode in the x, y, and z coordinate axes. ( , , ) is the physical coordinate upper bound of the octree node octalNode in the x, y, and z coordinate axis directions. is the C++ floor function, ( , , ) is the infimum of the x, y, z coordinate components of the Cartesian grid region in three-dimensional space;

[0133] The Gauss coordinates calculated by the physical coordinate boundary values ​​are normalized, fall within the interval [0, 1], and are rounded down to represent the relative position of the node in three dimensions. Step S41 is to convert the physical coordinates of the node into standardized Gauss coordinates to facilitate subsequent Hilbert coding.

[0134] Step S42: Call the C++ Standard Template Library <bitset>The header file declares three bit operation containers xg, yg, and zg, and copies the values ​​of i, j, and k bit by bit into the bit operation containers xg, yg, and zg in sequence.

[0135] Create three variables xg, yg, zg respectively, convert the calculated Gauss coordinates i, j, k into binary and store them in the container.

[0136] Step S43, declare an unsigned long integer register variable code and an unsigned integer register variable s to store the basic state number, and the unsigned long integer register variable code is used to store the Hilbert code of the octalNode center;

[0137] Step 43 prepares the variables required for Hilbert coding, initializes code to 0, and accumulates to generate the final Hilbert coding. Initializes the unsigned integer register variable s to 0, indicating the state change path during the coding process.

[0138] Step S44, sequentially combine the binary bit values ​​of the current xg, yg, zg to form a local Morton decimal code m, calculate the local Hilbert decimal code h according to the member array mortonToHilbertMapping of the Hilbert encoder, update the Hilbert code of the octalNode center, update the register variable s according to the member array parentToChildMapping of the Hilbert encoder, and then proceed to the next traversal process. When the traversal process is completed, the value of the register variable code is used as the Hilbert decimal code value of the octalNode center.

[0139] Synchronously traverse the binary bit values ​​of xg, yg, zg from the highest bit to the lowest bit. During the traversal process, first combine the current binary bit values ​​of xg, yg, zg in sequence to form a local Morton decimal code m, then calculate the local Hilbert decimal code h according to the member array mortonToHilbertMapping of the Hilbert encoder, and the process is expressed as h = mortonToHilbertMapping [( s<<3 ) + m], then update the Hilbert code of the octalNode center, and the expression process is code = ( code<<3 ) + h, and finally update the register variable s to s = parentToChildMapping [( s<<3 ) +h] according to the member array parentToChildMapping of the Hilbert encoder to proceed to the next traversal process (Note: << is the left shift operator in C++ bit operations). When the traversal process ends, the value of the register variable code is the Hilbert decimal code value of the octalNode center.

[0140] Step S5: After the adaptive numerical simulation process of the Cartesian grid solver is completed, the Hilbert encoder is destroyed and the storage space of the Hilbert encoder is released for each processor.

[0141] The release operation in step S5 occurs after the adaptive numerical simulation process of the Cartesian grid solver is completed. When all relevant calculations and data processing work have been completed and the Hilbert encoder is no longer needed for encoding or retrieval operations, it is the best time to perform the release operation. Since the Hilbert encoder is instantiated synchronously on each processor as mentioned in step 3, the release operation must also be performed separately on each processor to avoid resource leakage.

[0142] In a possible implementation manner, the present application embodiment takes the helicopter-specific numerical simulation software NNW_HELIX in the National Numerical Wind Tunnel Project as an example to further describe:

[0143] In order to achieve high-precision numerical simulation of the unsteady evolution process of helicopter rotor blade tip vortex, NNW_HELIX uses the overlapping assembly of background Cartesian grid and body-fitting structure grid to spatially discretize the calculation area. Among them, in order to maintain dynamic load balance during the grid adaptation process, NNW_HELIX software uses the Hilbert code generator of the present invention to realize the decomposition process of the space filling curve. Figure 5 is a grid decomposition diagram when 12 processors are used for numerical simulation in an embodiment of the present invention. When 12 processors are used for numerical simulation, one of the regional decomposition states is taken, and the calculation grid on each processor is displayed in turn. Current tests show that the Hilbert encoder designed by the present invention avoids the jumpiness when the space filling curve is decomposed, the aggregation of the calculation units on each processor is good, and the load balance is as high as 98% or more. Further tests show that for a Cartesian calculation grid of the order of 50 million, when 128 processors are used for parallel calculation, the overall Hilbert encoding time does not exceed 1 second.

[0144] The embodiments show that the application of the present invention can accurately and quickly implement Hilbert coding of a large-scale distributed Cartesian grid system, thereby providing effective technical support for the dynamic load balancing process required for high-performance parallel computing.

[0145] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0146] For Cartesian grids of tens of millions or more in size, in each step of the parallel adaptive process, the model provided by the present invention can quickly realize the Hilbert code calculation of the octree node center, and then realize the dynamic load balancing process, providing effective support for high-performance flow field numerical simulation on large Cartesian grids.

[0147] A possible implementation of a Hilbert encoding device for a three-dimensional distributed Cartesian grid is provided below, which is used to execute the various execution steps and corresponding technical effects of the Hilbert encoding method shown in the above embodiments and possible implementations. The device includes:

[0148] Definition module, used to define the storage structure of the basic state linker and Hilbert encoder;

[0149] A calling module, used for calling a memory manager to construct a hierarchical transformation group model of a Cartesian grid octree structure based on a storage structure;

[0150] An instantiation module is used to call the memory manager during the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure and to synchronously instantiate the Hilbert encoder on each processor;

[0151] The encoding module is used to perform global reduction operations through a message passing interface to parallelly calculate the infimum of the coordinate components of the Cartesian grid region in the three-dimensional space, and generate the Hilbert code of the Cartesian grid octree node on each processor using a Hilbert encoder;

[0152] The release module is used to destroy the Hilbert encoder and release the storage space of the Hilbert encoder for each processor after the adaptive numerical simulation process of the Cartesian grid solver is completed.

[0153] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.< / bitset> < / bitset> < / vector> < / vector> < / bitset> < / bitset> < / vector>

Claims

1. A Hilbert coding method for a three-dimensional distributed Cartesian grid, characterized in that: The method comprises: Step S1, defining the storage structure of the basic status linker and the Hilbert encoder, the abstract data type of the basic status linker is named MYBasicStatus, including a signed integer variable index, an unsigned integer array series, and a MYBasicStatus pointer type array child; The signed integer variable index is used to store the number of the current basic state linker in the finite sequence of all basic state linkers; Unsigned integer array series is used to store the Hilbert decimal code sequence in the current state; MYBasicStatus pointer type array child, used to store the first address of the child object of the current basic status linker; In the constructor of MYBasicStatus, the unsigned integer array series and the MYBasicStatus pointer type array child are dynamically generated through the memory manager and each element of the MYBasicStatus pointer type array child is a null address value NULL; In the destructor of MYBasicStatus, the storage space of the unsigned integer array series and the MYBasicStatus pointer type array child is released through the memory manager; The abstract data type of the Hilbert encoder is named MYCodeGenerator, which includes the array hilbertToMortonMapping, the array mortonToHilbertMapping and the array rentToChildMapping. The array hilbertToMortonMapping is used to record the mapping relationship from Hilbert decimal code to Morton decimal code in the finite sequence of all basic state linkers. The array mortonToHilbertMapping is used to record the mapping relationship from Morton decimal code to Hilbert decimal code in the finite sequence of all basic state linkers. The array parentToChildMapping is used to record the mapping relationship from the parent node to its child node in the finite sequence of all basic state linkers. In the constructor of MYCodeGenerator, the first addresses of the arrays hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping are all set to NULL; In the destructor of MYCodeGenerator, the storage space of the array hilbertToMortonMapping, the array mortonToHilbertMapping, and the array parentToChildMapping are all released through the memory manager; Step 21: Call the C++ Standard Template Library <vector>The header file declares the vector container group, which stores the first address of each element of the finite sequence of all basic state linkers;< / vector> Step 22, calling the constructor of MYBasicStatus to instantiate the initial basic status linker, setting the transformation of the internal member representation of the initial basic status linker to the identity transformation, and storing the first address into the vector container group through the push_back operation of the vector container; Step 23, construct a Boolean variable indicator logic and set the initial value of the Boolean variable indicator logic to true, and construct a while type loop process to generate the remaining basic state linkers; Step 24, record the final length of the vector container group through the signed integer register variable msize, and allocate dynamic memory for the arrays hilbertToMortonMapping, mortonToHilbertMapping, and rentToChildMapping of the Hilbert encoder; Step 25, traverse each element in the vector container group and set the value of the internal member variable of each element; Step 26, updating the internal member array parentToChildMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group, and the inner loop sequentially traverses the child objects of each element, and uses the internal member variables of the child objects to sequentially update the element values ​​of parentToChildMapping; Step 27, updating the internal member array hilbertToMortonMapping and array mortonToHilbertMapping of the Hilbert encoder through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group and extracts the first address of the internal member array of each element, and the inner loop sequentially traverses the Hilbert decimal code value stored in each element, and maps the Hilbert decimal code value to the corresponding Morton decimal code in combination with the array mcode; Step 28, traverse the vector container group, release the dynamic memory occupied by each basic state linker in turn, and complete the construction of the hierarchical transformation group model of the Cartesian grid octree structure; Step S3, calling the memory manager in the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure, and synchronously instantiating the Hilbert encoder on each processor; Step S41, declare three unsigned integer register variables i, j, k, which are used to store the Gauss coordinates of the center of the octree node octalNode; Step S42: Call the C++ Standard Template Library <bitset> The header file declares three bit operation containers xg, yg, and zg, and copies the values ​​of i, j, and k to the bit operation containers xg, yg, and zg in sequence;< / bitset> Step S43, declare an unsigned long integer register variable code and an unsigned integer register variable s to store the basic state number, and the unsigned long integer register variable code is used to store the Hilbert code of the octalNode center; Step S44, sequentially combine the binary bit values ​​of the current xg, yg, zg to form a local Morton decimal code m, calculate the local Hilbert decimal code h according to the member array mortonToHilbertMapping of the Hilbert encoder, update the Hilbert code of the octalNode center, update the register variable s according to the member array parentToChildMapping of the Hilbert encoder, and then proceed to the next traversal process. When the traversal process is completed, the value of the register variable code is used as the Hilbert decimal code value of the octalNode center; Step S5: After the adaptive numerical simulation process of the Cartesian grid solver is completed, the Hilbert encoder is destroyed and the storage space of the Hilbert encoder is released for each processor.

2. The Hilbert encoding method according to claim 1, wherein: The steps of the while loop process in step 23 include: Step 231, declare signed integer register variables p and q and set their initial values ​​to -1; Step 232, traverse the first address of each basic state linker in the vector container group, if there is a null address value NULL in the child address value in the first address, use the signed integer register variable p to record the number of the current basic state linker in the vector container group, and use the signed integer register variable q to record the number of the first child address pointing to the null address value NULL in the current basic state linker; Step 233, check the value of the signed integer register variable q, if the initial value -1 remains unchanged, then jump out of the while loop immediately, otherwise execute steps 234 to 236; Step 234, in the basic state linker located by the signed integer register variable p, traverse the elements in the member variable, and map each element into a Morton decimal code sequence in sequence in combination with the array mcode, and store the result in the unsigned integer register array source; Step 235, declare an unsigned integer register array stream, and call the C++ standard template library <bitset> The header file declares a bit operation container target. In the basic state linker located by the register variable p, the child pointer located by the register variable q is classified and processed, and the Morton decimal code m is mapped to stream[j] in combination with the data array hcode;< / bitset> Step 236, traverse the current dynamic vector container group, compare the consistency of the internal member series of each basic state linker group[i] in the vector container group with the value stored in the unsigned integer register array stream, if the consistency is established during the traversal process, point the child pointer located by the register variable q to the first address of the current basic state linker group[i] and jump out of the traversal process, if the consistency is not established during the entire traversal process, use the memory manager to dynamically generate a new basic state linker object, copy the value of the unsigned integer register array stream to the internal member series of status, store the first address of status in group through the push_back operation of the vector container, and point the child pointer located by the register variable q to the first address of status.

3. The Hilbert encoding method according to claim 2, characterized in that: The steps of classifying the child pointers located by the register variable q and mapping the Morton decimal code m to stream[j] in combination with the data array hcode include: When the value of q is 0 or 4, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target, convert the binary sequence of target into Morton decimal code m, and finally map m to stream[j] in combination with the array hcode; When the value of q is 3 or 7, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the 0th and 2nd digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with the array hcode; When the value of q is 1, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode; When the value of q is 6, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, replace the first and second digits of target and invert them respectively, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode; When the value of q is 2 or 5, traverse each element source[j] of the array source in turn, copy the value of source[j] to target, convert the binary sequence of target into Morton decimal code m, and map m to stream[j] in combination with array hcode.

4. The Hilbert encoding method according to claim 1, wherein: Unsigned integer register variable , unsigned integer register variable , unsigned integer register variable ,in( , , ) is the lower bound of the physical coordinates of the octalNode in the x, y, and z coordinate axes. ( , , ) is the physical coordinate upper bound of the octree node octalNode in the x, y, and z coordinate axis directions. is the C++ floor function, ( , , ) is the infimum of the x, y, and z coordinate components of the Cartesian grid region in three-dimensional space.

5. A Hilbert encoding device for a three-dimensional distributed Cartesian grid, characterized in that: The device comprises: A definition module is used to define the storage structure of the basic state linker and the Hilbert encoder. The abstract data type of the basic state linker is named MYBasicStatus, including a signed integer variable index, an unsigned integer array series, and a MYBasicStatus pointer type array child; The signed integer variable index is used to store the number of the current basic state linker in the finite sequence of all basic state linkers; Unsigned integer array series is used to store the Hilbert decimal code sequence in the current state; MYBasicStatus pointer type array child, used to store the first address of the child object of the current basic status linker; In the constructor of MYBasicStatus, the unsigned integer array series and the MYBasicStatus pointer type array child are dynamically generated through the memory manager and each element of the MYBasicStatus pointer type array child is a null address value NULL; In the destructor of MYBasicStatus, the storage space of the unsigned integer array series and the MYBasicStatus pointer type array child is released through the memory manager; The abstract data type of the Hilbert encoder is named MYCodeGenerator, which includes the array hilbertToMortonMapping, the array mortonToHilbertMapping and the array rentToChildMapping. The array hilbertToMortonMapping is used to record the mapping relationship from Hilbert decimal code to Morton decimal code in the finite sequence of all basic state linkers. The array mortonToHilbertMapping is used to record the mapping relationship from Morton decimal code to Hilbert decimal code in the finite sequence of all basic state linkers. The array parentToChildMapping is used to record the mapping relationship from the parent node to its child node in the finite sequence of all basic state linkers. In the constructor of MYCodeGenerator, the first addresses of the arrays hilbertToMortonMapping, mortonToHilbertMapping, and parentToChildMapping are all set to NULL; In the destructor of MYCodeGenerator, the storage space of the array hilbertToMortonMapping, the array mortonToHilbertMapping, and the array parentToChildMapping are all released through the memory manager; Calling module, calling C++ Standard Template Library <vector> The header file declares the vector container group, which stores the first address of each element of the finite sequence of all basic state linkers;< / vector> Call the constructor of MYBasicStatus to instantiate the initial basic status linker, set the transformation of the internal member representation of the initial basic status linker to the identity transformation, and store the first address into the vector container group through the push_back operation of the vector container; Construct a Boolean variable indicator logic and set the initial value of the Boolean variable indicator logic to true, and construct a while loop process to generate the remaining basic state linkers; The final length of the vector container group is recorded through the signed integer register variable msize, and dynamic memory is allocated for the arrays hilbertToMortonMapping, mortonToHilbertMapping, and rentToChildMapping of the Hilbert encoder; Traverse each element in the vector container group and set the value of the internal member variable of each element; Update the internal member array parentToChildMapping of the Hilbert encoder through a double loop process, where the outer loop iterates over each element of the vector container group in turn, and the inner loop iterates over the child objects of each element in turn, and uses the internal member variables of the child objects to update the element values ​​of parentToChildMapping in turn; The internal member array hilbertToMortonMapping and array mortonToHilbertMapping of the Hilbert encoder are updated through a double loop process, wherein the outer loop sequentially traverses each element of the vector container group and extracts the first address of the internal member array of each element, and the inner loop sequentially traverses the Hilbert decimal code value stored in each element, and maps the Hilbert decimal code value to the corresponding Morton decimal code in combination with the array mcode; Traverse the vector container group, release the dynamic memory occupied by each basic state linker in turn, and complete the construction of the hierarchical transformation group model of the Cartesian grid octree structure; An instantiation module is used to call the memory manager during the initialization phase of the hierarchical transformation group model of the Cartesian grid octree structure and to synchronously instantiate the Hilbert encoder on each processor; The encoding module is used to declare three unsigned integer register variables i, j, and k to store the Gauss coordinates of the center of the octalNode node; Calling the C++ Standard Template Library <bitset>The header file declares three bit operation containers xg, yg, and zg, and copies the values ​​of i, j, and k to the bit operation containers xg, yg, and zg in sequence;< / bitset> Declare unsigned long integer register variables code and unsigned integer register variables s to store the basic state number. Unsigned long integer register variable code is used to store the Hilbert code of the octalNode center. Combine the binary bit values ​​of the current xg, yg, zg in sequence to form a local Morton decimal code m, calculate the local Hilbert decimal code h according to the member array mortonToHilbertMapping of the Hilbert encoder, update the Hilbert code of the center of the octalNode, update the register variable s according to the member array parentToChildMapping of the Hilbert encoder, and then proceed to the next traversal process. When the traversal process is completed, the value of the register variable code is used as the Hilbert decimal code value of the center of the octalNode; The release module is used to destroy the Hilbert encoder and release the storage space of the Hilbert encoder for each processor after the adaptive numerical simulation process of the Cartesian grid solver is completed.

Citation Information

Patent Citations

  • Block adaptive type Cartesian grid rapid graph mapping method and system

    CN113689556A

  • Decoding and coding methods based on point cloud attribute prediction, decoder and encoder

    CN115086660A