OpenFOAM simulation method based on GPU acceleration, electronic equipment and readable medium
By converting the LDU matrix in OpenFOAM simulation to ELLPACK-R format and combining GPU acceleration and AMG-ILU adaptive preprocessor, the solution of linear equations in OpenFOAM simulation is optimized, solving the problem of low computational efficiency in existing technologies and achieving more efficient computational fluid dynamics simulation.
Patent Information
- Application Number
- CN202610227931.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-26
- Publication Date
- 2026-05-15
AI Technical Summary
In OpenFOAM simulations, solving linear equations accounts for about 80% of the program's execution time. The LDU format for storing sparse matrices has low access efficiency during iterative solving, leading to a decrease in computational performance, especially when dealing with large-scale sparse matrices.
A GPU-accelerated approach is adopted to convert the LDU matrix into ELLPACK-R format, transfer the data to GPU memory via CUDA API, optimize the iterative solution process using the AMG-ILU adaptive preprocessor, and improve computational efficiency by combining dynamic mesh generation and parallel computing optimization modules.
It significantly improves the computational efficiency and convergence speed of OpenFOAM simulation, reduces the overall solution time, increases the throughput of matrix-vector multiplication, and makes full use of multi-GPU resources, making it suitable for various computational fluid dynamics problems.
Smart Images

