A non-structured grid data rearrangement method based on cache block wavefront ordering and related device
By constructing a dual graph and multi-source breadth-first search, combined with a sorting method based on block thickness parameters and space-filling curve rank, the problem of wasted cache lines in unstructured mesh data rearrangement is solved, achieving computational acceleration and simulation speed improvement in fluid dynamics calculations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG RES INST OF WATER RESOURCES & HYDROPOWER
- Filing Date
- 2026-04-02
- Publication Date
- 2026-07-31
AI Technical Summary
Existing unstructured mesh data rearrangement methods lead to wasted cache lines and cache thrashing in fluid dynamics calculations, creating a bottleneck of limited memory bandwidth and making it difficult to achieve significant computational speedup while maintaining numerical accuracy.
The topological hierarchy is obtained by constructing a dual graph and using multi-source breadth-first search. Band aggregation is performed based on the block thickness parameter and the topological hierarchy. The rank of the space-filling curve is calculated by combining the geometric center coordinates of the grid cells. The cells are sorted in ascending and lexicographical order, and the cell array and interface array are reordered in a consistent manner.
It improves the cache hit rate of parallel processors, reduces the number of cross-cache line accesses, improves the efficiency of memory bandwidth utilization, reduces the computation time per step of parallel processors, and improves the overall simulation speed.
Smart Images

