Calculation method and system for CFD
By using a heterogeneous architecture of CPU and GPU, the central processing unit constructs the Jacobian matrix and transmits the partial derivative data to the graphics processor for storage. The graphics processor then performs iterative calculations, which solves the time-consuming problem caused by repeated copying of intermediate variables in Jacobian calculations and improves the efficiency of CFD solutions.
Patent Information
- Application Number
- CN202511205886.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-27
- Publication Date
- 2025-12-12
AI Technical Summary
In the process of performing Jacobi calculations related to CFD solving using heterogeneous architectures of CPU and GPU, it is necessary to recopy the updated intermediate variables at each iteration, which increases the program's time consumption.
The flow field is divided into multiple nodes by the central processing unit (CPU) and a unified Jacobian matrix is constructed. The first partial derivative data is transmitted to the graphics processing unit (GPU) for storage. During the iterative calculation process, the GPU reads and updates the data from the storage space, avoiding data transmission back to the CPU and reducing data interaction overhead.
It effectively eliminates the time overhead caused by data copying, improves the CFD solution efficiency under heterogeneous CPU and GPU architectures, and reduces program execution time.
Smart Images

Figure CN121116601A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computational fluid dynamics engineering, and in particular to a computational method and system for CFD. Background Technology
[0002] Computational Fluid Dynamics (CFD), as an important tool for research and design in engineering, has been widely applied in various industries such as aerospace, automotive, energy engineering, environmental engineering, and marine engineering. CFD uses numerical methods to solve the governing equations of fluid dynamics (such as the continuity equation, momentum equation, and energy conservation equation), simulating fluid motion and heat transfer to help engineers predict and optimize performance in complex physical scenarios. As industrial demands for aerodynamic performance optimization, energy efficiency improvement, and environmental impact assessment continue to increase, the application scope and complexity of CFD technology are also constantly expanding.
[0003] Recent advancements in hardware technology have provided new computing solutions, namely leveraging the massively parallel computing capabilities of GPUs (Graphics Processing Units) to accelerate the CFD solution process. GPUs, with thousands of computing cores, can perform intensive floating-point operations in numerical computations, making them ideal for mesh processing and iterative solution tasks in CFD. By transferring the computationally intensive parts of the CFD solver (such as solving linear equations or flow field iterations) from the traditional CPU to the GPU, CFD software can achieve computational efficiency improvements of several times or even tens of times. This design, which integrates CPU and GPU workflows, is called a CPU-GPU heterogeneous architecture.
[0004] Figure 1 A schematic diagram illustrating CFD solving using a heterogeneous architecture of CPU and GPU is shown. (Refer to...) Figure 1 As shown, in the CFD solution process, the CPU is used for flow field preprocessing (including parameter reading and meshing of flow field data), and transmits the mesh data obtained from the flow field preprocessing to the GPU. The GPU is used for iterative calculations, and after the iteration is completed, the results of the iterative calculations are transmitted to the CPU, so that the CPU can perform flow field postprocessing (including further analysis of the flow field data).
[0005] In GPU optimization, data transfer between the CPU and GPU has always been a major performance bottleneck, involving physical factors such as bandwidth and latency, which will not be discussed here. The most direct factors affecting transfer performance are the number of data copies, the size and type of data being transferred, and the continuity of the data.
[0006] In iterative computation on a GPU, the Jacobian, as an intermediate variable generated during the computation, participates in subsequent calculations after undergoing multiple calculations. Because its value changes during the computation process, and may be changed multiple times, these intermediate variables are subject to change during computation. Therefore, a single data transfer from the CPU to the GPU cannot solve the problem. However, copying the data every time the variable value changes would undoubtedly cause the program's execution time to increase dramatically.
[0007] There is currently no effective solution to the technical problem of time-consuming program execution caused by recopying updated intermediate variables in each iteration during the iterative process of Jacobi calculation related to CFD solving using heterogeneous CPU and GPU architectures. Summary of the Invention
[0008] The embodiments of this disclosure provide a computational method for CFD, which at least solves the technical problem in the prior art that in the iterative process of using heterogeneous architectures of CPU and GPU to perform Jacobian calculations related to CFD solving, it is necessary to recopy the updated intermediate variables at each iteration, which leads to time consumption in the program.
[0009] According to one aspect of the present disclosure, a computational method for CFD is provided, comprising: a central processing unit (CPU) dividing a flow field into multiple nodes, and defining input variables and output variables corresponding to each node and the computational function according to a predefined computational function related to CFD; the CPU constructing a unified Jacobian matrix based on the input variables and output variables corresponding to the multiple nodes, wherein the Jacobian matrix is associated with the partial derivatives of the output variables of the multiple nodes relative to the input variables; the CPU transmitting first partial derivative data associated with the Jacobian matrix to a graphics processing unit (GPU); the GPU storing the first partial derivative data in its storage space; during iterative computation corresponding to the multiple nodes, the GPU reading the first partial derivative data from the storage space for iterative computation, and updating the corresponding first partial derivative data in the storage space according to the results of each round of iterative computation for the next round of iterative computation; and after completing the iterative computation process, the GPU transmitting the results of the iterative computation to the CPU.
[0010] According to another aspect of the embodiments of this disclosure, a CFD computing system based on a central processing unit (CPU) and a graphics processing unit (GPU) is also provided, comprising a CPU and a GPU, wherein the CPU is configured to: divide a flow field into multiple nodes, and define input variables and output variables corresponding to each node and the predefined CFD-related computing function; construct a unified Jacobian matrix based on the input variables and output variables corresponding to the multiple nodes, wherein the Jacobian matrix is associated with the partial derivatives of the output variables of the multiple nodes relative to the input variables; and transmit a first partial derivative data associated with the Jacobian matrix to the GPU, wherein the GPU is configured to: store the first partial derivative data in the GPU's storage space; during iterative computing corresponding to the multiple nodes, read the first partial derivative data from the storage space for iterative computing, and update the corresponding first partial derivative data in the storage space according to the results of each round of iterative computing for the next round of iterative computing; and after completing the iterative computing process, transmit the results of the iterative computing to the CPU.
[0011] In view of this, for flow fields and multiphysics coupling scenarios in complex geometric domains, the central processing unit first divides the flow field into n nodes V1 to V2 based on existing unstructured mesh technology. n The CPU defines the input and output variables of each node corresponding to the predefined CFD-related calculation functions (such as finite volume solvers, turbulence model equations, etc.). Further, the CPU constructs a unified Jacobian matrix based on the input and output variables corresponding to the multiple nodes and transmits the first partial derivative data associated with the Jacobian matrix to the GPU. This provides a structured data foundation for the GPU to perform parallel iterative calculations based on this matrix. Upon receiving the first partial derivative data, the GPU stores it in its own storage space, reducing data interaction overhead with the CPU. Subsequently, the GPU initiates iterative calculations for all nodes (such as flow field convergence solutions based on implicit algorithms, multiphysics coupling iterations). In each iteration, the GPU reads the first partial derivative data from its own storage space, solves the flow field equations for each node using a parallel computing kernel function, and then stores the updated first partial derivative data in its own storage space in real time based on the calculation results of the current iteration (such as residual correction values), ensuring the accuracy of the partial derivative relationships required for the next iteration without needing to send the data back to the CPU. Furthermore, it ensures that the graphics processor can directly read from its own storage space during the next iteration of calculation, without having to copy it from the CPU again, effectively eliminating the time overhead caused by data copying.
[0012] Therefore, in the iterative process of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, the GPU stores the intermediate variables updated in each iteration in its pre-allocated memory space, eliminating the need to send them back to the CPU. In the next iteration, the GPU directly reads the updated intermediate variables from its own memory space, without needing to copy them back to the CPU, thus saving program time. This further solves the technical problem in existing technologies where it is necessary to recopy the updated intermediate variables in each iteration of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, leading to time consumption. Attached Figure Description
[0013] The accompanying drawings, which are included to provide a further understanding of this disclosure and form part of this application, illustrate exemplary embodiments of this disclosure and are used to explain this disclosure, but do not constitute an undue limitation of this disclosure. In the drawings:
[0014] Figure 1 This is a schematic diagram illustrating a CFD calculation method according to Embodiment 1 of this disclosure, which uses a CPU and GPU heterogeneous architecture for CFD solving.
[0015] Figure 2 This is a hardware structure block diagram for implementing the computing device according to Embodiment 1 of this disclosure;
[0016] Figure 3 This is a flowchart illustrating a calculation method for CFD according to Embodiment 1 of this disclosure;
[0017] Figure 4 This is a schematic diagram of the flow field partitioning nodes according to Embodiment 1 of this disclosure, which describes a calculation method for CFD.
[0018] Figure 5 This is a schematic diagram of the overall structure of the Jacobian matrix in a calculation method for CFD according to Embodiment 1 of this disclosure;
[0019] Figure 6 This is a schematic diagram showing the corresponding positions of input and output variables in the Jacobian matrix of a calculation method for CFD according to Embodiment 1 of this disclosure;
[0020] Figure 7 This is a schematic diagram of the internal structure of the Jacobian matrix in a calculation method for CFD according to Embodiment 1 of this disclosure; and
[0021] Figure 8 This is a schematic diagram of the overall iterative process of a computational method for CFD according to Embodiment 1 of this disclosure. Detailed Implementation
[0022] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this disclosure.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure 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 disclosure 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 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.
[0024] Example 1
[0025] According to this embodiment, a computational method embodiment for CFD is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.
[0026] The method embodiments provided in this example can be executed on computing devices with CUP-GUP heterogeneous architectures. Figure 2 A hardware block diagram of a computing device for implementing a computational method for CFD is shown. Figure 2 As shown, a computing device may include a motherboard and a computing card. The motherboard may house a CPU (Central Processing Unit), memory for storing data, and input / output interfaces; the computing card may include a GPU (Graphics Processing Unit). The memory is connected to the processor via a bus. Those skilled in the art will understand that... Figure 2 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, a computing device may also include... Figure 2 The more or fewer components shown, or having the same Figure 2 The different configurations shown.
[0027] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element in a computing device. As involved in the embodiments of this disclosure, the data processing circuits serve as processor control (e.g., selection of a variable resistor termination path connected to an interface).
[0028] The memory can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to a CFD calculation method in one embodiment of this disclosure. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the aforementioned application program and a CFD calculation method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the computing device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0029] It should be noted here that, in some optional embodiments, the above... Figure 2 The computing device shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 2 This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computing devices.
[0030] Under the aforementioned operating environment, according to the first aspect of this embodiment, a computational method for CFD is provided, which consists of... Figure 2 The CPU (Central Processing Unit) and GPU (Graphics Processing Unit) shown are implemented together. Figure 3 A flowchart illustrating the method is shown below. (Refer to...) Figure 3 As shown, the method includes:
[0031] S302: The central processing unit divides the flow field into multiple nodes and defines the input and output variables of each node corresponding to the predefined CFD-related calculation function.
[0032] S304: The central processing unit constructs a unified Jacobian matrix based on the input variables and output variables corresponding to the plurality of nodes, wherein the Jacobian matrix is related to the partial derivatives of the output variables of the plurality of nodes with respect to the input variables;
[0033] S306: The central processing unit transmits the first partial derivative data associated with the Jacobian matrix to the graphics processing unit;
[0034] S308: The graphics processor stores the first partial derivative data in the graphics processor's storage space;
[0035] S310: During the iterative calculation process corresponding to the plurality of nodes, the graphics processor reads the first partial derivative data from the storage space for iterative calculation, and updates the corresponding first partial derivative data in the storage space according to the results of each round of iterative calculation for the next round of iterative calculation.
[0036] S312: After completing the iterative calculation process, the graphics processor transmits the result of the iterative calculation to the central processing unit.
[0037] Specifically, refer to Figure 4 As shown, for flow fields and multiphysics coupling scenarios in complex geometric domains, the central processing unit first divides the flow field into n nodes V1 to V2 based on existing unstructured mesh technology. n The nodes are used to characterize fluid state parameters at different spatial locations in the flow field; and according to predefined CFD-related calculation functions (such as finite volume method solvers, turbulence model equations, etc.), the input and output variables corresponding to each node and the calculation function are defined (corresponding to step S302). Specifically, the input variables corresponding to each node are defined, such as the conserved variable vector Q (Q is a 5×1 vector, e.g., Q1 = {q...}). 1-1 ,q 2-1 ,q 3-1 ,q 4-1 ,q 5-1 Each variable in}) is defined as an input variable. For node V1, there are 5 corresponding input variables: q 1-1 q 2-1 q 3-1 q 4-1 q 5-1 For node V2, there are 5 input variables, namely: q 1-2 q 2-2 q 3-2 q 4-2 q 5-2 And so on, for node V n It has 5 corresponding input variables, namely: q 1-n q2-n q 3-n q 4-n q 5-n This allows for the configuration of input variables for all nodes. The output variables for each node are defined, such as the flux vector F (where F is a 5×1 vector, e.g., F1 = {f...}). 1-1 ,f 2-1 ,f 3-1 ,f 4-1 ,f 5-1 Each variable in}) is defined as an output variable. For node V1, there are 5 output variables: f 1-1 f 2-1 f 3-1 f 4-1 f 5-1 For node V2, there are 5 output variables, namely: f 1-2 f 2-2 f 3-2 f 4-2 f 5-2 And so on, for node V n It has 5 output variables, namely: f 1-n f 2-n f 3-n f 4-n f 5-n This enables the configuration of output variables for all nodes, thus building a basic data framework for subsequent flow field iterative calculations.
[0038] Specifically, taking the aerospace industry as an example, this paper explains the physical meaning of each variable in the conserved variable vector Q and flux vector F in CFD calculations:
[0039] In the aerospace field (e.g., aerodynamic design of aircraft / rockets, flow field analysis within engines), the core task of CFD is to solve the Navier-Stokes (NS) equations describing the flow of air (or other working fluids). The NS equations are essentially the mathematical expression of the laws of conservation of mass, momentum, and energy in fluids. The conserved variable vector Q represents the state variables of a fluid element at a specific node in the flow field; these are the fundamental unknowns in solving the NS equations. In three-dimensional compressible flow, the conserved variable vector Q includes five conserved variables, specifically: q 1-i : Mass density, which is the mass of fluid per unit volume; q 2-i : Momentum density in the x-direction, a measure of the strength of fluid motion in the x-direction; q 3-i : Momentum density in the y-direction, a measure of the strength of fluid motion in the y-direction; q 4-i : Momentum density in the z-direction, a measure of the strength of fluid motion in the z-direction; q 5-iTotal energy density is the total energy of the fluid per unit volume. The suffix i in the subscripts of the conserved variables is used to distinguish nodes. When the node is V1, i = 1; when the node is V2, i = 2, and so on.
[0040] The flux vector F represents the rate of change or flux of the conserved variable vector Q at a specific node in the flow field. It is calculated by substituting Q into a predefined computational function (the core of which is the spatial discretization scheme of the Navier-Stokes equations, such as the flux calculation function in the finite volume method). The flux vector F includes five variables: f... 1-i Mass flux, the mass flow rate through a unit area per unit time; f 2-i : Momentum flux in the x-direction, used to describe the transport of momentum by pressure and viscous stress in the x-direction; f 3-i : Momentum flux in the y-direction, used to describe the transport of momentum by pressure and viscous stress in the y-direction (i.e., force in the y-direction); f 4-i : z-direction momentum flux, used to describe the transport of momentum (i.e., z-direction force) by pressure and viscous stress in the z-direction; f 5-i Total energy flux is used to describe the transport of total energy by heat conduction, pressure work, and viscous dissipation. The suffix 'i' in the subscripts of each flux vector is used to distinguish nodes; when the node is V1, i = 1; when the node is V2, i = 2, and so on.
[0041] In CFD solving, the core objective is to find a set of conserved variable vectors Q such that the flux vector F calculated based on these Qs throughout the flow field satisfies the discretized Navier-Stokes equations (usually by making the residuals approach zero). Therefore, each variable in the conserved variable vector Q at each node is defined as an input variable, and each variable in the flux vector F is defined as an output variable. For example, for node V1, there are five corresponding input variables: the mass density q of node V1. 1-1 The momentum density q in the x-direction of node V1 2-1 The momentum density q in the y-direction of node V1 3-1 The momentum density q in the z-direction of node V1 4-1 The total energy density q of node V1 5-1 It has 5 output variables, namely: the mass flux f calculated from the states of node V1 and its neighbors. 1-1 The momentum flux f in the x-direction of node V1 2-1 The momentum flux f in the y-direction of node V1 3-1 The momentum flux f in the z-direction of node V1 4-1 The total energy flux f of node V1 5-1 .
[0042] It is important to note that in other industries (such as wind resistance / downforce analysis in the automotive industry, internal flow field simulation of turbomachinery and combustion chamber simulation in energy engineering, atmospheric / water pollution diffusion in environmental engineering, and ship hydrodynamics in marine engineering), the core physical laws of CFD (mass, momentum, and energy conservation) are the same. Therefore, the basic definitions and physical meanings of the conservation variable vector Q and flux vector F are also largely consistent, with slight differences due to different application scenarios.
[0043] Furthermore, the central processing unit is based on Figure 4 The output and input variables of the n nodes shown are used to construct a unified Jacobian matrix (corresponding to step S304), and its overall structure is as follows. Figure 5 As shown, it consists of n×n matrix blocks (i.e., j 1,1 j 1,2 ~j n,n Composed of, due to Figure 4 Nodes in the model influence themselves and other nodes. Each node has 5 output variables and 5 input variables. Therefore, each influence of a node on itself and other nodes can be represented by a 5×5 Jacobian matrix, forming a Jacobian matrix with 5×5×n rows and columns. Figure 5 Each matrix block in the array is 5×5 in size, that is, matrix block j 1,1 The size is 5×5, and the matrix block j 1,2 The size is also 5×5, and so on, matrix block j n,n The size is also 5×5. Therefore, the constructed Jacobian matrix uses matrix blocks to represent the effect of a node on itself (e.g., matrix block j). 1,1 The partial derivatives of the output variable of node V1 with respect to the input variable) and the interactions between different nodes (e.g., j) 1,2 (The partial derivative of the output variable of node V2 with respect to the input variable of node V1).
[0044] Then, the central processing unit transmits the first partial derivative data associated with the Jacobian matrix (including the partial derivative values of the output variables of the nodes themselves with respect to the input variables, as well as the partial derivative values of the output variables of different nodes with respect to the input variables) to the graphics processing unit (corresponding to step S306). This provides a structured data foundation for the graphics processing unit to perform parallel iterative calculations based on this first partial derivative data.
[0045] Secondly, after receiving the first partial derivative data, the graphics processor stores it in its own storage space (corresponding to step S308), providing data support for subsequent iterative calculations to retrieve the corresponding partial derivative data from its own storage space, thereby reducing the data interaction overhead with the central processing unit. Subsequently, the graphics processor initiates an iterative calculation process for all nodes (such as flow field convergence solution based on implicit algorithms, multiphysics coupling iteration). In each iteration: the graphics processor reads the first partial derivative data from its own storage space, solves the flow field equations for each node using a parallel computing kernel function, and then, based on the calculation results of the current round (such as residual correction values), stores the updated first partial derivative data in its own storage space in real time, ensuring the accuracy of the partial derivative relationships required for the next round of calculation without needing to send it back to the CPU. Furthermore, this ensures that the graphics processor can directly read the updated first partial derivative data from its own storage space in the next iteration, without needing to copy it back to the CPU, effectively eliminating the time overhead caused by data copying (corresponding to step S310).
[0046] Finally, when the iterative calculation meets the preset convergence conditions (such as the residual being less than the threshold or the number of iterations reaching the preset upper limit), the graphics processor terminates the calculation and transmits the partial derivative data updated in each round of the iteration process (including the partial derivative update values of self-coupling and cross-node coupling of each node, the partial derivative data in the final convergence state, etc.) back to the central processing unit (corresponding to step S312).
[0047] As mentioned in the background section, data transfer between the CPU and GPU has always been a major performance bottleneck in GPU optimization, involving physical factors such as bandwidth and latency, which will not be discussed here. The most direct factors affecting transfer performance are the number of data copies, the size and type of the transferred data, and the continuity of the data. In iterative GPU computation, the Jacobian calculation, as an intermediate variable generated during computation, participates in subsequent calculations after undergoing multiple calculations. Because its value changes during the computation process, and may be changed multiple times, these intermediate variables will change during the computation, and therefore cannot be solved by a single transfer from the CPU to the GPU. However, copying the data every time the variable value changes would undoubtedly lead to a sharp increase in program execution time.
[0048] In view of this, for flow fields and multiphysics coupling scenarios in complex geometric domains, the central processing unit first divides the flow field into n nodes V1 to V2 based on existing unstructured mesh technology. nThe CPU defines the input and output variables of each node corresponding to the predefined CFD-related calculation functions (such as finite volume solvers, turbulence model equations, etc.). Further, the CPU constructs a unified Jacobian matrix based on the input and output variables corresponding to the multiple nodes and transmits the first partial derivative data associated with the Jacobian matrix to the GPU. This provides a structured data foundation for the GPU to perform parallel iterative calculations based on this matrix. Upon receiving the first partial derivative data, the GPU stores it in its own storage space, reducing data interaction overhead with the CPU. Subsequently, the GPU initiates iterative calculations for all nodes (such as flow field convergence solutions based on implicit algorithms, multiphysics coupling iterations). In each iteration, the GPU reads the first partial derivative data from its own storage space, solves the flow field equations for each node using a parallel computing kernel function, and then stores the updated first partial derivative data in its own storage space in real time based on the calculation results of the current iteration (such as residual correction values), ensuring the accuracy of the partial derivative relationships required for the next iteration without needing to send the data back to the CPU. Furthermore, it ensures that the graphics processor can directly read from its own storage space during the next iteration of calculation, without having to copy it from the CPU again, effectively eliminating the time overhead caused by data copying.
[0049] Therefore, in the iterative process of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, the GPU stores the intermediate variables updated in each iteration in its pre-allocated memory space, eliminating the need to send them back to the CPU. In the next iteration, the GPU directly reads the updated intermediate variables from its own memory space, without needing to copy them back to the CPU, thus saving program time. This further solves the technical problem in existing technologies where it is necessary to recopy the updated intermediate variables in each iteration of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, leading to time consumption.
[0050] Optionally, the operation of constructing a unified Jacobian matrix based on the input and output variables corresponding to the plurality of nodes includes: mapping the output variables of the plurality of nodes to each position of the Jacobian matrix in a first direction, wherein the positions corresponding to the output variables of the same node are arranged sequentially adjacent; mapping the input variables of the plurality of nodes to each position of the Jacobian matrix in a second direction, wherein the positions corresponding to the input variables of the same node are arranged sequentially adjacent; and using the partial derivatives between the output variables arranged in the first direction and the input variables arranged in the second direction as elements at the corresponding positions of the Jacobian matrix.
[0051] In an embodiment of the present invention, the central processing unit maps the output variables corresponding to the n nodes sequentially along a first direction (e.g., the row direction) to the row dimension of the Jacobian matrix, wherein the position of each element in the Jacobian matrix corresponds one-to-one with the number of all output variables. For example, suppose there are three nodes, V1, V2, and V3, where the output variables of V1 include f 1-1 f 2-1 f 3-1 f 4-1 f 5-1 The output variables of V2 include f 1-2 f 2-2 f 3-2 f 4-2 f 5-2 The output variables of V3 include f 1-3 f 2-3 f 3-3 f 4-3 f 5-3 Therefore, these three nodes contain a total of 15 output variables. These 15 output variables are then mapped to the positions of each row in the Jacobian matrix along the first direction (row direction), with the output variables of the same node arranged sequentially adjacent to each other. (Reference) Figure 6 The Jacobian matrix shown is 5×5×3, and the output variable f of node V1 is... 1-1 The first position of the first row of the Jacobian matrix (i.e. Figure 6 Chinese f 1-1 (Corresponding to the position indicated by the arrow in the first row), then the second output variable f of node V1 is... 2-1 The second position in the first row of the Jacobian matrix (i.e. Figure 6 Chinese f 2-1 (The arrows point to the positions in the first row) and so on, until the last output variable f of node V1 is reached. 5-1 This corresponds to the fifth position in the first row of the Jacobian matrix. Next, each output variable of node V2 is mapped to a subsequent position in the first row of the Jacobian matrix (i.e., the positions after the fifth position), until the last output variable f of node V2 is mapped. 5-2 This corresponds to the tenth position in the first row of the Jacobian matrix. Next, each output variable of node V3 is mapped to one of the remaining positions in the first row of the Jacobian matrix after the tenth position, until the last output variable f of node V3 is mapped. 5-3 The last position of the first row of the Jacobian matrix (i.e. Figure 6 Chinese f 5-3 The positions in the first row are corresponding to the positions indicated by the arrows. Similarly, following the correspondence in the first row, the 15 output variables are assigned to the positions in the other rows of the Jacobian matrix (i.e., the second to the last row).
[0052] Simultaneously, the central processing unit maps the input variables corresponding to the n nodes sequentially along the second direction (e.g., the column direction) to the column dimension of the Jacobian matrix, where the position of each element in the Jacobian matrix corresponds one-to-one with the number of all input variables. For example, continuing with the above setting of three nodes V1, V2, and V3, the input variables of V1 include q 1-1 q 2-1 q 3-1 q 4-1 q 5-1 The input variables of V2 include q 1-2 q 2-2 q 3-2 q 4-2 q 5-2 The input variables for V3 include q. 1-3 q 2-3 q 3-3 q 4-3 q 5-3 Therefore, these three nodes contain a total of 15 input variables. These 15 input variables are then mapped to the positions of each column of the Jacobian matrix along the second direction (column direction), with the positions corresponding to the input variables of the same node arranged sequentially adjacent to each other. (Continue to reference...) Figure 6 The displayed Jacobian matrix is of size 5×5×3, representing the input variable q of node V1. 1-1 The first position of the first column of the Jacobian matrix (i.e. Figure 6 Chinese q 1-1 (Corresponding to the position in the first column indicated by the arrow), then the second input variable q of node V1 is... 2-1 The second position in the first column of the Jacobian matrix (i.e. Figure 6 Chinese q 2-1 (Based on the positions indicated by the arrows in the first column), and so on, until the last input variable q of node V1 is reached. 5-1 This corresponds to the fifth position in the first column of the Jacobian matrix. Next, each input variable of node V2 is mapped to a subsequent position in the first column of the Jacobian matrix (i.e., the positions after the fifth position), until the last input variable q of node V2 is mapped. 5-2 This corresponds to the tenth position in the first column of the Jacobian matrix. Next, each input variable of node V3 is mapped to a position after the tenth in the first column of the Jacobian matrix, until the last input variable f of node V3 is mapped. 5-3 The last position of the first column of the Jacobian matrix (i.e. Figure 6 Chinese q 5-3The positions (pointed to by the arrows in the first column) correspond to each other. Similarly, following the correspondence in the first column, the 15 input variables mentioned above are respectively matched with the positions in the other columns (i.e., the second to the last columns) of the Jacobian matrix.
[0053] It is understandable that the above-mentioned, such as Figure 6 The first position in the first row of the 5×5×3 Jacobian matrix shown corresponds to the output variable f. 1-1 and input variable q 1-1 The second position in the first row of the Jacobian matrix corresponds to the output variable f. 2-1 and input variable q 1-1 The fifth position in the first row of the Jacobian matrix corresponds to the output variable f. 5-1 and input variable q 1-1 The tenth position in the first row of this Jacobian matrix corresponds to the output variable f. 5-2 and input variable q 1-1 The last position in the first row of the Jacobian matrix corresponds to the output variable f. 5-3 and input variable q 1-1 The first position in the first column of the Jacobian matrix corresponds to the output variable f. 1-1 and input variable q 1-1 The second position in the first column of the Jacobian matrix corresponds to the output variable f. 1-1 and input variable q 2-1 The fifth position in the first column of the Jacobian matrix corresponds to the output variable f. 1-1 and input variable q 5-1 The tenth position in the first column of the Jacobian matrix corresponds to the output variable f. 1-1 and input variable q 5-2 The last position in the first column of the Jacobian matrix corresponds to the output variable f. 1-1 and input variable q 5-3 The other positions in the Jacobian matrix follow the same pattern.
[0054] Furthermore, the partial derivatives of the output and input variables corresponding to each position in the Jacobian matrix are used as the elements at that position. (Reference) Figure 7As shown, continuing with n=3, the three nodes are designated V1, V2, and V3. Since each node V1, V2, and V3 has five output variables and five input variables, the central processing unit constructs a unified Jacobian matrix of size 5×5×3 based on the input and output variables corresponding to these three nodes. Each element in this Jacobian matrix represents the partial derivative of the output variable at that position with respect to the input variable. For example, the output variable corresponding to the first position (top left corner) in the Jacobian matrix is f. 1-1 The input variable corresponding to this position is q. 1-1 Then the f corresponding to this position 1-1 and q 1-1 partial derivatives As the element at that position, the output variable corresponding to the second position in the Jacobian matrix (the position immediately to the right of the first position) is f. 2-1 The input variable corresponding to this position is q. 1-1 Then the f corresponding to this position 2-1 and q 1-1 partial derivatives As the element at that position, and so on, we get... Figure 7 The Jacobian matrix shown.
[0055] Using the above method, a Jacobian matrix was constructed to quantify the influence of a unit change in an input variable on an output variable. This enables a unified representation of the partial derivative relationships between input and output variables of multiple nodes in a structured matrix form. This not only ensures the spatial correlation between input and output variables of the same node in the matrix, but also quantifies the influence of input variables on output variables between different nodes and within a node itself through the numerical values of matrix elements. This lays the data structure foundation for efficient parallel computing by graphics processors based on this matrix.
[0056] Optionally, the operation of the graphics processor storing the first partial derivative data in the graphics processor's storage space includes: extracting a plurality of first matrix blocks located on the diagonal from the Jacobian matrix, and storing the second partial derivative data of the first matrix blocks in the storage space, wherein the input variable and the corresponding output variable of a single first matrix block both correspond to the same node; extracting the third partial derivative data of a plurality of second matrix blocks located off-diagonal from the Jacobian matrix and storing it in the storage space, wherein the output variable of a single second matrix block corresponds to the same node, and the input variable of a single second matrix block also corresponds to the same node, but the input variable and the corresponding output variable of a single second matrix block correspond to different nodes.
[0057] Specifically, the graphics processor extracts multiple first matrix blocks located on the diagonal from the Jacobian matrix, referring to... Figure 5 As shown, each first matrix block represents the influence of a node on itself, including j 1,1 j 2,2 j 3,3 ~j n,n ; where the first matrix block j 1,1 For example, its corresponding input variables include q 1-1 q 2-1 q 3-1 q 4-1 q 5-1 All belong to node V1, first matrix block j 1,1 The corresponding output variables include f 1-1 f 2-1 f 3-1 f 4-1 f 5-1 They all belong to node V1; with the first matrix block j 2,2 For example, its corresponding input variables include q 1-2 q 2-2 q 3-2 q 4-2 q 5-2 All belong to node V2, first matrix block j 2,2 The corresponding output variables include f 1-2 f 2-2 f 3-2 f 4-2 f 5-2 They all belong to node V2; and so on, the first matrix block j n,n The corresponding input variables include q 1-n q 2-n q 3-n q 4-n q 5-n All belong to node V n The first matrix block j n,n The corresponding output variables include f 1-n f 2-n f 3-n f 4-n f 5-n They all belong to node V n Subsequently, the graphics processor stores the second partial derivative data (i.e., the partial derivative values of the output and input variables corresponding to each position of the first matrix block) included in the first matrix block in its own storage space (such as GPU memory), and maintains the association between each first matrix block and the corresponding node during storage.
[0058] Simultaneously, the graphics processor extracts multiple second matrix blocks located off-diagonally from the Jacobian matrix, referencing... Figure 5 As shown, the second matrix block can be represented as j excluding the diagonal position. 1,1 j 2,2 j 3,3 ~j n,n Other matrix blocks, such as j 1,2 j 2,1 j 3,2 And so on. Each second matrix block represents the influence of one node on another node; for example, second matrix block j... 1,2 Its corresponding output variables include f 1-2 f 2-2 f 3-2 f 4-2 f 5-2 All belong to node V2, second matrix block j 1,2 The corresponding input variables include q 1-1 q 2-1 q 3-1 q 4-1 q 5-1 All belong to node V1, therefore the second matrix block j 1,2 The influence of node V2 on node V1 is represented; the second matrix block j 2,1 Its corresponding output variables include f 1-1 f 2-1 f 3-1 f 4-1 f 5-1 All belong to node V1, second matrix block j 2,1 The corresponding input variables include q 1-2 q 2-2 q 3-2 q 4-2 q 5-2 All belong to node V2, therefore the second matrix block j 2,1 This characterizes the influence of node V1 on node V2, and so on, for the second matrix block j. n,1 This characterizes the relationship between node V1 and node V. n The impact, and the second matrix block j 1,n Characterizes node V n The impact on node V1. Subsequently, the graphics processor stores the third partial derivative data (i.e., the partial derivative values of the output and input variables corresponding to each position of the second matrix block) included in the second matrix block in its own storage space (such as GPU memory), and maintains the association between each second matrix block and the corresponding node during storage.
[0059] Thus, the graphics processor can selectively store partial derivative data that characterizes the influence of a node itself, so that it can be quickly accessed in "blocks" in subsequent iterative calculations, instead of being accessed frequently in "elements", saving the GPU time in accessing data.
[0060] Optionally, the graphics processor determines a first index corresponding to the first matrix block based on the node corresponding to the first matrix block.
[0061] Specifically, after storing the second partial derivative data of the first matrix block in the storage space, the graphics processor generates a unique first index for each first matrix block, based on the nodes associated with that first matrix block. This first index has a one-to-one correspondence with the nodes and can be directly mapped to the storage address of the first matrix block in the graphics processor's storage space. By converting the first index information of the corresponding node into a positioning code for the first matrix block, the second partial derivative data of the corresponding first matrix block can be quickly located using the first index. For example, refer to... Figure 5 As shown, the first matrix block j 1,1 By representing the influence of node V1 on itself, the first matrix block j can be determined. 1,1 The first index is 1-1; the first matrix block j 2,2 By representing the influence of node V2 on itself, the first matrix block j can be determined. 2,2 The first index is 2-2, and so on, the first matrix block j n,n Characterization node V n The effect on itself can then determine the first matrix block j. n,n The first index is nn.
[0062] Thus, the first index enables a direct association between the node and the storage location of the first matrix block, providing a fast location mechanism for high-frequency data calls during complex flow field iteration.
[0063] Optionally, during the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the same target node, determining the first matrix block corresponding to the target node in the storage space according to the first index, and reading the second partial derivative data corresponding to the first matrix block in the storage space for partial derivative calculation.
[0064] In an embodiment of the present invention, reference is made to... Figure 5 and Figure 7 As shown, when the graphics processor performs partial derivative calculations for node V1 in the flow field, it calculates the partial derivative based on the first matrix block j corresponding to node V1. 1,1Using the first index 1-1 in the storage space, quickly locate the first matrix block j corresponding to the node. 1,1 and read the first matrix block j 1,1 The corresponding second partial derivative data (i.e. Partial derivative calculations are performed (such as implicit solutions to flow field equations, residual corrections, etc.). When the graphics processor performs partial derivative calculations for node V2 in the flow field, it calculates the partial derivatives based on the first matrix block j corresponding to node V2. 2,2 Using the first index 2-2 in the storage space, quickly locate the first matrix block j corresponding to the node. 2,2 and read the first matrix block j 2,2 The corresponding second partial derivative data (i.e. Partial derivative calculations are performed (such as implicit solutions to flow field equations, residual corrections, etc.), and so on.
[0065] Thus, the second partial derivative data corresponding to the target node is quickly obtained through the first index, which is especially suitable for the characteristics of unstructured grids. It avoids traversing and searching the entire Jacobian matrix, and significantly improves the efficiency and computational focus of the graphics processor in accessing the partial derivative data of the node itself during the iteration process.
[0066] Optionally, the operation of extracting the third partial derivative data of a plurality of second matrix blocks located off-diagonally from the Jacobian matrix and storing it in the storage space includes: traversing the third matrix blocks located off-diagonally in the Jacobian matrix; and selecting a second matrix block as a non-zero matrix block from the third matrix block, and storing the third partial derivative data of the second matrix block in the storage space.
[0067] Specifically, the graphics processor traverses all third matrix blocks located off-diagonally within the Jacobian matrix. This application considers that when calculating the physical quantities of a node, the physical quantities and partial derivatives of that node and several nearby nodes are typically selected, meaning that there is no interaction between distant adjacent nodes, and a large number of matrix blocks have element values of zero. That is, referring to... Figure 5 As shown, when it is necessary to calculate the physical quantities of node V1, V1 is usually selected relative to itself and several nearby nodes (e.g., nodes V2, V3, V4, ..., V...). 10 The partial derivative data of V1 means that V1 is far from other neighboring nodes (i.e., V... 11 ~V n If there is no interaction between nodes V1 and V2, then it is used to characterize the interaction between node V1 and its more distant neighboring nodes V2. 11 ~V n The influence of the matrix block (i.e., matrix block j) 1,11 ~j 1,n The element values of ) are likely to be zero, which makes the Jacobian matrix exhibit sparse properties.
[0068] Therefore, before storing the off-diagonal matrix blocks obtained through traversal into the storage space, it is necessary to select a second matrix block from the third matrix block as a non-zero matrix block, and store the third partial derivative data of the second matrix block into the storage space. For details, please refer to [link to relevant documentation]. Figure 5 As shown, if a single third matrix block (e.g., third matrix block j) 1,n When at least one element in the third matrix block j is not zero, the graphics processor will then... 1,2 Select the second matrix block as the second matrix block, and store the third partial derivative data of the second matrix block in the storage space, while maintaining the storage of each third matrix block j. 1,2 The relationship between the node and the corresponding node.
[0069] Conversely, if a single third matrix block (e.g., third matrix block j) 7,n When every element in the third matrix j is zero, the graphics processor will not consider adding that third matrix block. 7,n Selected as the second matrix block, there is no need to store the third matrix block j. 7,n The partial derivative data.
[0070] Thus, by filtering non-zero matrix blocks, invalid storage of zero-value data is avoided, significantly saving GPU storage space. At the same time, considering the characteristics of unstructured meshes, only valid third partial derivative data is retained, providing efficient support for the rapid invocation of interactions between different nodes in subsequent iterative calculations, further improving the efficiency of complex flow field and multi-physics field coupled calculations.
[0071] Optionally, the graphics processor determines a second index corresponding to the second matrix block based on the nodes corresponding to the output variables of the second matrix block and the nodes corresponding to the input variables of the second matrix block.
[0072] Specifically, for each second matrix block, the graphics processor generates a unique second index based on the unique identifiers of the nodes associated with its output and input variables. This second index has a one-to-one mapping relationship with the nodes corresponding to the output and input variables, and can be directly mapped to the storage address of that second matrix block in the graphics processor's memory space (such as GPU memory). For example, refer to... Figure 5 and Figure 7 As shown, with the second matrix block j 1,2 For example, the second matrix block j 1,2 The output variables include: f 1-2 f 2-2 f 3-2 f 4-2 f 5-2 These output variables all belong to node V2, the second matrix block j 1,2The input variables include: q 1-1 q 2-1 q 3-1 q 4-1 q 5-1 Since these input variables all belong to node V1, the graphics processor can determine the relationship between node V2 and node V1 and the second matrix block j. 1,2 The corresponding second index is 1-2. Taking the second matrix block j... 2,1 For example, the second matrix block j 2,1 The output variables include: f 1-1 f 2-1 f 3-1 f 4-1 f 5-1 These output variables all belong to node V1, the second matrix block j 2,1 The input variables include: q 1-2 q 2-2 q 3-2 q 4-2 q 5-2 Since these input variables all belong to node V2, the graphics processor can determine the relationship between node V1 and node V2 and the second matrix block j. 2,1 The corresponding second index is 2-1, and so on, for the second matrix block j. n,1 The corresponding second index is n-1, and the second matrix block j 1,n The corresponding second index is 1-n.
[0073] By employing the above methods, the graphics processor can quickly locate the third partial derivative data of the corresponding second matrix block through the second index during iterative calculations. This significantly improves the efficiency of calling the third partial derivative data during iterative calculations and provides an efficient positioning mechanism for parallel solving of the coupling relationship between nodes in complex flow fields.
[0074] Optionally, during the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the output variable of the first target node and the input variable of the second target node, determining the corresponding second matrix block in the storage space according to the second index, and reading the third partial derivative data corresponding to the second matrix block in the storage space for partial derivative calculation.
[0075] In an embodiment of the present invention, reference is made to... Figure 5 and Figure 7 As shown, when the graphics processor performs partial derivative calculations for node V1 with respect to node V2 in the flow field, it calculates the partial derivative based on the second matrix block j that corresponds to both nodes V2 and V1. 1,2 Using the second index 1-2 in the storage space, quickly locate the second matrix block j.1,2 and read the second matrix block j 1,2 The corresponding third partial derivative data (i.e. Partial derivative calculations are performed (such as implicit solutions to flow field equations, residual corrections, etc.). When the graphics processor performs partial derivative calculations for node V1 with respect to node V2 in the flow field, it uses the second matrix block j corresponding to both nodes V1 and V2. 2,1 Using the second index 2-1 in the storage space, quickly locate the second matrix block j corresponding to the node. 2,1 and read the second matrix block j 2,1 The corresponding third partial derivative data (i.e. Partial derivative calculations are performed (such as implicit solutions to flow field equations, residual corrections, etc.), and so on.
[0076] Thus, the precise binding of "node pair - second matrix block" is achieved through the second index, avoiding redundant traversal of the entire Jacobian matrix; at the same time, it significantly improves the access efficiency of partial derivative data of interactions between different nodes, providing efficient support for parallel solution of densely associated nodes in complex flow fields.
[0077] Overall, such as Figure 8 As shown, the system flow of this application is based on a heterogeneous architecture of a central processing unit (CPU) and a graphics processing unit (GPU). Collaborative computation is achieved through a clear division of functions: the CPU, as the global control and preprocessing module, is responsible for parallel initialization, reading control parameters, reading unstructured mesh data of complex geometric domains and completing flow field node partitioning, coordinating multi-process communication through existing MPI technology, allocating system memory and GPU video memory resources, setting initial physical parameters and boundary conditions of the flow field to complete process initialization, and copying the basic data required for computation (such as node input variables and initial partial derivative data of the Jacobian matrix) to the GPU's memory. The CPU processes the logical connections between function contexts within the storage space. The GPU, as the core module of parallel computing, initiates iterative flow field calculations in the storage space based on the initial data transmitted from the CPU. It efficiently processes the partial derivative calculations of each node through parallel kernel functions and stores the updated partial derivative data in its own storage space in real time, without needing to send it back to the CPU. Simultaneously, it ensures that the GPU can directly read from its own storage space in the next iteration, without needing to copy it from the CPU again. Only after the iteration is complete is the final flow field calculation result sent back to the CPU. The CPU receives the result, generates complete flow field data, and outputs it as a flow field file suitable for engineering analysis. This division of labor fully leverages the advantages of heterogeneous architecture, adapting to the high-efficiency requirements of complex flow fields and multi-physics coupled calculations.
[0078] In addition, refer to Figure 2As shown, according to a second aspect of this embodiment, a memory is provided. The memory includes a stored program, wherein, during runtime, the method described in any of the above embodiments is executed by a central processing unit and / or a graphics processing unit.
[0079] Therefore, in the iterative process of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, the GPU stores the intermediate variables updated in each iteration in its pre-allocated memory space, eliminating the need to send them back to the CPU. In the next iteration, the GPU directly reads the updated intermediate variables from its own memory space, without needing to copy them back to the CPU, thus saving program time. This further solves the technical problem in existing technologies where it is necessary to recopy the updated intermediate variables in each iteration of Jacobian calculations related to CFD solving using a heterogeneous CPU and GPU architecture, leading to time consumption.
[0080] Example 2
[0081] This embodiment provides a CFD computing system based on a central processing unit (CPU) and a graphics processing unit (GPU), corresponding to the method described in Embodiment 1. The CFD computing system includes a CPU and a GPU, wherein the CPU is configured to: divide the flow field into multiple nodes, and define input and output variables corresponding to each node and the predefined CFD-related computing function; construct a unified Jacobian matrix based on the input and output variables corresponding to the multiple nodes, wherein the Jacobian matrix is associated with the partial derivatives of the output variables of the multiple nodes relative to the input variables; and transmit the first partial derivative data associated with the Jacobian matrix to the GPU, wherein the GPU is configured to: store the first partial derivative data in the GPU's storage space; during iterative calculations corresponding to the multiple nodes, read the first partial derivative data from the storage space for iterative calculations, and update the corresponding first partial derivative data in the storage space according to the results of each round of iterative calculations for the next round of iterative calculations; and after completing the iterative calculation process, transmit the results of the iterative calculations to the CPU.
[0082] Optionally, the operation of constructing a unified Jacobian matrix based on the input and output variables corresponding to the plurality of nodes includes: mapping the output variables of the plurality of nodes to each position of the Jacobian matrix in a first direction, wherein the positions corresponding to the output variables of the same node are arranged sequentially adjacent; mapping the input variables of the plurality of nodes to each position of the Jacobian matrix in a second direction, wherein the positions corresponding to the input variables of the same node are arranged sequentially adjacent; and using the partial derivatives between the output variables arranged in the first direction and the input variables arranged in the second direction as elements at the corresponding positions of the Jacobian matrix.
[0083] Optionally, the operation of storing the first partial derivative data in the storage space of the graphics processor includes: extracting a plurality of first matrix blocks located on the diagonal from the Jacobian matrix, and storing the second partial derivative data of the first matrix blocks in the storage space, wherein the input variable and the corresponding output variable of a single first matrix block correspond to the same node; extracting the third partial derivative data of a plurality of second matrix blocks located off-diagonal from the Jacobian matrix and storing it in the storage space, wherein the output variable of a single second matrix block corresponds to the same node, and the input variable of a single second matrix block also corresponds to the same node, but the input variable and the corresponding output variable of a single second matrix block correspond to different nodes.
[0084] Optionally, the graphics processor is further configured to: determine a first index corresponding to the first matrix block based on the node corresponding to the first matrix block.
[0085] Optionally, in the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the same target node, determining the first matrix block corresponding to the target node in the storage space according to the first index, and reading the second partial derivative data corresponding to the first matrix block in the storage space for partial derivative calculation.
[0086] Optionally, the operation of extracting the third partial derivative data of a plurality of second matrix blocks located off-diagonally from the Jacobian matrix and storing it in the storage space includes: traversing the third matrix blocks located off-diagonally in the Jacobian matrix; and selecting a second matrix block as a non-zero matrix block from the third matrix block, and storing the third partial derivative data of the second matrix block in the storage space.
[0087] Optionally, the graphics processor is further configured to: determine a second index corresponding to the second matrix block based on the nodes corresponding to the output variables of the second matrix block and the nodes corresponding to the input variables of the second matrix block.
[0088] Optionally, in the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the output variable of the first target node and the input variable of the second target node, determining the corresponding second matrix block in the storage space according to the second index, and reading the third partial derivative data corresponding to the second matrix block in the storage space for partial derivative calculation.
[0089] Therefore, in the iterative process of Jacobian calculations related to CFD solving using a heterogeneous architecture of a central processing unit (CPU) and a graphics processing unit (GPU), the GPU stores the intermediate variables updated in each iteration in its pre-allocated storage space, eliminating the need to send them back to the CPU. Furthermore, in the next iteration, the GPU directly reads the updated intermediate variables from its own storage space, avoiding the need to copy them back to the CPU, thus saving program time. This further solves the technical problem in existing technologies where it is necessary to copy the updated intermediate variables in each iteration of Jacobian calculations related to CFD solving using a heterogeneous architecture of a CPU and a GPU, resulting in time consumption.
[0090] It should be noted that the apparatus of Embodiment 2 and the method of Embodiment 1 belong to the same inventive concept, solve the same technical problem, and achieve the same technical effect. The system of Embodiment 2 can implement all the methods of Embodiment 1, and the similarities will not be repeated here.
[0091] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0092] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0093] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units 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 displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0094] The units described 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.
[0095] Furthermore, the functional units in the various embodiments of the present invention 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.
[0096] 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 the present invention, 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 several 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 described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0097] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A computational method for CFD, characterized in that, include: The central processing unit divides the flow field into multiple nodes and defines the input and output variables of each node corresponding to the predefined CFD-related calculation functions. The central processing unit constructs a unified Jacobian matrix based on the input and output variables corresponding to the plurality of nodes, wherein the Jacobian matrix is related to the partial derivatives of the output variables of the plurality of nodes with respect to the input variables; The central processing unit transmits the first partial derivative data associated with the Jacobian matrix to the graphics processing unit; The graphics processor stores the first partial derivative data in the graphics processor's storage space; During the iterative calculation process corresponding to the plurality of nodes, the graphics processor reads the first partial derivative data from the storage space for iterative calculation, and updates the corresponding first partial derivative data in the storage space according to the results of each round of iterative calculation for the next round of iterative calculation. After completing the iterative calculation process, the graphics processor transmits the results of the iterative calculation to the central processing unit.
2. The method according to claim 1, characterized in that, The operation of the central processing unit to construct a unified Jacobian matrix based on the input and output variables corresponding to the multiple nodes includes: The output variables of the plurality of nodes are mapped to the positions of the Jacobian matrix in a first direction, wherein the positions corresponding to the output variables of the same node are arranged sequentially adjacent to each other. The input variables of the plurality of nodes are mapped to the positions of the Jacobian matrix along a second direction, wherein the positions corresponding to the input variables of the same node are arranged sequentially adjacent to each other; and The partial derivatives between the output variables arranged in the first direction and the input variables arranged in the second direction are used as elements at the corresponding positions of the Jacobian matrix.
3. The method according to claim 2, characterized in that, The operation of the graphics processor storing the first partial derivative data in the graphics processor's storage space includes: Multiple first matrix blocks located on the diagonal are extracted from the Jacobian matrix, and the second partial derivative data of the first matrix blocks are stored in the storage space, wherein the input variables and the corresponding output variables of a single first matrix block correspond to the same node; The third partial derivative data of multiple second matrix blocks located off-diagonally are extracted from the Jacobian matrix and stored in the storage space, wherein the output variable corresponding to a single second matrix block corresponds to the same node, and the input variable corresponding to a single second matrix block also corresponds to the same node, but the input variable and the corresponding output variable of a single second matrix block correspond to different nodes.
4. The method according to claim 3, characterized in that, The method further includes: the graphics processor determining a first index corresponding to the first matrix block based on the node corresponding to the first matrix block.
5. The method according to claim 4, characterized in that, In the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the same target node, determining the first matrix block corresponding to the target node in the storage space according to the first index, and reading the second partial derivative data corresponding to the first matrix block in the storage space for partial derivative calculation.
6. The method according to claim 3, characterized in that, The operation of extracting the third partial derivative data of multiple off-diagonal second matrix blocks from the Jacobian matrix and storing them in the storage space includes: Traverse the third matrix block located off-diagonally within the Jacobian matrix; and Select a second matrix block from the third matrix block as a non-zero matrix block, and store the third partial derivative data of the second matrix block in the storage space.
7. The method according to claim 6, characterized in that, The method further includes: the graphics processor determining a second index corresponding to the second matrix block based on the nodes corresponding to the output variables of the second matrix block and the nodes corresponding to the input variables of the second matrix block.
8. The method according to claim 7, characterized in that, In the iterative calculation process corresponding to the plurality of nodes, the operation of reading the first partial derivative data from the storage space for iterative calculation includes: when performing partial derivative calculation for the output variable of the first target node and the input variable of the second target node, determining the corresponding second matrix block in the storage space according to the second index, and reading the third partial derivative data corresponding to the second matrix block in the storage space for partial derivative calculation.
9. A CFD computing system based on a central processing unit and a graphics processing unit, characterized in that, Including a central processing unit and a graphics processing unit, among which, The central processing unit is configured to: The flow field is divided into multiple nodes, and the input and output variables of each node are defined according to the predefined CFD-related calculation functions. Based on the input and output variables corresponding to the plurality of nodes, a unified Jacobian matrix is constructed, wherein the Jacobian matrix is related to the partial derivatives of the output variables of the plurality of nodes with respect to the input variables; and The first partial derivative data associated with the Jacobian matrix is transmitted to the graphics processor, and The graphics processor is configured to: The first partial derivative data is stored in the storage space of the graphics processor; During the iterative calculation process corresponding to the plurality of nodes, the first partial derivative data is read from the storage space for iterative calculation, and the corresponding first partial derivative data in the storage space is updated according to the results of each round of iterative calculation for the next round of iterative calculation; and After the iterative calculation process is completed, the result of the iterative calculation is transmitted to the central processing unit.
10. The system according to claim 9, characterized in that, The operation of constructing a unified Jacobian matrix based on the input and output variables corresponding to the multiple nodes includes: The output variables of the plurality of nodes are mapped to the positions of the Jacobian matrix in a first direction, wherein the positions corresponding to the output variables of the same node are arranged sequentially adjacent to each other. The input variables of the plurality of nodes are mapped to the positions of the Jacobian matrix along a second direction, wherein the positions corresponding to the input variables of the same node are arranged sequentially adjacent to each other; and The partial derivatives between the output variables arranged in the first direction and the input variables arranged in the second direction are used as elements at the corresponding positions of the Jacobian matrix.