OpenFOAM dictionary file automatic generation method and CFD automatic calculation system
Automatically generate OpenFOAM dictionary files through the graphical user interface and mapping system, solving the problem of complex manual configuration of OpenFOAM software and achieving an efficient and simplified CFD simulation calculation process.
Patent Information
- Application Number
- CN202510705353.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-05-29
AI Technical Summary
The existing OpenFOAM software requires users to manually write or modify dictionary files, which has a high learning threshold, resulting in complex and inefficient CFD simulation computing configuration.
It provides a CFD automatic calculation system that receives input parameters through a graphical user interface, generates a JSON interface parameter file, and uses a mapping system to automatically map it into an OpenFOAM dictionary file, supporting parameter insertion and file management, simplifying the operation process.
It reduces user operation complexity, improves simulation computing efficiency and reliability, has wide applicability, supports custom parameter expansion, and is suitable for a variety of GUI interfaces.
Smart Images

Figure CN120217479B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computational fluid dynamics technology, and in particular to an OpenFOAM dictionary file automatic generation method and a CFD automatic calculation system. Background Art
[0002] Computational Fluid Dynamics (CFD) is a science that uses numerical methods and algorithms to simulate fluid flow. It studies the behavior of fluids by solving the governing equations of fluid dynamics and analyzes problems such as flow, heat transfer, and mass transfer.
[0003] As open-source CFD software, OpenFOAM provides the solvers, algorithms, and modules necessary to implement CFD theory. It is used to simulate and solve numerical problems in fluid dynamics and related physical phenomena. Its core operations rely primarily on users manually writing or modifying text-based dictionary files, such as controlDict and fvSchemes. However, due to its high learning threshold and configuration requirements, users must spend considerable time thoroughly mastering OpenFOAM's syntax and physical model matching logic before completing parameter configuration and successfully conducting simulation calculations. Summary of the Invention
[0004] This application provides an OpenFOAM dictionary file automatic generation method and a CFD automatic calculation system to solve the problem that existing solutions require users to manually write or modify dictionary files and have a high learning threshold.
[0005] In a first aspect, the present application provides a CFD automatic calculation system, comprising: a graphical user interface for receiving input parameters configured by a user and storing the input parameters as a JSON interface parameter file; a mapping system for mapping the JSON interface parameter file to an OpenFOAM dictionary file; and OpenFOAM for performing CFD calculations according to the OpenFOAM dictionary file and returning the calculation results to the graphical user interface.
[0006] Optionally, the mapping system includes: a normalization processing unit, which is used to convert the parameters of the JSON interface parameter file through a mapping table from interface parameters to OpenFOAM parameters to obtain a JSON parameter intermediate file; a file list generation unit, which is used to generate a file list based on the JSON parameter intermediate file, the file list including multiple records, each record including a file name, a generation condition, and a belonging folder, the meaning of each record is that when the generation condition is judged to be true, a file with a file name is generated in the belonging folder, recorded as a transfer file, the file name corresponds to the OpenFOAM example file name, and the value of the generation condition is composed of multiple input parameters in the JSON parameter intermediate file; a first parameter mapping form generation unit, which is used to generate a first parameter mapping form for each transfer file in the file list, the first parameter mapping form including: a serial number, a parameter name, a parameter type, a previous level, "parameter value or position" and a generation condition, and the parameter corresponding to the parameter name will be generated only when the generation condition in the first parameter mapping form is met; a parameter mapping unit, which is used to obtain the OpenFOAM dictionary file of each transfer file based on the file list, the first parameter mapping form and the JSON parameter intermediate file.
[0007] Optionally, the value of the first parameter mapping form is determined in the following manner: the parameter names in the first parameter mapping form are all parameter names appearing in the transfer file; the parameter type is the corresponding JSON format data type; when a parameter has nested data types, the serial number of the nested outer parameter is filled in the "previous level" of the nested inner parameter; when the parameter type is a constant, the parameter value is filled in the "parameter value or position" item, and in other cases the position of the parameter in the JSON parameter intermediate file is filled in; the value of the generation condition in the first parameter mapping form is determined in the following manner: for the required parameter items, set to true, and the values of the generation conditions of other parameters are determined by the parameters in the JSON parameter intermediate file.
[0008] Optionally, the "parameter value or position" in the first parameter mapping form of different transfer files corresponds to the same parameter position in the JSON parameter intermediate file, so that the first parameter mapping form establishes a one-to-many relationship between the JSON parameter and the dictionary parameter.
[0009] Optionally, the parameter mapping unit is configured to obtain an OpenFOAM dictionary file of each transfer file according to the file list, the first parameter mapping form, and the JSON parameter intermediate file, including:
[0010] Generate multiple transfer files according to the file list, find the first parameter mapping form corresponding to each transfer file; traverse the first parameter mapping form, fill in the parameter default value for each parameter item in turn or take the parameter value from the JSON parameter intermediate file to obtain the OpenFOAM dictionary file of each transfer file.
[0011] Optionally, the mapping system further includes: a data structure mapping unit, for converting the JSON structure file generated by the parameter mapping unit into the OpenFOAM dictionary file, the data structure mapping unit having built-in data structure mapping rules, and converting the JSON structure file into the OpenFOAM dictionary file through the data structure mapping rules, the data structure mapping rules including conversion rules from JSON format to OpenFOAM format for multiple data types, the multiple data types including string / numeric arrays, object arrays, and two-dimensional arrays.
[0012] Optionally, the mapping system also includes a data verification unit, which is used to: identify the first parameter mapping form corresponding to each transferred file; traverse the first parameter mapping form, and determine in turn whether the parameter value can be obtained from the JSON parameter intermediate file for the parameters whose data type is not a constant and whose generation condition is not false; if the parameter value cannot be obtained, the parameter name is recorded, and the missing parameter is prompted to the graphical user interface when finally returning.
[0013] Optionally, the mapping system also includes: a second parameter mapping form generating unit, used to generate a second parameter mapping form, the second parameter mapping form including: serial number, parameter name, parameter type, previous level, mapping parameter name, folder and required items, wherein the parameter name is the name in the JSON parameter intermediate file, the mapping parameter name is the parameter name in the OpenFOAM dictionary file to be finally generated, the folder indicates the storage path and file name of the parameter in the dictionary, All means that the parameter is required in all files, and the required items indicate whether the parameter must exist in the file; the parameter mapping unit is also used to obtain the OpenFOAM dictionary file of each transfer file according to the file list, the second parameter mapping form and the JSON parameter intermediate file.
[0014] Optionally, the hierarchy of the parameters of the JSON interface parameter file is consistent with the structure of the graphical user interface, and the hierarchy of the parameters of the JSON interface parameter file includes geometry, mesh, physics, solution, and display.
[0015] In a second aspect, the present application provides a method for automatically generating an OpenFOAM dictionary file, comprising: receiving user-configured input parameters through a graphical user interface, and storing the input parameters as a JSON interface parameter file; performing parameter conversion on the JSON interface parameter file through a mapping table from interface parameters to OpenFOAM parameters to obtain a JSON parameter intermediate file; generating a file list based on the JSON parameter intermediate file, the file list including multiple file records, each file record including a file name, a generation condition, and a belonging folder, the meaning of each record being that when the generation condition is judged to be true, a file with a file name is generated in the belonging folder, recorded as a transfer file, the file name corresponds to the OpenFOAM example file name, and the value of the generation condition is composed of multiple input parameters in the JSON parameter intermediate file; generating a first parameter mapping form for each transfer file in the file list, the first parameter mapping form including: a serial number, a parameter name, a parameter type, a previous level, a "parameter value or position" and a generation condition, and when the generation condition in the first parameter mapping form is met, the parameter corresponding to the parameter name will be generated; obtaining the OpenFOAM dictionary file for each transfer file based on the file list, the first parameter mapping form and the JSON parameter intermediate file.
[0016] In a third aspect, the present application provides an OpenFOAM dictionary file automatic generation device, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the OpenFOAM dictionary file automatic generation method as described above.
[0017] Compared with the prior art, this application has the following advantages:
[0018] The OpenFOAM dictionary file automatic generation method and CFD automatic calculation system of the present invention automatically maps the JSON interface parameter file to the format and structure of multiple dictionary files required by OpenFOAM through a mapping system, supports parameter insertion and file management, is very user-friendly, and performs calculations with one click, simplifying most user operations; secondly, the present invention has wide applicability and can be easily extended to any existing GUI interface. It only needs to provide a JSON interface for the parameter file and an interface for the example calculation results to complete the entire process; furthermore, the present invention has high scalability, and users can customize the extended file list and parameter mapping table as needed to achieve personalized parameter verification and parameter mapping. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are included to provide a further understanding of the present application. They are incorporated into and constitute a part of this application. The accompanying drawings illustrate embodiments of the present application and, together with this specification, serve to explain the principles of the present application. In the accompanying drawings:
[0020] Figure 1 This is a timing diagram of a CFD automatic calculation system provided in an embodiment of the present application.
[0021] Figure 2 yes Figure 1 A system block diagram of an embodiment of a mapping system.
[0022] Figure 3 This is a schematic diagram of a JSON parameter intermediate file provided in an embodiment of the present application.
[0023] Figure 4 is based on Figure 3 Schematic diagram of the file list generated by the JSON parameter intermediate file and the first parameter mapping form.
[0024] Figure 5 This is a schematic diagram of a data structure mapping rule provided in an embodiment of the present application.
[0025] Figure 6 This is a schematic diagram of a second parameter mapping form provided in an embodiment of the present application.
[0026] Figure 7 This is a flowchart of a method for automatically generating an OpenFOAM dictionary file provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the following is a brief introduction to the drawings required for describing the embodiments. Obviously, the drawings described below are merely examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without inventive effort. Unless otherwise apparent from the context or otherwise noted, the same reference numerals in the figures represent the same structure or operation.
[0028] Flowcharts are used in this application to illustrate the operations performed by devices or apparatuses according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, the steps may be performed 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.
[0029] Some commercial open-source CFD software attempts to provide a graphical user interface (GUI) for OpenFOAM, but significant flaws still exist. These include relatively independent functions, the interface only implementing graphics for some modules, and the need to manually edit dictionary files for key solver parameters. Furthermore, the software lacks flexibility, with built-in templates unable to cover user-defined model requirements, forcing users to bypass the GUI and directly modify the underlying dictionary files.
[0030] In order to lower the threshold for applying CFD technology and improve the efficiency and reliability of simulation calculations, this paper proposes an OpenFOAM dictionary file automatic generation method and a CFD automatic calculation system. The core of the method is to abstract the underlying parameter details through a visual interface. Through the automation of interface parameter input - dictionary file generation - calculation task submission, it supports users to dynamically add custom parameters through the interface, automatically generates dictionary files that conform to the OpenFOAM syntax, and transforms OpenFOAM from an expert tool into a universal simulation platform.
[0031] Figure 1 This is a timing diagram of a CFD automatic calculation system provided by an embodiment of the present application. Figure 1 As shown, CFD automated calculation system 100 includes a graphical user interface (GUI) 1, a mapping system 2, and OpenFOAM 3. GUI 1 is used to receive user-configured input parameters and store them as a JSON interface parameter file. Mapping system 2 is used to map the JSON interface parameter file to an OpenFOAM dictionary file. OpenFOAM 3 is used to perform CFD calculations based on the OpenFOAM dictionary file and return the calculation results to GUI 1.
[0032] Optionally, the graphical user interface 1 is configured to receive input parameters configured by the user, and the input parameters are recorded in JSON format to form a JSON interface parameter file; the hierarchy of the parameters in the file is recommended to be consistent with the interface structure, and the user's main operating process "geometry-mesh-physics-solution-display" can be referred to to divide the JSON file into the above 5 categories, and then fill in specific configuration items and configuration parameters into the category table; at the same time, the interface completes the legitimacy check of the user input data to ensure that the configuration parameters are credible input data.
[0033] In other embodiments, the input parameters may be recorded in other formats, including but not limited to XML, YAML, or a TXT file in a specific format. As long as the file type can clearly record data and parse the recorded data, replacement may be considered.
[0034] Figure 2 yes Figure 1 FIG. 1 is a system block diagram of an embodiment of a mapping system. Figure 2As shown, the mapping system 2 includes: a normalization processing unit 21 , a file list generating unit 22 , a first parameter mapping form generating unit 23 , and a parameter mapping unit 25 .
[0035] The normalization processing unit 21 is used to convert the parameters of the JSON interface parameter file using a mapping table from interface parameters to OpenFOAM parameters, thereby generating a JSON parameter intermediate file. Since the parameters selected in the interface are user-oriented and may be interpreted in Chinese or other user-friendly language, the parameter conversion is performed using a mapping table from interface parameters to OpenFOAM parameters. This mapping table is used to normalize the JSON interface parameter file, generating a JSON parameter intermediate file.
[0036] The file list generation unit 22 is used to generate a file list based on the JSON parameter intermediate file. The file list includes multiple records, each of which includes a file name, a generation condition, and a folder. The meaning of each record is that when the "generation condition" is judged to be true, a file with the "file name" is generated in the "folder".
[0037] The first parameter mapping form generating unit 23 is used to generate a first parameter mapping form for each transfer file in the file list. The first parameter mapping form includes: sequence number, parameter name, parameter type, previous level, "parameter value or position" and generating conditions.
[0038] Figure 3 This is a schematic diagram of a JSON parameter intermediate file provided in an embodiment of the present application. Figure 4 is based on Figure 3 Schematic diagram of the file list generated by the JSON parameter intermediate file and the first parameter mapping form. Figure 3~Figure 4 As shown, the file list (also known as a file list) consists of multiple records, each of which includes a file name, generation condition, and folder. The file name corresponds to the OpenFOAM example file name, and the generation condition determines whether the file is generated. This condition can be composed of parameters entered through multiple interfaces. When determining the generation condition, the corresponding parameter values are retrieved from the JSON parameter intermediate file. If a file is required, the generation condition can be set to true. A record in this file list indicates that when the "generation condition" is true, a file with the specified name is generated in the "folder."
[0039] The first parameter mapping form includes: serial number, parameter name, parameter type, previous level, "parameter value or position" and generation conditions. The parameter name is a list of all parameters appearing in the file, and the parameter type is the corresponding JSON format data type, such as string, number, boolean, Array, Object, and const (default value). When a parameter has nested data types, the serial number of the nested outer parameter needs to be filled in the "previous level" of the nested inner parameter. When the parameter type is const (constant), fill in the parameter value in the "parameter value or position" item. In other cases, fill in the position of the parameter in the JSON parameter intermediate file. Different files can correspond to the unified parameter position of the JSON parameter intermediate file. The generation condition is used to control whether the parameter should be written to the current file. For required parameter items, it can be set to true. The value of the generation condition of other parameters is determined by the parameters in the JSON parameter intermediate file. A set of first parameter mapping forms needs to be constructed for each transferred file in the file list (generation condition is true).
[0040] After being processed by the first parameter mapping form generating unit 23 , a first parameter mapping form of each file is finally obtained, and the first parameter mapping form establishes a one-to-many relationship between the JSON parameters and the dictionary parameters.
[0041] like Figure 4 As shown in the figure, the file number 1 in the file list is named "controlDict". The control dictionary file controlDict of OpenFOAM 5.0 is located in the system directory of the current case folder. Its main functions include setting the calculation time and data output format, etc. Through the settings of this file, functions such as automatic adjustment of the calculation time step and loading of dynamic library files can be realized. The first parameter mapping form of the file named "controlDict" includes the parameters named applicationClass, startFrom, startTime, and timeFormat. Among them, the parameter value / position of applicationClass is Figure 3 The location of the value in the JSON parameter intermediate file is under the applicationClass variable under the TimeControl function, recorded as [TimeControl, applicationClass]. The parameter value / position of startFrom is Figure 3The position of this value in the JSON parameter intermediate file is under the startFrom variable under the TimeControl function, recorded as [TimeControl, startFrom]. The values of other parameter values / positions are deduced in the same way. It should be noted that the parameter type of timeFormat is const (constant), and the parameter value is filled in the "parameter value or position" item. Furthermore, for the generation conditions, the required parameter items are set to true, and the values of the generation conditions of other parameters are determined by the parameters in the JSON parameter intermediate file. For example, for the required parameters applicationClass, startFrom, and timeFormat, the generation conditions are set to true, and for the parameter startTime, the judgment condition [TimeControl, startFrom] =='startFrom' is set. The value of the generation condition is determined to be true or false based on the judgment result.
[0042] The parameter mapping unit 25 is configured to obtain an OpenFOAM dictionary file for each transferred file based on the file list, the first parameter mapping form, and the JSON parameter intermediate file. Specifically, the parameter mapping unit 25 is configured to find the first parameter mapping form for each transferred file based on the file list; traverse the first parameter mapping form, and sequentially fill in the default parameter values for each parameter item or retrieve the parameter values from the JSON intermediate file to obtain the OpenFOAM dictionary file for each transferred file.
[0043] Optionally, the parameter mapping unit 25 is used to obtain the JSON structure files of each transfer file based on the file list, the first parameter mapping form and the JSON parameter intermediate file. The JSON structure file refers to an OpenFOAM dictionary file in JSON format, which needs to undergo format conversion to obtain the final dictionary file. Optionally, the mapping system 2 also includes a data structure mapping unit 26. The data structure mapping unit 26 is used to convert the JSON structure file generated by the parameter mapping unit 25 into an OpenFOAM dictionary file. The data structure mapping unit 26 has built-in data structure mapping rules, and converts the JSON structure file into an OpenFOAM dictionary file through the data structure mapping rules. The data structure mapping rules include conversion rules from JSON format to OpenFOAM format for multiple data types, and the multiple data types include string / numeric arrays, object arrays, and two-dimensional arrays.
[0044] Figure 5 This is a schematic diagram of a data structure mapping rule provided by an embodiment of the present application. Figure 5 As shown, the key-value pair Key:Value in JSON format is converted into a data structure that conforms to the OpenFOAM syntax rules through the data structure mapping rules as Key Value;
[0045] The JSON array List[value1,value2] is converted into a data structure that conforms to the OpenFOAM syntax rules through the data structure mapping rules, which is List (value1 value2).
[0046] Conversion of other data types such as Figure 5 As shown, no further details are given here.
[0047] As can be seen from the above, the parameter mapping unit 25 can be mapped directly to an OpenFOAM dictionary file or to a JSON structure file. The JSON structure file is then converted into an OpenFOAM dictionary file by the data structure mapping unit 26. The advantage of first mapping to a JSON structure file and then converting to an OpenFOAM dictionary file is that each link is decoupled from each other for easy maintenance.
[0048] Alternatively, as Figure 2 As shown, mapping system 2 also includes a data verification unit 24. Data verification unit 24 is used to verify the integrity of parameters. Specifically, based on the file list, it finds the first parameter mapping form for each transferred file. It traverses the first parameter mapping form and, for parameters whose data types are not constants and whose generation conditions are not false, determines whether parameter values can be retrieved from the JSON parameter intermediate file. If a parameter value cannot be retrieved, the parameter name is recorded, and the missing parameter is displayed in the graphical user interface during the final return.
[0049] After receiving the OpenFOAM dictionary file, Mapping System 2 notifies OpenFOAM to begin the calculation and passes the OpenFOAM dictionary file to OpenFOAM. After receiving the input case file, OpenFOAM begins the calculation. The results are returned to the GUI through the file interface. The GUI parses the result file and displays it graphically to the user.
[0050] Optionally, the mapping system 2 also includes a second parameter mapping form generation unit. The second parameter mapping form generation unit is used to generate a second parameter mapping form. The parameter mapping unit is also used to obtain the OpenFOAM dictionary file of each transferred file based on the file list, the second parameter mapping form, and the JSON parameter intermediate file. The difference between the second parameter mapping form and the first parameter mapping form is that the first parameter mapping form is a parameter mapping form derived from the forward path, that is, it is derived step by step from the input parameters to the JSON parameter intermediate file, and which files in the file list need to be generated (whether the generation condition is true) and which parameters in the first parameter mapping form of the file to be generated are required (whether the generation condition is true) are determined based on the input parameters. The second parameter mapping form is a parameter mapping form derived in reverse based on the results. Based on the known parameters required by the OpenFOAM example file, the second parameter mapping form of each file is derived.
[0051] Figure 6 This is a schematic diagram of a second parameter mapping form provided in an embodiment of the present application. Figure 6 As shown, the second parameter mapping form includes: serial number, parameter name, parameter type, previous level, mapping parameter name, folder and required items. The parameter name is the name in the JSON parameter intermediate file, the mapping parameter name is the parameter name in the OpenFOAM dictionary file to be generated, the folder indicates the storage path and file name of the parameter in the dictionary, All means that the parameter is required in all files, and the required items indicate whether the parameter must exist in the file. File generation logic judgment and data verification can be completed according to the second parameter mapping form. Traverse the parameter names with required items as true in the second parameter mapping table in turn. If the parameter name does not exist in the JSON parameter intermediate file, it means that the file lacks the parameters required to generate the file.
[0052] The OpenFOAM dictionary file obtained according to the second parameter mapping form and the JSON parameter intermediate file can replace the OpenFOAM dictionary file obtained according to the first parameter mapping form and the JSON parameter intermediate file, and can also exist in parallel as a double verification to ensure the accuracy of the generated results.
[0053] The present disclosure also provides a method for automatically generating an OpenFOAM dictionary file.
[0054] Figure 7 This is a flow chart of a method for automatically generating an OpenFOAM dictionary file provided in an embodiment of the present application. Figure 7 As shown, the OpenFOAM dictionary file automatic generation method 700 includes:
[0055] Step S71: receiving input parameters configured by the user through the graphical user interface, and storing the input parameters as a JSON interface parameter file;
[0056] Step S72: converting the parameters of the JSON interface parameter file through the mapping table from interface parameters to OpenFOAM parameters to obtain a JSON parameter intermediate file;
[0057] Step S73: Generate a file list based on the JSON parameter intermediate file. The file list includes multiple records. Each record includes a file name, generation conditions, and a folder to which it belongs. The file name corresponds to the OpenFOAM example file name. The generation conditions are the basis for judging whether this file is generated. The judgment basis is composed of multiple input parameters in the JSON parameter intermediate file.
[0058] Step S74: Generate a first parameter mapping form for each transferred file in the file list. The first parameter mapping form includes the sequence number, parameter name, parameter type, previous level, parameter value or position, and generation conditions. The generation conditions control whether the parameter should be written to the current file. Required parameters are set to true. The values of the generation conditions for other parameters are determined by the parameters in the JSON parameter intermediate file.
[0059] Step S75: Obtain the OpenFOAM dictionary files of each transfer file according to the file list, the first parameter mapping form and the JSON parameter intermediate file.
[0060] Optionally, in step S74, the parameter name in the first parameter mapping form is a list of all parameters appearing in the file, and the parameter type is the corresponding JSON format data type. When a parameter has a nested data type, the serial number of the nested outer parameter is filled in the "previous level" of the nested inner parameter; when the parameter type is a constant, the parameter value is filled in the "parameter value or position" item, and in other cases, the position of the parameter in the JSON parameter intermediate file is filled in.
[0061] Optionally, in step S75, obtaining the OpenFOAM dictionary file of each transfer file includes: finding the first parameter mapping form of each transfer file according to the file list; traversing the first parameter mapping form, filling in the parameter default value for each parameter item in turn or taking the parameter value from the JSON intermediate file to obtain the OpenFOAM dictionary file of each transfer file.
[0062] The OpenFOAM dictionary file automatic generation method and CFD automatic calculation system disclosed in the present invention have the following beneficial effects:
[0063] 1. Multi-file linkage generation mechanism: A JSON parameter can be mapped to parameters in multiple dictionary files, reducing redundant configuration items and automatically handling one-to-many parameter mapping.
[0064] 2. Automatic parsing mechanism for parameter impact range: The system can automatically identify that a certain parameter affects multiple OpenFOAM configuration items and files to avoid omissions.
[0065] 3. Structured participation and template dynamic binding mechanism: Through unified data structure and preset file templates, it supports dynamic interpolation, batch generation, and parameter group management.
[0066] 4. Dictionary file generation engine mechanism: automatically maps structured parameters into the format and structure of multiple dictionary files required by OpenFOAM, supporting parameter insertion and file management.
[0067] 5. User-friendliness: One-click calculation simplifies most user operations;
[0068] 6. Wide applicability: This application can be easily extended to any existing GUI interface. The entire process can be completed by simply providing a JSON interface for parameter files and an interface for calculation results.
[0069] 7. Scalability: Users can customize the extended file list and parameter mapping table as needed to achieve personalized parameter verification and parameter mapping.
[0070] In general, various embodiments of the present application may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Certain aspects may be implemented in hardware, while other aspects may be implemented in firmware or software, which may be executed by a controller, microprocessor, or other computing device. Although various aspects of the embodiments of the present application are shown and described as block diagrams, flow charts, or using some other graphical representations, it should be understood that, as non-limiting examples, the blocks, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or a controller or other computing device, or some combination thereof.
[0071] The present application also provides at least one computer program product tangibly stored on a non-transitory computer readable storage medium. The computer program product includes computer executable instructions, such as instructions included in program modules, which are executed in a device on a target real or virtual processor to perform the above-mentioned reference Figure 1-Figure 3 The method described. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functionality of program modules can be combined or separated between program modules as needed. Machine-executable instructions for program modules can be executed on local or distributed devices. In distributed devices, program modules can be located in local and remote storage media.
[0072] The program code for executing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing equipment so that when the program code is executed by the processor or controller, the function / operation specified in the flow chart and / or block diagram is realized. The program code can be executed fully on the machine as an independent software package, partially on the machine, partially on a remote machine, or all on a remote machine or server.
[0073] In the context of this application, computer program codes or related data may be carried by any suitable carrier to enable a device, apparatus or processor to perform various processes and operations as described above. Examples of carriers include signals, computer-readable media, etc.
[0074] A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. Computer-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or apparatuses, or any suitable combination of the foregoing. More specific examples of computer-readable storage media include an electrical connection having one or more wires, a portable computer floppy disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0075] As used herein, unless the context clearly indicates otherwise, the terms "a," "an," "an," and / or "the" are not intended to refer to the singular but may include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the steps and elements specifically identified, and these steps and elements do not constitute an exclusive list. A method or apparatus may also include other steps or elements.
[0076] At the same time, this application uses specific terms to describe the embodiments of this application. For example, "one embodiment," "an embodiment," and / or "some embodiments" refer to a certain feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that "one embodiment," "an embodiment," or "an alternative embodiment" mentioned twice or multiple times in different locations in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application may be appropriately combined.
[0077] Unless otherwise specified, the relative arrangement of the parts and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present application. Meanwhile, it should be understood that, for ease of description, the sizes of the various parts shown in the accompanying drawings are not drawn according to actual proportional relationships. Technology, methods and equipment known to those of ordinary skill in the relevant art may not be discussed in detail, but in appropriate cases, the technology, methods and equipment should be considered as a part of the specification. In all examples shown and discussed here, any specific value should be interpreted as being merely exemplary, rather than as a limitation. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar numbers and letters represent similar items in the following drawings, and therefore, once an item is defined in an accompanying drawing, it does not need to be further discussed in subsequent drawings.
[0078] In addition, although the terms used in this application are selected from commonly known and commonly used terms, some of the terms mentioned in this specification may be selected by the applicant at his or her discretion, and their detailed meanings are explained in the relevant parts of the description herein. In addition, it is required that this application be understood not only by the actual terms used, but also by the meaning implied by each term.
[0079] In addition, although operations are described in a specific order, this should not be understood as requiring that these operations be performed in the specific order or sequence shown, or that all operations shown be performed to obtain the desired result. In some cases, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are involved in the above discussion, these details should not be interpreted as limiting the scope of the application, but rather as describing features specific to a particular embodiment. Some features described in the context of a separate embodiment may also be combined in a single embodiment. On the contrary, the various features described in the context of a single embodiment may also be implemented individually or in any suitable subcombination in multiple embodiments.
[0080] Although the present application has been described with reference to the current specific embodiments, those skilled in the art should recognize that the above embodiments are merely used to illustrate the present application, and that various equivalent changes or substitutions may be made without departing from the spirit of the present application. Therefore, any changes or modifications to the above embodiments that fall within the spirit of the present application will fall within the scope of the present application.
Claims
1. A CFD automatic calculation system, characterized in that: include: A graphical user interface, configured to receive input parameters configured by a user and store the input parameters as a JSON interface parameter file; A mapping system for mapping the JSON interface parameter file to an OpenFOAM dictionary file; OpenFOAM, for performing CFD calculations according to the OpenFOAM dictionary file and returning calculation results to the graphical user interface; Wherein, the mapping system includes: A normalization processing unit, configured to perform parameter conversion on the JSON interface parameter file through a mapping table from interface parameters to OpenFOAM parameters to obtain a JSON parameter intermediate file; A file list generating unit is configured to generate a file list according to the JSON parameter intermediate file, wherein the file list includes a plurality of records, each record including a file name, a generation condition, and a folder to which it belongs. The meaning of each record is that when the generation condition is judged to be true, a file with a file name is generated in the folder to which it belongs, which is recorded as a transfer file. The file name corresponds to the OpenFOAM example file name, and the value of the generation condition is composed of a plurality of input parameters in the JSON parameter intermediate file; a first parameter mapping form generating unit, configured to generate a first parameter mapping form for each transfer file in the file list, wherein the first parameter mapping form includes: a sequence number, a parameter name, a parameter type, a previous level, a "parameter value or position," and a generation condition; a parameter corresponding to the parameter name will be generated only when the generation condition in the first parameter mapping form is met; A parameter mapping unit is used to obtain an OpenFOAM dictionary file of each transfer file according to the file list, the first parameter mapping form and the JSON parameter intermediate file.
2. The CFD automatic calculation system according to claim 1, wherein: The value of the first parameter mapping form is determined as follows: The parameter names in the first parameter mapping form are all parameter names that appear in the transfer file; The parameter type is the corresponding JSON format data type; When a parameter has nested data types, the serial number of the nested outer parameter is entered into the "previous level" of the nested inner parameter; When the parameter type is a constant, enter the parameter value in the "Parameter value or position" field. In other cases, enter the parameter's position in the JSON parameter intermediate file. The values of the generation conditions in the first parameter mapping form are determined in the following manner: required parameter items are set to true, and the values of the generation conditions of other parameters are determined by the parameters in the JSON parameter intermediate file.
3. The CFD automatic calculation system according to claim 2, wherein: The "parameter value or position" in the first parameter mapping form of different transfer files corresponds to the same parameter position in the JSON parameter intermediate file, so that the first parameter mapping form establishes a one-to-many relationship between the JSON parameter and the dictionary parameter.
4. The CFD automatic calculation system according to claim 1, wherein: The parameter mapping unit is used to obtain the OpenFOAM dictionary file of each transfer file according to the file list, the first parameter mapping form and the JSON parameter intermediate file, including: Generate multiple transfer files according to the file list, and find the first parameter mapping table corresponding to each transfer file; Traverse the first parameter mapping form, fill in the parameter default value for each parameter item in turn or get the parameter value from the JSON parameter intermediate file to obtain the OpenFOAM dictionary file of each transfer file.
5. The CFD automatic calculation system according to claim 1, wherein: The mapping system further comprises: A data structure mapping unit is used to convert the JSON structure file generated by the parameter mapping unit into the OpenFOAM dictionary file. The data structure mapping unit has built-in data structure mapping rules, and the JSON structure file is converted into the OpenFOAM dictionary file through the data structure mapping rules. The data structure mapping rules include conversion rules from JSON format to OpenFOAM format for multiple data types, and the multiple data types include string / numeric arrays, object arrays, and two-dimensional arrays.
6. The CFD automatic calculation system according to claim 1, wherein: The mapping system further includes a data verification unit, configured to: Identify a first parameter mapping table corresponding to each transfer file; Traverse the first parameter mapping form, and determine whether the parameter values can be obtained from the JSON parameter intermediate file for parameters whose data types are not constants and whose generation conditions are not false; If the parameter value cannot be obtained, the parameter name is recorded, and the missing parameter is prompted to the graphical user interface when the function is finally returned.
7. The CFD automatic calculation system according to claim 1, wherein: The mapping system further comprises: A second parameter mapping form generating unit is used to generate a second parameter mapping form, wherein the second parameter mapping form includes: a serial number, a parameter name, a parameter type, a previous level, a mapping parameter name, a folder, and required items, wherein the parameter name is the name in the JSON parameter intermediate file, the mapping parameter name is the parameter name in the OpenFOAM dictionary file to be generated, the folder indicates the storage path and file name of the parameter in the dictionary, All indicates that the parameter is required in all files, and the required item indicates whether the parameter must exist in the file; The parameter mapping unit is further configured to obtain an OpenFOAM dictionary file for each transfer file according to the file list, the second parameter mapping form and the JSON parameter intermediate file.
8. The CFD automatic calculation system according to claim 1, wherein: The hierarchy of the parameters in the JSON interface parameter file is consistent with the structure of the graphical user interface, and the hierarchy of the parameters in the JSON interface parameter file includes geometry, mesh, physics, solution, and display.
9. A method for automatically generating an OpenFOAM dictionary file, characterized in that: include: Receive user-configured input parameters through a graphical user interface, and store the input parameters as a JSON interface parameter file; Perform parameter conversion on the JSON interface parameter file through a mapping table from interface parameters to OpenFOAM parameters to obtain a JSON parameter intermediate file; Generate a file list according to the JSON parameter intermediate file, the file list includes multiple file records, each file record includes a file name, a generation condition, and a folder to which it belongs. The meaning of each record is that when the generation condition is judged to be true, a file with a file name is generated in the folder to which it belongs, which is recorded as a transfer file. The file name corresponds to the OpenFOAM example file name, and the value of the generation condition is composed of multiple input parameters in the JSON parameter intermediate file; Generate a first parameter mapping form for each transferred file in the file list, wherein the first parameter mapping form includes: a sequence number, a parameter name, a parameter type, a previous level, a "parameter value or position," and a generation condition. When the generation condition in the first parameter mapping form is met, the parameter corresponding to the parameter name is generated; An OpenFOAM dictionary file for each transfer file is obtained according to the file list, the first parameter mapping form and the JSON parameter intermediate file.
10. An automatic generation device for OpenFOAM dictionary files, characterized in that: include: a memory for storing instructions executable by the processor; A processor is configured to execute the instructions to implement the OpenFOAM dictionary file automatic generation method according to claim 9.