Figure CN122044657A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computational fluid dynamics technology, and in particular to a GPU-accelerated OpenFOAM simulation method, electronic device, and readable medium. Background Technology
[0002] Computational Fluid Dynamics (CFD) is an important tool for studying physical phenomena such as fluid flow, heat transfer, and chemical reactions. It is widely used in aerospace, energy and power, environmental engineering, nuclear energy system design, and many other fields. CFD simulation software is used to simulate and analyze physical phenomena such as fluid dynamics, heat transfer, and chemical reactions. These software programs solve the governing equations of fluid dynamics using numerical methods to analyze problems related to flow, heat transfer, and mass transfer.
[0003] OpenFOAM (Open Field Operation and Manipulation) is an open-source software widely used in computational fluid dynamics. It can simulate various physical phenomena such as fluid flow, heat transfer, chemical reactions, and particle flow. Its rich set of numerical methods and models allows users to customize and extend it according to their specific needs. In OpenFOAM's solution process, solving linear equations accounts for approximately 80% of the program's computation time, representing a core performance bottleneck limiting simulation efficiency. OpenFOAM uses the LDU format to store sparse matrices by default. While this format saves storage space by omitting many zero elements, it requires frequent access to matrix elements during iterative solutions, resulting in low access efficiency, especially when dealing with large-scale sparse matrices, which can easily lead to a degraded computational performance. Summary of the Invention
[0004] To alleviate, reduce, or eliminate the aforementioned technical problems, this application provides a GPU-accelerated OpenFOAM simulation method, electronic device, and readable medium, achieving higher parallel efficiency and faster convergence speed.
[0005] Firstly, this application provides a GPU-accelerated OpenFOAM simulation method, including: Read OpenFOAM mesh information and generate an LDU matrix; write a dedicated function to convert the LDU matrix into ELLPACK-R format. After generating an initial mesh based on the OpenFOAM mesh information, the initial mesh is dynamically divided according to the computing load of each GPU to balance the computing load of each GPU; the matrix and vector data in ELLPACK-R format are compressed, and the compressed data is transferred from CPU memory to the corresponding GPU memory through the CUDA API; an optimized CUDA kernel function is written, and matrix-vector multiplication in ELLPACK-R format is performed on the GPU according to the CUDA kernel function; The PCG solver is initialized on the GPU. The initialization process includes setting the initial solution vector, residual vector, and AMG-ILU adaptive preprocessor. The matrix in ELLPACK-R format is preprocessed by the AMG-ILU adaptive preprocessor, and then iterative calculations of the PCG solver are performed. After decompressing the iterative calculation results on the GPU, the results are transferred back to the CPU memory. A function is written to convert the decompressed solution vectors into an LDU matrix format that OpenFOAM can recognize. An OpenFOAM simulation is run, and the dynamic mesh generation strategy and the parameters of the PCG solver are dynamically adjusted based on the calculation results of the OpenFOAM simulation.
[0006] In one possible implementation, the step of writing a dedicated function to convert the LDU matrix into ELLPACK-R format includes: Iterate through each row of the LDU matrix and record the position, value, and number of non-zero elements in each row. Calculate the distribution of the number of non-zero elements in all rows, determine the base column number of the ELLPACK-R format based on the distribution of the number of non-zero elements, store the non-zero elements in the ELL main structure for rows with the number of non-zero elements within the range of the base column number, and store the non-zero elements in the additional CSR submatrix for rows with the number of non-zero elements exceeding the base column number. Sort the non-zero elements of the ELL master structure by column index to generate an array of non-zero element values, an array of column indices, and an array of row non-zero element counts. Append a CSR submatrix to generate a Value array, a Col_Index array, and a Row_Offsets array in standard CSR format.
[0007] In one possible implementation, the CUDA kernel function integrates a data decompression module and a parallel computing optimization module. The data decompression module is used to restore the compressed data in the GPU memory to the ELLPACK-R format, and the parallel computing optimization module is used to allocate computing resources according to the features of the ELL main structure and the additional CSR submatrix of the ELLPACK-R format.
[0008] In one possible implementation, the compression process employs a sparsity-based differential coding compression algorithm, encoding only the index differences and numerical values of non-zero elements; the transfer of the compressed data from CPU memory to the corresponding GPU memory via the CUDA API includes: Combine CUDA Streams to create two parallel streams, one for transmitting compressed data and the other for GPU initialization computation.
[0009] In one possible implementation, the dynamic meshing of the initial mesh based on the computational load of each GPU includes: The computational cost of the initial grid is evaluated. Subgrids in the initial grid whose computational load exceeds a first preset threshold are split and redistributed a second time.
[0010] In one possible implementation, the preprocessing method of the AMG-ILU adaptive preprocessor includes: After the iterative calculation begins, the AMG preprocessor is used for the first N steps to calculate the residual change rate for each step. In the N+1th step, if the residual change rate is lower than the second preset threshold, the AMG preprocessor and the ILU preprocessor are used for mixed preprocessing. The weight ratio of the AMG preprocessor and the weight ratio of the ILU preprocessor in the mixed preprocessing are set according to the residual change rate.
[0011] In one possible implementation, each iteration of the iterative computation includes: Calculate the current residual vector and evaluate the rate of change of the residuals; The AMG-ILU adaptive preprocessor is invoked to perform preprocessing steps based on the residual change rate; Based on the ELL main structure and additional CSR submatrix in the ELLPACK-R format, matrix-vector multiplication is performed in different regions to update the solution vector; Check the convergence condition, and terminate the iteration in response to the residual change rate being less than the preset tolerance or the number of iterations reaching the upper limit.
[0012] In one possible implementation, the final solution vector is stored in the GPU cache, and then decompressed and sent back to the CPU memory via the asynchronous transfer mechanism of the CUDA API.
[0013] In one possible implementation, the function that converts the decompressed solution vector into an OpenFOAM-recognizable LDU matrix format includes: Traverse the decompressed solution vectors and, according to the element mapping relationship between the ELLPACK-R format and the LDU matrix, fill the values of the solution vectors into the corresponding positions of the diagonal elements, upper triangular elements, and lower triangular elements of the LDU matrix. The integrity of the diagonal elements and the symmetry of the triangular elements of the filled LDU matrix are verified using a cross-validation algorithm.
[0014] Secondly, this application provides an electronic device, comprising: At least one processor; and At least one memory storing instructions that, when executed individually or jointly by the at least one processor, cause the electronic device to perform the method as described in the first aspect.
[0015] Thirdly, this application provides a computer-readable medium storing instructions that, when executed individually or jointly by at least one processor of an electronic device, cause the electronic device to perform the method described in the first aspect.
[0016] This application, by employing a general-purpose GPU platform and CUDA programming model, eliminates the dependence on specific hardware, resulting in wider adaptability and more flexible deployment. The LDU matrix is converted to ELLPACK-R format. The combination of the ELL main structure and the additional CSR submatrices in ELLPACK-R format not only conforms to the regular access pattern of GPU thread bundles, reducing thread divergence, but also avoids the storage waste of a single format. Compared to existing CSR formats, it achieves higher matrix-vector multiplication throughput on GPUs. Simultaneously, the iterative solution process is optimized by incorporating AMG-ILU adaptive preprocessing technology, significantly improving the condition number of the coefficient matrix, accelerating convergence, and reducing overall solution time. Furthermore, the data transmission and computation stages are tightly integrated throughout the entire process, and the dynamic load balancing mechanism ensures full utilization of multi-GPU resources. It can also be seamlessly integrated with existing OpenFOAM solvers, making it suitable for various computational fluid dynamics problems and improving the efficiency of OpenFOAM simulation. Attached Figure Description
[0017] The accompanying drawings are included to provide a further understanding of this application; they are incorporated into and constitute a part of this application. The drawings illustrate embodiments of this application and, together with this specification, serve to explain the principles of this application. In the drawings: Figure 1 This is a flowchart illustrating a GPU-accelerated OpenFOAM simulation method provided in an embodiment of this application. Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some examples or embodiments of this application. For those skilled in the art, these drawings can be applied to other similar scenarios without creative effort. Unless obvious from the context or otherwise specified, the same reference numerals in the drawings represent the same structures or operations.
[0019] As indicated in this application, unless the context clearly indicates otherwise, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of explicitly identified steps and elements, which do not constitute an exclusive list, and the method or apparatus may also include other steps or elements. Furthermore, it should be noted that the use of words such as "first" and "second" to define the object is merely for the purpose of distinguishing the corresponding objects, and unless otherwise stated, the above words have no special meaning and therefore should not be construed as limiting the scope of protection of this application.
[0020] Unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of this application. It should also be understood that, for ease of description, the dimensions of the various parts shown in the drawings are not drawn to actual scale. Techniques, methods, and devices known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and devices should be considered part of the specification. In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar reference numerals and letters in the following drawings denote similar items; therefore, once an item is defined in one drawing, it need not be further discussed in subsequent drawings.
[0021] Furthermore, although the terminology used in this application is selected from commonly known and used terms, some terms mentioned in this application's specification may have been chosen by the applicant according to his or her judgment, and their detailed meanings are explained in the relevant sections of the description herein. Moreover, this application is to be understood not only by the actual terms used, but also by the meaning implied by each term.
[0022] This application uses flowcharts to illustrate the operations performed by an apparatus or device according to embodiments of this application. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, these steps can be processed in reverse order or simultaneously. Furthermore, other operations may be added to these processes, or one or more operations may be removed from these processes.
[0023] Please refer to Figure 1 , Figure 1 A flowchart of a GPU-accelerated OpenFOAM simulation method 100 according to an exemplary embodiment of this application is shown. It should be understood that the OpenFOAM simulation method 100 may include additional steps not shown and / or some steps shown may be omitted, and the scope of this application is not limited thereto.
[0024] In step S110, OpenFOAM mesh information is read and an LDU matrix is generated. A dedicated function is written to convert the LDU matrix into ELLPACK-R format.
[0025] OpenFOAM mesh information can be structured or unstructured. In an exemplary embodiment, structured or unstructured mesh information is read through OpenFOAM's mesh reading interface, and a built-in function is called to generate an LDU matrix. For example, the diagonal elements of the LDU matrix are stored in lduMatrix.diag(), the upper triangular elements are stored in lduMatrix.upper(), and the lower triangular elements are stored in lduMatrix.lower().
[0026] In some embodiments, writing a dedicated function to convert the LDU matrix to ELLPACK-R format includes: traversing each row of the LDU matrix, recording the position, value, and number of non-zero elements in each row; calculating the distribution of non-zero element counts across all rows, determining the baseline column number for the ELLPACK-R format based on the distribution, storing non-zero elements in the ELL main structure for rows where the number of non-zero elements is within the baseline column number, and storing non-zero elements in an additional CSR submatrix for rows where the number of non-zero elements exceeds the baseline column number; sorting the non-zero elements in the ELL main structure by column index to generate an array of non-zero element values, an array of column indices, and an array of row non-zero element counts, and generating a Value array, a Col_Index array, and a Row_Offsets array in the additional CSR submatrix according to the standard CSR format.
[0027] For example, first, each row of the LDU matrix is traversed by iterating through the index vectors lduMatrix.upperAddr() and lduMatrix.lowerAddr(), recording the position, value, and number of non-zero elements in each row. The distribution of non-zero elements across all rows is then calculated. For instance, if an LDU matrix has 1000 rows and the median number of non-zero elements is 8, then the base column number is set to 8. The non-zero elements from 950 rows (95%) are stored in the ELL main structure, and the remaining 50 rows of extra non-zero elements are stored in an additional CSR submatrix. Then, the non-zero elements in the ELL main structure are sorted in ascending order by column index, generating a value array, a column index array, and a row count array. The additional CSR submatrix generates a Value array, a Col_Index array, and a Row_Offsets array according to the standard CSR format.
[0028] This application integrates a grid information reading interface and ELLPACK-R format conversion logic, supporting the generation of LDU matrices for both structured and unstructured grids. The conversion efficiency can reach 1 million rows / second, and the generated hybrid format matrix saves 15%-20% of storage space compared to the traditional ELLB format.
[0029] In step S120, after generating the initial mesh based on the OpenFOAM mesh information, the initial mesh is dynamically divided according to the computing load of each GPU to balance the computing load of each GPU; the matrix and vector data in ELLPACK-R format are compressed, and the compressed data is transferred from CPU memory to the corresponding GPU memory through the CUDA API; an optimized CUDA kernel function is written, and matrix-vector multiplication in ELLPACK-R format is performed on the GPU according to the CUDA kernel function.
[0030] The initial mesh can be generated using OpenFOAM's tools. For example, the initial mesh can be generated using OpenFOAM's blockMesh tool.
[0031] In some embodiments, dynamically partitioning the initial mesh based on the computational load of each GPU includes: evaluating the computational load of the initial mesh, and then further splitting and redistributing sub-mesh in the initial mesh whose computational load exceeds a first preset threshold. For example, a custom load evaluation function can be invoked to evaluate the computational load of the initial mesh, such as calculating the theoretical number of computations based on the number of mesh cells and the density of non-zero elements, with a partitioning accuracy error of less than 3%. In an exemplary embodiment, assuming four GPUs participate in the computation, and the initial mesh includes four sub-mesh, if the computational load of a certain sub-mesh is 7% higher than the average computational load (exceeding the 5% threshold), then that sub-mesh is split into two sub-mesh and redistributed to GPUs with lower computational loads.
[0032] In some embodiments, the compression processing of matrix and vector data in ELLPACK-R format employs a sparsity-based differential coding compression algorithm, encoding only the index difference and numerical value of non-zero elements. For example, the difference between the column index of a non-zero element and the column index of the preceding non-zero element in that row is encoded using variable-length integer encoding (1 byte for differences less than 128, otherwise 2 bytes), and the numerical value is encoded using 32-bit floating-point simplified encoding (retaining 6 significant digits).
[0033] In some embodiments, the data transfer process from CPU memory to GPU memory is implemented asynchronously using CUDA Streams, at least partially overlapping data transfer with CPU computation. Specifically, the cudaMemcpyAsync function of the CUDA API, combined with CUDA Streams, creates two parallel streams: one stream for transferring compressed data and the other for GPU initialization computation. This application embodiment supports multi-stream parallel transmission, reducing transmission latency by 30%.
[0034] In some embodiments, the CUDA kernel function integrates a data decompression module and a parallel computing optimization module. The data decompression module is used to restore compressed data in GPU memory to ELLPACK-R format. The parallel computing optimization module is used to allocate computing resources according to the characteristics of the ELL main structure and the additional CSR submatrix in ELLPACK-R format. For example, the parallel computing optimization module allocates a thread block of 256 threads / block for the ELL main structure (adapting to column-parallel computing) and a thread block of 128 threads / block for the additional CSR submatrix (adapting to row-parallel computing), making full use of the GPU's stream processor cores. This embodiment uses the CUDA kernel for matrix-vector multiplication calculations, achieving a 40% improvement in computational efficiency compared to traditional kernels.
[0035] In step S130, the PCG solver is initialized on the GPU. This initialization process includes setting the initial solution vector, residual vector, and AMG-ILU adaptive preprocessor. The matrix in ELLPACK-R format is preprocessed by the AMG-ILU adaptive preprocessor, and then iterative calculations of the PCG solver are performed.
[0036] On the GPU, the cudaMalloc function is called to allocate memory and initialize the PCG solver's initial solution vector (e.g., set to an all-zero vector), residual vector (e.g., initial residual vector r0 = bA × x0, where b is the right-hand side vector, A is the coefficient matrix, and x0 is the initial solution vector), and AMG-ILU adaptive preprocessor. In an exemplary embodiment, when initializing the AMG-ILU adaptive preprocessor, the number of multigrid layers of the AMG preprocessor is set to 3, and the fill factor of the ILU preprocessor is set to 1.2.
[0037] In some embodiments, the preprocessing method of the AMG-ILU adaptive preprocessor includes: after the start of iterative calculation, the AMG preprocessor is used for the first N steps to calculate the residual change rate at each step; in the N+1th step, if the residual change rate is lower than a second preset threshold, a hybrid preprocessing method using the AMG preprocessor and the ILU preprocessor is used. The weight ratios of the AMG preprocessor and the ILU preprocessor in the hybrid preprocessing are set according to the residual change rate. In this embodiment, the AMG preprocessor is used to quickly reduce the residual magnitude in the early stage of iteration. When the residual change rate is lower than the preset threshold, the method automatically switches to the ILU preprocessor to optimize local convergence performance. During the iteration process, the weight ratios of the two preprocessing methods are dynamically adjusted according to the residual change rate to accelerate the convergence speed.
[0038] N is a positive integer, and its value can be set according to actual needs. For example, N=10. After the iterative calculation begins, the first 10 steps use pure AMG preprocessing to calculate the residual change rate at each step. In step 11, if the residual change rate drops from the initial 30% to 10% (below the 50% threshold), then it switches to a mixed preprocessing with AMG preprocessing weighting at 70% and ILU preprocessing weighting at 30%. In step 20, if the residual change rate stabilizes at 8%, then it is adjusted to a mixed preprocessing with AMG preprocessing weighting at 50% and ILU preprocessing weighting at 50%. It can be understood that when the residual change rate is below a certain threshold, it can be adjusted to pure ILU preprocessing, that is, the weight of AMG preprocessing is 0.
[0039] In some embodiments, each iteration of the iterative computation includes: calculating the current residual vector and evaluating the residual rate of change; invoking the AMG-ILU adaptive preprocessor to perform preprocessing steps based on the residual rate of change; performing matrix-vector multiplication by region based on the ELL main structure and the additional CSR submatrix in ELLPACK-R format, and updating the solution vector; checking the convergence condition, and terminating the iteration in response to the residual rate of change being less than a preset tolerance or the iteration count reaching the upper limit. The final solution vector can be stored in the GPU cache. For example, in each iteration, the ELL main structure performs matrix-vector multiplication through column-parallel computation, and the additional CSR submatrix performs multiplication through row-parallel computation; the results of both are summed to update the solution vector. The convergence condition is checked every few iterations (e.g., 5 steps), and when the residual rate of change is less than a preset tolerance (e.g., 1×10⁻⁶), the solution vector is updated. -6 The iteration terminates when the final solution vector is stored in the GPU cache.
[0040] In step S140, the iterative calculation results on the GPU are decompressed and transferred back to the CPU memory. A function is written to convert the decompressed solution vectors into an LDU matrix format that OpenFOAM can recognize. The OpenFOAM simulation is run, and the dynamic mesh generation strategy and the parameters of the PCG solver are dynamically adjusted according to the calculation results of the OpenFOAM simulation.
[0041] The `cudaMemcpyAsync` function decompresses the solution vector in the GPU cache and then transfers it back to CPU memory; the decompression process is executed in parallel with GPU memory release. In some embodiments, the final solution vector is decompressed and transferred back to CPU memory using the asynchronous transfer mechanism of the CUDA API, reducing data transfer latency.
[0042] In some embodiments, writing a function to convert the decompressed solution vectors into an OpenFOAM-recognizable LDU matrix format includes: traversing the decompressed solution vectors, filling the corresponding positions of the diagonal, upper triangular, and lower triangular elements of the LDU matrix with the values of the solution vectors according to the element mapping relationship between the ELLPACK-R format and the LDU matrix; and then verifying the integrity of the diagonal elements and the symmetry of the triangular elements of the filled LDU matrix using a cross-validation algorithm. For example, a format restoration function is written to traverse the solution vectors and fill the values into the diag(), upper(), and lower() vectors of the LDU matrix according to the mapping relationship between the core array and auxiliary array of the ELLPACK-R format. The cross-validation algorithm is used to calculate the ratio of the sum of the diagonal elements of the LDU matrix to the L2 norm of the solution vectors and compare it with a preset threshold (e.g., 1 ± 0.01); the symmetry of the upper and lower triangular elements is verified (e.g., |upper[i] - lower[j]| < 1 × 10). -8 (where i and j are symmetric indices) to ensure data consistency and accuracy during the conversion process.
[0043] Based on the OpenFOAM simulation results, the dynamic mesh generation strategy and PCG solver parameters are dynamically adjusted according to actual needs. For example, the threshold range for dynamic mesh generation is 3%-7%, and the tolerance range for the PCG solver is 5×10. -7 -1×10 -5 This allows for adaptation to CFD problems of varying complexity. For example, running an OpenFOAM simulation and, based on the residual convergence curve in the simulation results, adjusting the PCG solver's tolerance to 5 × 10⁻⁶ if the number of iterations exceeds 500. -7 Meanwhile, the threshold for dynamic mesh generation was adjusted to 4% to optimize subsequent computational performance.
[0044] An embodiment of this application also proposes a method such as Figure 2 The electronic device 200 shown. According to... Figure 2The electronic device 200 may include an internal communication bus 201, a processor 202, a read-only memory (ROM) 203, a random access memory (RAM) 204, and a communication port 205. When used in a personal computer, the electronic device 200 may also include a hard disk 206.
[0045] The internal communication bus 201 enables data communication between components of the electronic device 200. The processor 202 can perform judgments and issue prompts. In some embodiments, the processor 202 may consist of one or more processors. The communication port 205 enables data communication between the electronic device 200 and external devices. In some embodiments, the electronic device 200 can send and receive information and data from a network through the communication port 205.
[0046] Electronic device 200 may also include different forms of program storage units and data storage units, such as hard disk 206, read-only memory (ROM) 203 and random access memory (RAM) 204, capable of storing various data files used for computer processing and / or communication, as well as possible program instructions executed by processor 202. Processor 202 executes these instructions to cause electronic device 200 to perform OpenFOAM simulation method 100. The results processed by processor 202 are transmitted to user equipment through communication port 205 and displayed on user interface.
[0047] In addition, this application also proposes a computer-readable medium storing computer program instructions, which, when executed individually or jointly by at least one processor of an electronic device, cause the electronic device to perform the OpenFOAM simulation method 100.
[0048] Some aspects of this application can be executed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The aforementioned hardware or software may be referred to as a "data block," "module," "engine," "unit," "component," or "system." The processor may be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or combinations thereof. Furthermore, aspects of this application may manifest as computer products residing in one or more computer-readable media, including computer-readable program code. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disks, floppy disks, magnetic tapes, etc.), optical discs (e.g., compressed CDs, digital multifunction DVDs, etc.), smart cards, and flash memory devices (e.g., cards, sticks, key drives, etc.).
[0049] A computer-readable medium may contain a propagated data signal containing computer program code, for example, on baseband or as part of a carrier wave. This propagated signal may take various forms, including electromagnetic, optical, and so on, or suitable combinations thereof. A computer-readable medium can be any computer-readable medium other than a computer-readable storage medium, which can be connected to an instruction execution system, apparatus, or device to enable communication, propagation, or transmission of a program for use. The program code located on the computer-readable medium can be propagated through any suitable medium, including radio, cable, fiber optic cable, radio frequency signals, or similar media, or any combination of the above media.
[0050] The basic concepts have been described above. Obviously, for those skilled in the art, the above disclosure is merely illustrative and does not constitute a limitation of this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are suggested in this application, and therefore remain within the spirit and scope of the exemplary embodiments of this application.
[0051] Furthermore, this application uses specific terms to describe embodiments of the application. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic related to at least one embodiment of the application. Therefore, it should be emphasized and noted that "an embodiment," "one embodiment," or "an alternative embodiment" mentioned twice or more in different locations in this specification do not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of the application can be appropriately combined.
[0052] Similarly, it should be noted that, in order to simplify the description of the present application and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of the embodiments of the present application sometimes combines multiple features into a single embodiment, drawing, or description thereof. However, this disclosure method does not imply that the subject matter of the present application requires more features than those mentioned. In fact, the embodiments have fewer features than all the features of the single embodiments disclosed above.
[0053] Although this application has been described with reference to specific embodiments, those skilled in the art should recognize that the above embodiments are only used to illustrate this application, and various equivalent changes or substitutions can be made without departing from the spirit of this application. Therefore, any changes or modifications to the above embodiments within the scope of the essential spirit of this application will fall within the scope of this application.
Claims
1. A GPU-accelerated OpenFOAM simulation method, characterized in that, include: Read OpenFOAM mesh information and generate an LDU matrix; write a dedicated function to convert the LDU matrix into ELLPACK-R format. After generating an initial mesh based on the OpenFOAM mesh information, the initial mesh is dynamically divided according to the computing load of each GPU to balance the computing load of each GPU; the matrix and vector data in ELLPACK-R format are compressed, and the compressed data is transferred from CPU memory to the corresponding GPU memory through the CUDA API; an optimized CUDA kernel function is written, and matrix-vector multiplication in ELLPACK-R format is performed on the GPU according to the CUDA kernel function; The PCG solver is initialized on the GPU. The initialization process includes setting the initial solution vector, residual vector, and AMG-ILU adaptive preprocessor. The matrix in ELLPACK-R format is preprocessed by the AMG-ILU adaptive preprocessor, and then iterative calculations of the PCG solver are performed. After decompressing the iterative calculation results on the GPU, the results are transferred back to the CPU memory. A function is written to convert the decompressed solution vectors into an LDU matrix format that OpenFOAM can recognize. An OpenFOAM simulation is run, and the dynamic mesh generation strategy and the parameters of the PCG solver are dynamically adjusted based on the calculation results of the OpenFOAM simulation.
2. The OpenFOAM simulation method as described in claim 1, characterized in that, The step of writing a dedicated function to convert the LDU matrix to ELLPACK-R format includes: Iterate through each row of the LDU matrix and record the position, value, and number of non-zero elements in each row. Calculate the distribution of the number of non-zero elements in all rows, determine the base column number of the ELLPACK-R format based on the distribution of the number of non-zero elements, store the non-zero elements in the ELL main structure for rows with the number of non-zero elements within the range of the base column number, and store the non-zero elements in the additional CSR submatrix for rows with the number of non-zero elements exceeding the base column number. Sort the non-zero elements of the ELL master structure by column index to generate an array of non-zero element values, an array of column indices, and an array of row non-zero element counts. Append a CSR submatrix to generate a Value array, a Col_Index array, and a Row_Offsets array in standard CSR format.
3. The OpenFOAM simulation method as described in claim 1, characterized in that, The CUDA kernel function integrates a data decompression module and a parallel computing optimization module. The data decompression module is used to restore the compressed data in the GPU memory to the ELLPACK-R format. The parallel computing optimization module is used to allocate computing resources according to the features of the ELL main structure and the additional CSR submatrix of the ELLPACK-R format.
4. The OpenFOAM simulation method as described in claim 1, characterized in that, The compression process employs a sparsity-based differential coding compression algorithm, which encodes only the index difference and numerical value of non-zero elements. The process of transferring compressed data from CPU memory to the corresponding GPU memory via the CUDA API includes: Combine CUDA Streams to create two parallel streams, one for transmitting compressed data and the other for GPU initialization computation.
5. The OpenFOAM simulation method as described in claim 1, characterized in that, The dynamic meshing of the initial mesh based on the computing load of each GPU includes: The computational cost of the initial grid is evaluated. Subgrids in the initial grid whose computational load exceeds a first preset threshold are split and redistributed a second time.
6. The OpenFOAM simulation method as described in claim 1, characterized in that, The preprocessing method of the AMG-ILU adaptive preprocessor includes: After the iterative calculation begins, the AMG preprocessor is used for the first N steps to calculate the residual change rate for each step. In the N+1th step, if the residual change rate is lower than the second preset threshold, the AMG preprocessor and the ILU preprocessor are used for mixed preprocessing. The weight ratio of the AMG preprocessor and the weight ratio of the ILU preprocessor in the mixed preprocessing are set according to the residual change rate.
7. The OpenFOAM simulation method as described in claim 1, characterized in that, Each iteration of the iterative calculation includes: Calculate the current residual vector and evaluate the rate of change of the residuals; The AMG-ILU adaptive preprocessor is invoked to perform preprocessing steps based on the residual change rate; Based on the ELL main structure and additional CSR submatrix in the ELLPACK-R format, matrix-vector multiplication is performed in different regions to update the solution vector; Check the convergence condition, and terminate the iteration in response to the residual change rate being less than the preset tolerance or the number of iterations reaching the upper limit.
8. The OpenFOAM simulation method as described in claim 7, characterized in that, The final solution vector is stored in the GPU cache, and is decompressed and sent back to the CPU memory through the asynchronous transfer mechanism of the CUDA API.
9. The OpenFOAM simulation method as described in claim 8, characterized in that, The function described above converts the decompressed solution vectors into an LDU matrix format recognizable by OpenFOAM, including: Traverse the decompressed solution vectors and, according to the element mapping relationship between the ELLPACK-R format and the LDU matrix, fill the values of the solution vectors into the corresponding positions of the diagonal elements, upper triangular elements, and lower triangular elements of the LDU matrix. The integrity of the diagonal elements and the symmetry of the triangular elements of the filled LDU matrix are verified using a cross-validation algorithm.
10. An electronic device, characterized in that, include: At least one processor; as well as At least one memory storing instructions that, when executed individually or jointly by the at least one processor, cause the electronic device to perform the method as described in any one of claims 1-9.
11. A computer-readable medium, characterized in that, The computer-readable medium stores instructions that, when executed individually or jointly by at least one processor of the electronic device, cause the electronic device to perform the method as described in any one of claims 1-9.