Figure CN122489677A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and related equipment for rearranging unstructured grid data based on cached block wavefront sorting. Background Technology
[0002] Currently, unstructured meshes are widely used in fluid dynamics calculations for complex terrains and boundaries (such as urban building complexes, port shorelines, and river network systems). Taking the finite volume method as an example, cell updates typically rely on read and write access to the set of adjacent cells. When the arrangement of mesh cells in memory does not match their topological adjacency, thread access will exhibit non-contiguous and non-merged memory access behavior, leading to cache line waste and cache thrashing, thus forming a typical "memory-bound" bottleneck.
[0003] However, common unstructured mesh data rearrangement methods mainly include geometric rearrangement, topological rearrangement, and standard wavefront rearrangement. Geometric rearrangement methods are based on cell center coordinates to maintain geometric proximity, but they are difficult to reflect the actual flow connectivity. In the presence of obstacles, narrow channels, or strongly non-uniform mesh scales, geometric proximity is not equivalent to dual graph adjacency access proximity, resulting in a large number of cross-cache line accesses during the flux calculation stage. Topological rearrangement methods tend to optimize the bandwidth of linear equation system matrices and are more suitable for implicit solvers. For explicit time-progressive flux updates, their main overhead comes from edge traversal and adjacency reads and writes. The correlation between bandwidth optimization and GPU (Graphics Processing Unit) memory access locality is unstable, and the benefits fluctuate greatly under different boundary / source term configurations. Standard wavefront rearrangement methods can reflect the propagation direction, but in two-dimensional unstructured meshes, each layer often has a narrow leading edge, and the sortable space within the layer is insufficient, which easily leads to the "thin layer" problem, that is, memory addresses frequently jump at layer switching points, resulting in insufficient cache line reuse.
[0004] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention
[0005] The embodiments of this application aim to at least partially solve one of the technical problems in the related art. Therefore, the main objective of the embodiments of this application is to propose a method and related equipment for rearranging unstructured grid data based on cached block wavefront sorting, which can reduce the computation time per step of parallel processors and improve the overall simulation speed in scenarios such as flood simulation.
[0006] To achieve the above objectives, one aspect of this application proposes a method for rearranging unstructured grid data based on cached block wavefront sorting, the method comprising the following steps: Obtain unstructured grid data of the flood simulation calculation area, and construct a dual graph based on the unstructured grid data; Based on the set of source nodes on the dual graph, a multi-source breadth-first search is performed on the dual graph to obtain the topological hierarchy of each grid cell in the unstructured grid data. Based on the preset block thickness parameters and the topology level of each grid cell, band aggregation is performed on all grid cells, and the band number of each grid cell is calculated. Within each band, the rank of the corresponding space-filling curve is calculated based on the geometric center coordinates of each grid cell within the band, and all grid cells within the band are sorted in ascending order based on the rank of the space-filling curve of each grid cell within the band. Based on the band number and the corresponding space-filling curve rank of each grid cell, all grid cells after intra-band ascending sort are sorted in lexicographical order to obtain a cell rearrangement sequence, and a rearrangement mapping relationship is determined based on the cell rearrangement sequence. Based on the rearrangement mapping relationship, the cell array and interface array in the unstructured mesh data are uniformly rearranged to obtain a uniform rearrangement result.
[0007] In some embodiments, the step of performing a multi-source breadth-first search on the dual graph based on the set of source cells on the dual graph to obtain the topological hierarchy of each grid cell in the unstructured grid data includes: The set of source point units on the dual graph is determined according to boundary determination conditions; wherein, the boundary determination conditions are boundary type, inflow marker, or preset determination rules; Based on the set of source nodes on the dual graph, a multi-source breadth-first search is performed on the dual graph to obtain the topological level of each grid cell in the unstructured grid data.
[0008] In some embodiments, the step of calculating the rank of the space-filling curve corresponding to the geometric center coordinates of each grid cell within each band, and sorting all grid cells within the band in ascending order based on the rank of the space-filling curve of each grid cell within the band, includes: Within each band, determine the geometric center coordinates of each grid cell within the band; The geometric center coordinates of each grid cell within the band are normalized and mapped to a discrete network to obtain the discrete coordinates corresponding to each grid cell; By mapping the discrete coordinates corresponding to each grid cell using a preset mapping function, the rank of the space-filling curve corresponding to each grid cell is obtained; Based on the space-fill curve rank of each grid cell within the band, all grid cells within the band are sorted in ascending order.
[0009] In some embodiments, the consistent rearrangement of the cell array and interface array in the unstructured mesh data based on the rearrangement mapping relationship to obtain a consistent rearrangement result includes: The cell array is sorted according to the rearrangement mapping relationship to obtain the cell array rearrangement result; Based on the rearrangement result of the unit array, the keywords of each interface in the interface array are constructed, and the interface array is sorted according to the keywords of each interface so that interfaces connecting the same band or adjacent bands are stored continuously in memory, thus obtaining the interface array rearrangement result. Based on the rearrangement results of the cell array and the interface array, the consistent rearrangement result is constructed.
[0010] In some embodiments, the method further includes: When constructing the keywords for each interface in the interface array, if an interface in the interface array is a boundary interface, then the band number and rearrangement position of the missing side unit of the boundary interface are processed using a preset sentinel value.
[0011] In some embodiments, after performing a consistent rearrangement of the cell array and interface array in the unstructured mesh data based on the rearrangement mapping relationship to obtain a consistent rearrangement result, the method further includes: Based on the consistent rearrangement results, the fluid dynamics control equations are numerically solved on the unstructured mesh.
[0012] To achieve the above objectives, another aspect of this application proposes an unstructured grid data rearrangement device based on cached block wavefront sorting, the device comprising the following modules: The dual graph construction module is used to acquire unstructured grid data of the flood simulation calculation area and construct a dual graph based on the unstructured grid data; The topology hierarchy calculation module is used to perform a multi-source breadth-first search on the dual graph based on the set of source nodes on the dual graph, so as to obtain the topology hierarchy of each grid cell in the unstructured grid data. The band aggregation module is used to perform band aggregation on all the grid cells based on preset block thickness parameters and the topology level of each grid cell, and to calculate the band number of each grid cell. The unit ascending sorting module is used to calculate the corresponding space filling curve rank of each grid unit in each band based on the geometric center coordinates of each grid unit in the band, and to sort all grid units in the band in ascending order based on the space filling curve rank of each grid unit in the band. The unit lexicographical sorting module is used to perform lexicographical sorting on all the grid units after intra-band ascending sorting based on the band number and the corresponding space-filling curve rank of each grid unit, to obtain the unit rearrangement sequence, and to determine the rearrangement mapping relationship based on the unit rearrangement sequence. The array consistency rearrangement module is used to perform consistency rearrangement of the cell array and interface array in the unstructured grid data based on the rearrangement mapping relationship, and obtain the consistency rearrangement result.
[0013] To achieve the above objectives, another aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0014] To achieve the above objectives, another aspect of the embodiments of this application proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0015] To achieve the above objectives, another aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0016] The embodiments of this application include at least the following beneficial effects: This application provides a method and related equipment for rearranging unstructured grid data based on cached block wavefront sorting. This scheme acquires unstructured grid data from a flood simulation calculation area and constructs a dual graph based on the unstructured grid data; based on the source point unit set on the dual graph, a multi-source breadth-first search is performed on the dual graph to obtain the topological level of each grid unit in the unstructured grid data; based on preset block thickness parameters and the topological level of each grid unit, band aggregation is performed on all grid units, and the band number of each grid unit is calculated; Within each band, the rank of the corresponding space-filling curve is calculated based on the geometric center coordinates of each grid cell within the band. All grid cells within the band are then sorted in ascending order based on their space-filling curve ranks. Based on the band number and corresponding space-filling curve rank of each grid cell, all grid cells after ascending sorting within the band are sorted lexicographically to obtain a cell rearrangement sequence. The rearrangement mapping relationship is then determined based on this sequence. Finally, the cell array and interface array in the unstructured grid data are uniformly rearranged based on the rearrangement mapping relationship to obtain a uniform rearrangement result. This application's embodiments achieve topological flow constraints by constructing a dual graph and employing multi-source breadth-first search to obtain the topological hierarchy. By aggregating all mesh cells based on block thickness parameters and the topological hierarchy, and calculating the corresponding space-fill curve rank within each band based on the geometric center coordinates of the mesh cells, all mesh cells within a band are sorted in ascending order according to the space-fill curve rank. Then, based on the band number and corresponding space-fill curve rank of each mesh cell, a lexicographical sort is performed on all mesh cells after the ascending sort within the band. This enhances geometric locality under topological flow constraints. By thickening the bands, the sorting granularity matches the hardware thread bundle and cache granularity, thereby improving the cache hit rate of the parallel processor, reducing the number of cross-cache line accesses, and improving memory bandwidth utilization efficiency. Finally, based on the rearrangement mapping relationship, the cell array and interface array in the unstructured mesh data are reordered consistently, which can reduce the computation time per step of the parallel processor and improve the overall simulation speed in scenarios such as large-scale flood simulations. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the steps of an unstructured grid data rearrangement method based on cached block wavefront sorting provided in an embodiment of this application. Figure 2 This is a schematic diagram of the overall process of an unstructured grid data rearrangement method based on cached block wavefront sorting provided in an embodiment of this application; Figure 3 This is a schematic diagram of an unstructured mesh provided in an embodiment of this application; Figure 4 This is a schematic diagram of the WaveFront layering provided in the embodiments of this application; Figure 5 This is a schematic diagram of band thickening and fusion provided in an embodiment of this application; Figure 6 This is a schematic diagram of the access path connecting the center points according to the unit number in the original sequence, provided by an embodiment of this application; Figure 7 This is a schematic diagram of the access path for connecting the center points according to the unit number in the Thick Wavefront sequence, provided in an embodiment of this application. Figure 8 This is a schematic diagram of the access path connecting the center points according to the unit number in the Hilbert sequence, provided in an embodiment of this application. Figure 9 This is a schematic diagram of the non-zero structure of the pre-adjacency matrix rearranged in the original order, provided in an embodiment of this application. Figure 10 This is a schematic diagram of the non-zero adjacency matrix structure after rearranging in the Thick Wavefront order, provided in an embodiment of this application. Figure 11 This is a schematic diagram of the non-zero adjacency matrix structure after rearranging under the Hilbert order, provided in an embodiment of this application. Figure 12 This is a schematic diagram comparing the speedup ratios of different data rearrangement methods provided in the embodiments of this application on typical computational examples; Figure 13 This is a schematic diagram of an example of urban flooding using an unstructured triangular mesh provided in this application embodiment; Figure 14 This is a schematic diagram of the structure of an unstructured grid data rearrangement device based on cache block wavefront sorting provided in an embodiment of this application; Figure 15 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of apparatuses and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0019] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0020] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0022] Currently, unstructured meshes are widely used in fluid dynamics calculations for complex terrains and boundaries (such as urban building complexes, port shorelines, and river network systems). Taking the finite volume method as an example, cell updates typically rely on the set of adjacent cells. When the arrangement of grid cells in memory does not match their topological adjacency, thread access will exhibit non-contiguous and non-merged memory access behavior, leading to cache line waste and cache thrashing, thus forming a typical "memory-bound" bottleneck.
[0023] Common unstructured grid data rearrangement methods include: (1) Geometric rearrangement (e.g., Hilbert curve, Z curve): sorting based on the coordinates of the cell center to maintain geometric proximity, but it is difficult to reflect the actual flow connectivity; (2) Topological rearrangement (e.g., RCM (Reverse Cuthill-McKee Algorithm)): tends to optimize the bandwidth of the linear equation system matrix and is more suitable for implicit solvers; (3) Standard wavefront rearrangement (BFS (Breadth-First Search) hierarchical sorting): It can reflect the direction of propagation, but in two-dimensional unstructured grids, each layer often has a narrow front edge, and the sortable space within the layer is insufficient, which can easily lead to the problem of "thin layers", that is, the memory address jumps frequently at the level switching point, resulting in insufficient cache line reuse.
[0024] However, for solving explicit finite volume problems on unstructured meshes on GPUs (Graphics Processing Units) / many-core processors, related research and engineering practices still have the following limitations, making it difficult to achieve significant computational speedup while maintaining numerical correctness: (1) Geometric rearrangement is based only on spatial proximity and does not explicitly constrain the topological direction of "downstream propagation / information propagation". When there are obstacles, narrow channels or strong non-uniform grid scales, geometric proximity is not equivalent to dual graph adjacency access proximity, resulting in a large number of cross-cache line accesses still occurring during the throughput calculation stage. (2) Standard BFS wavefront sorting often presents "too thin a layer" on two-dimensional / three-dimensional unstructured grids. The number of units contained in a single layer is insufficient to cover the continuous processing needs of one or more thread bundles / thread blocks, causing frequent switching between adjacent layers, resulting in memory access address jumps and a decrease in cache line effective load, making it difficult to fully leverage the advantages of merged memory access and cache reuse. (3) Topological rearrangement with matrix bandwidth as the target (such as RCM) is more suitable for the solution stage of implicit linear systems; for the flux update with explicit time advancement, its main overhead comes from edge traversal and adjacency read and write. The correlation between bandwidth optimization and GPU memory access locality is unstable, and the benefit fluctuates greatly under different boundary / source item configurations. (4) Some graph partitioning / clustering methods require high preprocessing costs or rely on external libraries, and need to be recalculated when the source point, boundary conditions or local mesh refinement change; their output order may not be aligned with the hardware thread bundle granularity, and it is difficult to directly map to the GPU memory access coordination mode. (5) The relevant methods often only sort the cell array and do not perform consistent rearrangement of the interface array and its "interface-cell" reference relationship, which results in the local benefits of the cell update stage and the interface throughput stage not being reflected synchronously, and the overall performance is still limited by the memory bandwidth bottleneck.
[0025] In view of this, this application provides a method and related device for rearranging unstructured grid data based on cache block wavefront sorting. This scheme obtains the topology hierarchy by constructing a dual graph and using multi-source breadth-first search, which can realize topology flow constraints. By performing band aggregation on all grid cells based on block thickness parameters and topology hierarchy, and calculating the corresponding space-fill curve rank within each band according to the geometric center coordinates of the grid cells, all grid cells within the band are sorted in ascending order according to the space-fill curve rank. Then, based on the band number and the corresponding space-fill curve rank of each grid cell, all grid cells after ascending sorting within the band are sorted in lexicographical order. This can enhance geometric locality under topology flow constraints. By thickening the bands, the sorting granularity is matched with the hardware thread bundle and cache granularity, thereby improving the cache hit rate of parallel processors, reducing the number of cross-cache line accesses, and improving the efficiency of memory bandwidth utilization. Finally, based on the rearrangement mapping relationship, the cell array and interface array in the unstructured grid data are reordered in a consistent manner, which can reduce the computation time per step of parallel processors and improve the overall simulation speed in scenarios such as large-scale flood simulation.
[0026] This application provides a method for reordering unstructured grid data based on cached block wavefront sorting, relating to the field of computer technology. This method can be applied to terminals, servers, or software running on either a terminal or server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, or in-vehicle terminal, but is not limited to these. The server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application implementing the method, but is not limited to these forms.
[0027] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0028] Please see Figure 1 , Figure 1 This is an optional flowchart of a method for rearranging unstructured grid data based on cached block wavefront sorting, provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S101 to S106.
[0029] Step S101: Obtain unstructured grid data of the flood simulation calculation area, and construct a dual graph based on the unstructured grid data; The flood simulation calculation area refers to the spatial range selected for numerical calculation of hydrodynamic or hydrological processes in flood simulation. It is usually a two-dimensional or three-dimensional geographical area that includes topography, water system, and boundary conditions, such as urban areas or watershed areas.
[0030] In practical implementation, flood simulation first requires discretizing the computational domain into either a structured or unstructured mesh. However, since structured meshes are typically only suitable for areas with regular terrain, unstructured meshes are generally used in practical applications. Unstructured meshes contain three basic data structures: cells, interfaces, and nodes. For example, assuming a triangular cell contains 3 interfaces and 3 nodes, the cell is two-dimensional, the interface is a one-dimensional line, and the node is a point. Based on unstructured meshes, the governing equations describing the flow motion can be solved. These governing equations are generally shallow water equations and can be used for numerical simulation scenarios such as flood simulations.
[0031] Specifically, unstructured mesh data refers to the set of mesh cells and related attribute data obtained after discretizing the flood simulation calculation area. Unstructured mesh data includes at least the set of cells, the set of interfaces, and the relationships between interfaces and cells.
[0032] Alternatively, it is assumed that the unstructured grid data contains Unit Interface. Connect left unit With the right unit Among them, the boundary interface can make .
[0033] In dual graph middle, Corresponding unit set, Corresponding interface set; if two units share the same internal interface, then in Add an undirected interface. Define the adjacency matrix of the dual graph. as follows: ; in, Let be the element value in the i-th row and j-th column of the adjacency matrix A; and These are the numbers of two adjacent units.
[0034] In the specific implementation, a dual graph is constructed with units as nodes and shared interfaces as edges. Specifically, the cell array (the core data structure storing all information in the unstructured grid) has a length of... The structure is given, and each interface Record the cell indexes on both sides and The construction of dual graphs follows these rules: for any internal interface (i.e. ),make , In the interface set Add undirected edges and and will join in adjacency list, join in The adjacency list is used to obtain the set of adjacent cells. : ; Finally, based on the set of adjacent units... Construct the dual graph corresponding to the unstructured mesh of the flood simulation computation domain. .
[0035] It is worth mentioning that the method provided in this application can be widely applied to various numerical simulation scenarios based on the finite volume method, including but not limited to flood simulation, computational fluid dynamics (CFD) simulation, levee seepage simulation, magnetic field simulation, etc.
[0036] Step S102: Based on the set of source cells on the dual graph, perform a multi-source breadth-first search on the dual graph to obtain the topological hierarchy of each grid cell in the unstructured grid data; In some embodiments, step S102 may include: determining the set of source cells on the dual graph according to boundary determination conditions; wherein the boundary determination conditions are boundary type, inflow marker or preset determination rule; and performing a multi-source breadth-first search on the dual graph based on the set of source cells on the dual graph to obtain the topological level of each grid cell in the unstructured grid data.
[0037] Optionally, the source element set is the set of vertices (i.e., grid cells) representing the initial inflow / source location in the flood simulation in the dual graph, and serves as the starting point for multi-source BFS (breadth-first search). For example, the source element set can be the grid cells corresponding to the river inlet, the grid cells corresponding to the storm center, and preset flood inundation zone cells, etc. Here, the grid cells are the basic discrete units constituting the computational domain, such as the control volume in the finite volume method or the element in the finite element method.
[0038] The boundary determination criteria are a set of rules used to select source point units from the vertex set of the dual graph. Boundary determination criteria can be based on boundary type, inflow marker, or preset rules. Boundary type refers to the boundary attribute classification of unstructured mesh units (e.g., inflow boundary, outflow boundary, solid wall boundary, etc.); inflow marker is a marker set for mesh units to indicate whether inflow exists (e.g., a marker of 1 represents inflow, 0 represents no inflow); preset rules are source point selection logic based on the geometric / physical attributes of the units, preset according to business requirements.
[0039] For the topology level, it is the level number assigned to each grid cell during the multi-source BFS traversal, reflecting the topological distance of the cell relative to the source point.
[0040] In the specific implementation, one or more source point unit sets are determined based on boundary type, inflow marker, or preset determination rules. Based on source point unit set In dual graphs Perform a multi-source breadth-first search to obtain each cell. Topology hierarchy For a given set of source point elements Topology level is defined as the shortest path distance. Determined by the following formula: ; in, This represents the shortest path length on the dual graph. The shortest path length is obtained through multi-source breadth-first search, which can be viewed as initializing the queue to all source nodes and expanding it simultaneously. Represents the set of source point units; Represents the set of source point units One of the elements, namely a single source point unit; topological hierarchy is the distance from cell i to the nearest source cell.
[0041] Step S103: Based on the preset block thickness parameters and the topology level of each grid cell, perform band aggregation on all grid cells and calculate the band number of each grid cell. Among them, the block thickness parameter Also known as band thickness parameter, it is a parameter used to control the granularity of band aggregation, determining how many consecutive topological levels are merged into a thick band. Block thickness parameter. The settings are based on the thread bundle width or cache line granularity of the target processor (such as a GPU), and, exemplarily, preferably... or Among them, the block thickness parameter The selection is adaptive based on the grid size, the number of source cells, or the cache miss rate measured during hardware runtime.
[0042] Band aggregation is a process that groups continuous units on the topology into several bands based on topological hierarchy and block thickness parameters, with the aim of solving the problem of "thin hierarchy" in traditional BFS.
[0043] To adapt to the cache granularity of target processors (such as GPUs), band numbering is introduced. The band number of a grid cell is the number of the "thick band" to which each cell belongs; that is, the identifier assigned to each cell after band aggregation. , representing the thick band to which the unit belongs.
[0044] In the specific implementation, the block thickness parameter is set. ( (A set of positive integers), band aggregation is performed on the cells based on the topological hierarchy, and the band number of each cell is calculated. Band number The calculation formula is as follows: .
[0045] Step S104: Within each band, calculate the corresponding space-filling curve rank based on the geometric center coordinates of each grid cell within the band, and sort all grid cells within the band in ascending order based on the space-filling curve rank of each grid cell within the band. In some embodiments, step S104 may include: determining the geometric center coordinates of each grid cell within each band; normalizing and mapping the geometric center coordinates of each grid cell within the band to a discrete network to obtain the discrete coordinates corresponding to each grid cell; mapping the discrete coordinates corresponding to each grid cell using a preset mapping function to obtain the space-filling curve rank corresponding to each grid cell; and sorting all grid cells within the band in ascending order according to the space-filling curve rank of each grid cell within the band.
[0046] The geometric center coordinates are the spatial coordinates (x, y, z) of the geometric center point of the grid cell, which are used for subsequent space filling curve mapping.
[0047] The rank of a space-fill curve is the result of mapping multidimensional spatial coordinates (such as two-dimensional or three-dimensional) to a one-dimensional sequence of integers; this integer is called the "rank". The rank of a space-fill curve is used to transform spatial proximity into the continuity of a one-dimensional sequence, facilitating the sorting of grid cells according to spatial location. It is obtained from any one of two-dimensional or three-dimensional Hilbert curves, Z curves or Morton curves, preferably Hilbert curves.
[0048] In this embodiment of the application, the space-filling curve rank Let be the rank of the Hilbert curve. To preserve the geometric locality of grid cells within the same band (i.e., spatially neighboring cells remain neighborly after sorting), the rank of the Hilbert curve is calculated for each cell. Within each band, the calculation is performed by first setting the geometric center coordinates of the i-th cell. Normalization is mapped to a discrete grid, and then mapped by the Hilbert mapping function. Mapping discrete coordinates to obtain the integer rank In each band, by integer rank Sort the grid cells in ascending order. Normalization and discretization are performed as follows: Let the coordinate range be... Let the discrete bit width be ,but: ; Wherein, the Hilbert mapping function Output bit width is A non-negative integer, used to express the locality order in two-dimensional space, and the rank of the integer. The calculation formula is as follows: ; in, These are the normalized discrete coordinates; These are the minimum and maximum coordinate values of the mesh cell along the X-axis, respectively. These are the minimum and maximum coordinate values of the grid cell along the Y-axis, respectively.
[0049] Similarly, in three-dimensional expansion, it can be... Discretize and let .
[0050] Step S105: Based on the band number and the corresponding space-filling curve rank of each grid cell, perform lexicographical sorting on all grid cells after intra-band ascending sorting to obtain a cell rearrangement sequence, and determine the rearrangement mapping relationship based on the cell rearrangement sequence. Lexicographical sorting is a multi-key sorting method, similar to the arrangement of words in a dictionary. Specifically, all units are first grouped by waveband, then sorted by spatial position within each group, ultimately forming a globally ordered unit rearrangement sequence. .
[0051] For rearranged mapping relationships This is a mapping table recording the corresponding position of each original grid cell in the rearranged sequence, i.e., the mapping relationship between the cells before and after sorting. The rearranged mapping relationship is used to transform data between the original order and the rearranged order before and after computation, ensuring data consistency. For example, assuming cell A's index is 1 before sorting and 100 after sorting, the rearranged mapping relationship for cell A is... The mapping relationship between package number 1 and package number 100. It is understandable that the mapping relationship is rearranged. It is a complete mapping set, which contains the mapping relationship between the numbering of all units before and after sorting.
[0052] For example, suppose the numbering sequence of grid A before reordering is 12345, and the numbering sequence of grid A after lexicographical sorting is 54321. Then, the sequence 54321 is regarded as the cell reordering sequence. Therefore, 12345 - 54321 is used as a rearranged mapping relationship. That is, the rearranged mapping relationship in this example is specifically 1-5, 2-4, 3-3, 4-2 and 5-1.
[0053] In practical implementation, band numbers are used. Primary key, space-filling curve rank Using the secondary key, perform lexicographical sorting on all cells to obtain the cell rearrangement sequence. and rearranged mapping relationships Specifically, lexicographical sort key For all units Lexicographical sorting yields the unit rearrangement sequence. And construct rearranged mapping relationships Among them, the rearrangement of mapping relationships The definition is as follows: ; Where t represents the unit number.
[0054] Step S106: Based on the rearrangement mapping relationship, perform a consistent rearrangement of the cell array and interface array in the unstructured mesh data to obtain a consistent rearrangement result.
[0055] In some embodiments, step S106 may include: sorting the cell array according to the rearrangement mapping relationship to obtain the cell array rearrangement result; constructing the key of each interface in the interface array based on the cell array rearrangement result, and sorting the interface array according to the key of each interface so that interfaces connecting the same band or adjacent bands are stored continuously in memory to obtain the interface array rearrangement result; and constructing a consistent rearrangement result based on the cell array rearrangement result and the interface array rearrangement result.
[0056] In some specific embodiments, it may also include: when constructing the keywords of each interface in the interface array, if the interface in the interface array is a boundary interface, then the band number and rearrangement position of the missing side unit of the boundary interface are processed by a preset sentinel value.
[0057] In the specific implementation, the rearrangement of the cell array is performed by directly rearranging all cells in the cell array according to the rearrangement mapping relationship after obtaining the rearrangement mapping relationship. For example, assuming the original cell array is sorted as 123 and the rearrangement mapping relationship is 1-2, 2-3, 3-1, then the cell order after sorting according to the rearrangement mapping relationship is 231.
[0058] In explicit finite volume methods, flux calculations are typically performed by traversing the interface array for rearranging the interface array. To ensure locality of reference during interface traversal, this application performs a consistent rearrangement of the interface array. In the specific implementation, this is based on the rearrangement mapping relationship between the cells on both sides of the interface. Construct each interface Keywords and by keyword The interface array is sorted so that interfaces connecting the same or adjacent bands are stored contiguously in memory. For boundary interfaces, the band number and rearrangement position of missing side cells are handled using preset sentinel values to ensure keyword accuracy. Comparable and sorted stably.
[0059] Specifically, firstly for each interface Constructing keywords : , in, To interface The adjacent left unit, To interface The adjacent right unit, The band number / layer number where element c is located. For cell c, the linear storage location / index is rearranged; then, by key... For the interface The sorting allows interfaces connecting the same or adjacent bands to be compactly distributed in memory. For boundary interfaces, this can be done by... and Alternatively, an equivalent preset sentinel value rule can be used to ensure that keywords are comparable and maintain ranking stability.
[0060] Consistent rearrangement satisfies the following mapping relationship: for any array stored by cell index... The array after rearrangement It is given by the following formula: Furthermore, for any interface connection relationship of a referenced unit index, its reference index is synchronously replaced with a rearranged mapping relationship. The corresponding new index.
[0061] In some embodiments, after step S106, the method may further include: numerically solving the fluid dynamics control equations on an unstructured grid based on the consistent rearrangement results.
[0062] Among them, the governing equations of fluid mechanics may include, but are not limited to, shallow water equation models.
[0063] Steps S101 to S106 of this embodiment demonstrate that by constructing a dual graph and using multi-source breadth-first search to obtain the topology hierarchy, topology flow constraints can be achieved. By performing band aggregation on all mesh cells based on the block thickness parameter and the topology hierarchy, and calculating the corresponding space-fill curve rank within each band based on the geometric center coordinates of the mesh cells, all mesh cells within the band are sorted in ascending order according to the space-fill curve rank. Then, based on the band number and the corresponding space-fill curve rank of each mesh cell, lexicographical sorting is performed on all mesh cells after ascending sorting within the band. This enhances geometric locality under topology flow constraints. By thickening the bands, the sorting granularity is matched with the hardware thread bundle and cache granularity, thereby improving the cache hit rate of the parallel processor, reducing the number of cross-cache line accesses, and improving the efficiency of memory bandwidth utilization. Finally, based on the rearrangement mapping relationship, the cell array and interface array in the unstructured mesh data are reordered in a consistent manner, which can reduce the computation time per step of the parallel processor and improve the overall simulation speed in scenarios such as large-scale flood simulation.
[0064] To explain in detail the principles of the technical solution of this application, the overall process of this application will be described below with reference to some specific embodiments. It is easy to understand that the following is an explanation of the technical principles of this application and should not be regarded as a limitation of this application.
[0065] This application aims to provide a computation acceleration reordering method for parallel processors, which enhances geometric locality under topological flow constraints and matches the sorting granularity with the hardware thread bundle and cache granularity by thickening the bands, thereby improving the cache hit rate of the target processor (such as GPU), reducing the number of cross-cache line accesses and improving the efficiency of memory bandwidth utilization, thereby reducing the computation time per step and achieving overall simulation acceleration.
[0066] Therefore, in this embodiment, a combined strategy of "macro-topological flow + micro-geometric clustering" is adopted: first, the topological hierarchy is obtained on the dual graph, and then the block thickness parameter is used. Adjacent levels are aggregated into bands, and local rearrangement is performed within each band using Hilbert curves. Finally, a consistent rearrangement is performed on the grid data and the associated interface data.
[0067] Please see Figure 2 , Figure 2 This is a schematic diagram of the overall process of an unstructured grid data rearrangement method based on cached block wavefront sorting provided in an embodiment of this application, as shown below. Figure 2 As shown, the overall implementation process of the unstructured grid data rearrangement method based on cached block wavefront sorting includes, but is not limited to, the following steps S201-S205: Step S201: Construct the dual graph; In practical implementation, flood simulation first requires discretizing the computational domain into either structured or unstructured meshes. However, since structured meshes are typically only suitable for areas with regular terrain, unstructured meshes are generally used in practical applications. Unstructured meshes contain three basic data structures: cells, interfaces, and nodes. Based on unstructured meshes, governing equations (generally shallow water equations used for flood simulation) can be solved.
[0068] After obtaining the unstructured mesh, a dual graph is constructed using cells as nodes and shared interfaces as edges. Specifically, the cell array has a length of The structure is given, and each interface Record the cell indexes on both sides and The construction of dual graphs follows these rules: for any internal interface (i.e. ),make , In the interface set Add undirected edges and and will join in adjacency list, join in The adjacency list is used to obtain the set of adjacent cells. Finally, based on the set of adjacent units... Construct the dual graph corresponding to the unstructured mesh of the flood simulation computation domain. .
[0069] Step S202, multi-source BFS calculation hierarchy; In the specific implementation, one or more source point unit sets are first determined based on the boundary type, inflow marker, or preset determination rules. Then based on the source point unit set In dual graphs Perform a multi-source breadth-first search to obtain each cell. Topology hierarchy .
[0070] Step S203, band convergence; In the specific implementation, the block thickness parameter is set. ( (a set of positive integers), band aggregation is performed on the cells based on the topological hierarchy, and the band number of each cell is calculated. .
[0071] Step S204, intra-band sorting; In this embodiment of the application, in order to maintain the geometric locality of grid cells within the same band, the Hilbert curve rank is calculated for each cell. And within each band, according to the Hilbert curve rank Sort the grid cells in ascending order. Within each band, during calculation, first determine the geometric center coordinates of the i-th cell. Normalization is mapped to a discrete grid, and then mapped by the Hilbert mapping function. Mapping discrete coordinates to obtain the integer rank In each band, by integer rank Sort the grid cells in ascending order.
[0072] Step S205, according to the band number of each unit Rank of space-filling curves Determine the final sorting.
[0073] In practical implementation, band numbers are used. Primary key, space-filling curve rank Using the secondary key, perform lexicographical sorting on all cells to obtain the cell rearrangement sequence. Furthermore, based on the unit rearrangement sequence Determine the rearrangement mapping relationship Finally, based on the rearranged mapping relationship Perform a consistent rearrangement of the cell array and the interface array.
[0074] It should be noted that this embodiment is only a brief illustrative description of the overall process of an unstructured grid data rearrangement method based on cached block wavefront sorting. Detailed descriptions of each step can be found in the relevant content of the foregoing embodiments, and will not be repeated here. It is understood that this application does not impose any limitations on this.
[0075] In this embodiment of the application, the objective function and evaluation index are as follows: To characterize cache line utilization of a target processor (e.g., a GPU), a metric for the number of cache lines spanned can be defined. Let the cache line capacity hold... Multiple elements of the same type (e.g., indexes or floating-point numbers), in some embodiments The set of units processed for each execution thread bundle (Warp). Define access set : ; in, This is the set of linear addresses that will be accessed in one computation corresponding to this warp; This is a mapping from cells to linear storage locations. The set of cache lines triggered by this warp. for: ; Where a is Any linear address / index element in the cache can be used to define the average number of cache lines. for: ; in, This is the expectation operator. This application reduces the number of layer switching by band thickening, and simultaneously reduces [the number of] band switching by in-band Hilbert clustering. The span, thereby reducing And improve cache reuse.
[0076] Regarding complexity and implementability: In some embodiments, the time complexity of constructing the dual graph is O(n log n). The time complexity of multi-source BFS is . The time complexity of Hilbert rank calculation is . The time complexity of sorting by composite key is O(n). Therefore, the overall time complexity of this application is O(n). The space complexity is This method can be executed once during the preprocessing stage and reused for multi-step time progression. In the complexity, N represents the number of grid cells and M represents the number of interfaces. That is, as the number of grid cells N and the number of interfaces M increase, the sorting time of traditional methods may increase explosively, while the sorting time of the method provided in this application increases gradually and controllably. It can efficiently support engineering applications such as flood simulation under large-scale unstructured grids, significantly improving the efficiency of large-scale data processing.
[0077] In addition, an experimental example is provided in this embodiment: please refer to Figure 13 , Figure 13 This is a schematic diagram of an unstructured triangular mesh urban flood example provided in an embodiment of this application, such as... Figure 13 As shown: Taking a city flood example with 1.1 million unstructured triangular grids (e.g.) Figure 13 As shown), compare natural order (unsorted), Hilbert sort, standard Wavefront sort, and our method Thick Wavefront (…). Speedup results of methods such as ) Figure 12 As shown), the method in this case is Thick Wavefront (…). Achieving a higher speedup ratio, where Thick Wavefront is used to characterize band thickening aggregation. A comparison diagram of the sparse structure of the adjacency matrix is shown (e.g.,...). Figures 9-11As shown in the figure, after rearrangement, non-zero elements are more concentrated near the diagonal, indicating that adjacency access is more localized. This means that when the GPU performs calculations based on this unstructured grid, it is easier to hit the cache, thereby improving the memory access and write efficiency. Compared with the natural sequence, the thickened wavefront rearrangement in this application can reduce the average step time and improve the computational acceleration effect while maintaining stable computation.
[0078] Compared with existing related technologies, this application has at least the following beneficial effects: (1) Please refer to Figures 3-5 , Figure 3 This is a schematic diagram of an unstructured mesh provided in an embodiment of this application. Figure 4 This is a schematic diagram of the WaveFront layering provided in the embodiments of this application. Figure 5 This is a schematic diagram of band thickening and fusion provided in an embodiment of this application. Figures 3-5 This paper presents a comparison of unstructured mesh layering in WaveFront and ThickWaveFront (band thickening aggregation) techniques, by... Figures 3-5 It can be seen that this application solves the problem of memory fragmentation and frequent cross-layer jumps caused by the excessively thin layers of the standard wavefront by calculating the topology hierarchy and aggregating the cell incoming bands based on the topology hierarchy and block thickness parameters. (2) Please refer to Figures 6-8 , Figure 6 This is a schematic diagram of the access path connecting the center points according to the unit number in the original sequence, provided by an embodiment of this application. Figure 7 This is a schematic diagram of the access path connecting the center points according to the cell number in the Thick Wavefront sequence, provided by an embodiment of this application. Figure 8 This is a schematic diagram of the access path connecting the center points according to the unit number in the Hilbert sequence, provided in an embodiment of this application. Figures 6-8 The comparison results of access paths connecting the center points by unit number are displayed. Figures 6-8 As can be seen, this application uses dual graphs to express connectivity, achieving natural adaptation to complex boundaries and hybrid meshes, and solving the problem that Hilbert sorting only considers the proximity relationship of spatial distance and cannot reflect the law of physical information propagation. (3) Using block thickness parameters Matches GPU thread bundle / cache line granularity to improve cache line payload and L2 reuse; (4) Please refer to Figures 9-11 , Figure 9 This is a schematic diagram of the non-zero structure of the front adjacency matrix rearranged in the original order, provided in an embodiment of this application. Figure 10 This is a schematic diagram of the non-zero adjacency matrix structure after rearranging in the Thick Wavefront order, provided in an embodiment of this application. Figure 11This is a schematic diagram of the non-zero adjacency matrix structure after rearranging under Hilbert order, provided in an embodiment of this application. Figures 9-11 This demonstrates a comparison of the non-zero structure (bandwidth) of the adjacency matrix before and after rearrangement, by... Figures 9-11 As can be seen, this application enables throughput computation to also obtain continuous memory access benefits by reordering the interface array in a consistent manner, and significantly reduces the bandwidth of the coefficient matrix. (5) Please refer to Figures 12-13 , Figure 12 This is a schematic diagram comparing the speedup ratios of different data rearrangement methods provided in the embodiments of this application on typical computational examples. Figures 12-13 It can be seen that, in the typical urban flood calculation example, the average step calculation is accelerated relative to the natural sequence.
[0079] In summary, this application proposes a method for unstructured mesh data rearrangement based on cache block wavefront sorting for parallel processor computation acceleration, belonging to the field of high-performance computing and numerical simulation acceleration technology, and particularly involving data layout optimization for unstructured mesh finite volume solvers for GPUs / many-core processors. This method addresses the problems of frequent cross-layer jumps and low cache line utilization caused by the random distribution of topological connections between unstructured mesh cells, by proposing to rearrange the topological hierarchy obtained from multi-source breadth-first search according to the thickness parameter. Block aggregation is performed, and geometric locality sorting is performed within each band using Hilbert space-filling curves. Furthermore, a consistent rearrangement is performed on the cell array and its associated interface array, thereby enhancing GPU cache reuse and improving the effective utilization of video memory bandwidth while maintaining topological flow constraints.
[0080] Please see Figure 14 This application also provides an unstructured grid data rearrangement device 1400 based on cached block wavefront sorting, which can implement the above method. The device includes the following modules: The dual graph construction module 1401 is used to acquire unstructured grid data of the flood simulation calculation area and construct a dual graph based on the unstructured grid data; The topology hierarchy calculation module 1402 is used to perform a multi-source breadth-first search on the dual graph based on the set of source nodes on the dual graph, so as to obtain the topology hierarchy of each grid cell in the unstructured grid data. The band aggregation module 1403 is used to perform band aggregation on all the grid cells based on preset block thickness parameters and the topology level of each grid cell, and to calculate the band number of each grid cell. The unit ascending sorting module 1404 is used to calculate the corresponding space filling curve rank according to the geometric center coordinates of each grid unit in each band, and to sort all grid units in the band in ascending order according to the space filling curve rank of each grid unit in the band. The unit lexicographical sorting module 1405 is used to perform lexicographical sorting on all the grid units after intra-band ascending sorting based on the band number and the corresponding space-filling curve rank of each grid unit, to obtain a unit rearrangement sequence, and to determine the rearrangement mapping relationship based on the unit rearrangement sequence. The array consistency rearrangement module 1406 is used to perform consistency rearrangement on the cell array and interface array in the unstructured grid data based on the rearrangement mapping relationship, and obtain a consistency rearrangement result.
[0081] It is understood that the content of the above method embodiments is applicable to the present device embodiments. The specific functions implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0082] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0083] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0084] Please see Figure 15 , Figure 15 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes: The processor 1501 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 1502 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1502 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1502 and is called and executed by the processor 1501 using the methods described in the embodiments of this application. The input / output interface 1503 is used to implement information input and output; The communication interface 1504 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 1505 transmits information between various components of the device (e.g., processor 1501, memory 1502, input / output interface 1503, and communication interface 1504); The processor 1501, memory 1502, input / output interface 1503 and communication interface 1504 are connected to each other within the device via bus 1505.
[0085] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0086] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0087] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0088] It is understood that the content of the above method embodiments is applicable to the embodiments of this program product. The specific functions implemented by the embodiments of this program product are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0089] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0090] This application provides a method and related device for rearranging unstructured grid data based on cache block wavefront sorting. It constructs a dual graph and uses multi-source breadth-first search to obtain the topological hierarchy, enabling topological flow constraints. By aggregating all grid cells based on block thickness parameters and the topological hierarchy, and calculating the corresponding space-fill curve rank within each band based on the geometric center coordinates of the grid cells, it sorts all grid cells within the band in ascending order according to the space-fill curve rank. Then, based on the band number and corresponding space-fill curve rank of each grid cell, it performs lexicographical sorting on all grid cells after ascending sorting within the band. This enhances geometric locality under topological flow constraints. By thickening the bands, it matches the sorting granularity with the hardware thread bundle and cache granularity, thereby improving the cache hit rate of parallel processors, reducing the number of cross-cache line accesses, and improving memory bandwidth utilization efficiency. Finally, based on the rearrangement mapping relationship, it performs consistent rearrangement of the cell array and interface array in the unstructured grid data, which can reduce the computation time per step of the parallel processor and improve the overall simulation speed in scenarios such as large-scale flood simulations.
[0091] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0092] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0093] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0094] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0095] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0096] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0097] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0098] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0099] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0100] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0101] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for rearranging unstructured grid data based on cached block wavefront sorting, characterized in that, The method includes the following steps: Obtain unstructured grid data of the flood simulation calculation area, and construct a dual graph based on the unstructured grid data; Based on the set of source nodes on the dual graph, a multi-source breadth-first search is performed on the dual graph to obtain the topological hierarchy of each grid cell in the unstructured grid data. Based on the preset block thickness parameters and the topology level of each grid cell, band aggregation is performed on all grid cells, and the band number of each grid cell is calculated. Within each band, the rank of the corresponding space-filling curve is calculated based on the geometric center coordinates of each grid cell within the band, and all grid cells within the band are sorted in ascending order based on the rank of the space-filling curve of each grid cell within the band. Based on the band number and the corresponding space-filling curve rank of each grid cell, all grid cells after intra-band ascending sort are sorted in lexicographical order to obtain a cell rearrangement sequence, and a rearrangement mapping relationship is determined based on the cell rearrangement sequence. Based on the rearrangement mapping relationship, the cell array and interface array in the unstructured mesh data are uniformly rearranged to obtain a uniform rearrangement result.
2. The method according to claim 1, characterized in that, The process of performing a multi-source breadth-first search on the dual graph, based on the set of source cells in the dual graph, to obtain the topological hierarchy of each grid cell in the unstructured grid data includes: The set of source point units on the dual graph is determined according to boundary determination conditions; wherein, the boundary determination conditions are boundary type, inflow marker, or preset determination rules; Based on the set of source nodes on the dual graph, a multi-source breadth-first search is performed on the dual graph to obtain the topological level of each grid cell in the unstructured grid data.
3. The method according to claim 1, characterized in that, Within each band, the rank of the corresponding space-filling curve is calculated based on the geometric center coordinates of each grid cell within the band, and all grid cells within the band are sorted in ascending order based on the rank of the space-filling curve of each grid cell within the band, including: Within each band, determine the geometric center coordinates of each grid cell within the band; The geometric center coordinates of each grid cell within the band are normalized and mapped to a discrete network to obtain the discrete coordinates corresponding to each grid cell; By mapping the discrete coordinates corresponding to each grid cell using a preset mapping function, the rank of the space-filling curve corresponding to each grid cell is obtained; Based on the space-fill curve rank of each grid cell within the band, all grid cells within the band are sorted in ascending order.
4. The method according to claim 1, characterized in that, The process of performing a consistent rearrangement of the cell arrays and interface arrays in the unstructured mesh data based on the rearranged mapping relationship to obtain a consistent rearrangement result includes: The cell array is sorted according to the rearrangement mapping relationship to obtain the cell array rearrangement result; Based on the rearrangement result of the unit array, the keywords of each interface in the interface array are constructed, and the interface array is sorted according to the keywords of each interface so that interfaces connecting the same band or adjacent bands are stored continuously in memory, thus obtaining the interface array rearrangement result. Based on the rearrangement results of the cell array and the interface array, the consistent rearrangement result is constructed.
5. The method according to claim 4, characterized in that, The method further includes: When constructing the keywords for each interface in the interface array, if an interface in the interface array is a boundary interface, then the band number and rearrangement position of the missing side unit of the boundary interface are processed using a preset sentinel value.
6. The method according to claim 1, characterized in that, After performing a consistent rearrangement of the cell array and interface array in the unstructured mesh data based on the rearrangement mapping relationship to obtain a consistent rearrangement result, the method further includes: Based on the consistent rearrangement results, the fluid dynamics control equations are numerically solved on the unstructured mesh.
7. A device for rearranging unstructured grid data based on cached block wavefront sorting, characterized in that, The device includes the following modules: The dual graph construction module is used to acquire unstructured grid data of the flood simulation calculation area and construct a dual graph based on the unstructured grid data; The topology hierarchy calculation module is used to perform a multi-source breadth-first search on the dual graph based on the set of source nodes on the dual graph, so as to obtain the topology hierarchy of each grid cell in the unstructured grid data. The band aggregation module is used to perform band aggregation on all the grid cells based on preset block thickness parameters and the topology level of each grid cell, and to calculate the band number of each grid cell. The unit ascending sorting module is used to calculate the corresponding space filling curve rank of each grid unit in each band based on the geometric center coordinates of each grid unit in the band, and to sort all grid units in the band in ascending order based on the space filling curve rank of each grid unit in the band. The unit lexicographical sorting module is used to perform lexicographical sorting on all the grid units after intra-band ascending sorting based on the band number and the corresponding space-filling curve rank of each grid unit, to obtain the unit rearrangement sequence, and to determine the rearrangement mapping relationship based on the unit rearrangement sequence. The array consistency rearrangement module is used to perform consistency rearrangement of the cell array and interface array in the unstructured grid data based on the rearrangement mapping relationship, and obtain the consistency rearrangement result.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.