A method for outputting detailed information about OpenFOAM boundary surface meshes
By setting time control functions and reading normalized mesh files in OpenFOAM, detailed boundary surface mesh information is extracted and output, solving the problem of low automation in existing technologies and achieving efficient, convenient extraction and accurate saving of boundary surface mesh information.
Patent Information
- Application Number
- CN202610632666.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-09
- Publication Date
- 2026-07-03
AI Technical Summary
Existing technologies have low automation and poor scalability when extracting detailed boundary surface mesh information, making it difficult to accurately identify and extract information from boundary surfaces in complex geometries, unstructured meshes, or dynamic meshes, thus affecting the reliability of subsequent calculations and analyses.
This paper provides a method for outputting detailed information of OpenFOAM boundary surface meshes. By setting the root directory of the OpenFOAM example, accessing the time control function, reading the normalized mesh file, creating a global blank file, and extracting and outputting the geometric, topological, and physical information of the boundary surface mesh, it supports saving in the formats of commonly used data processing software.
It enables efficient and convenient extraction of boundary surface mesh information, reduces operational complexity, supports users in flexibly extracting multi-dimensional information of specified boundary surfaces, and improves the efficiency and accuracy of data post-processing.
Smart Images

Figure CN122334094A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computational fluid dynamics data post-processing technology, and in particular to a method for outputting detailed information of OpenFOAM boundary surface meshes. Background Technology
[0002] With the rapid development of computer hardware and software technologies, Computational Fluid Dynamics (CFD) has been widely applied in various fields such as aerospace, weaponry, shipbuilding, energy and power, vehicle transportation, heavy machinery, and electronics. OpenFOAM, as an object-oriented open-source CFD software package, features convenient modular design, powerful multiphysics coupling, flexible code customization, and efficient parallel computing capabilities, and has received widespread attention from academia and industry in recent years. Compared to commonly used commercial CFD software such as ANSYS Fluent, STAR-CD, STAR-CCM+, and CFX, which have closed algorithms and expensive copyrights, OpenFOAM's source code is completely open, requiring no additional software fees. It also supports polyhedral meshes, can handle complex geometric configurations, and possesses powerful simulation and analysis capabilities for flow, combustion, heat transfer, and other multiphysics coupling problems.
[0003] In numerical simulations, detailed information about boundary surface meshes plays a crucial role in data processing and result analysis. For example, the geometric information of the boundary surface mesh (such as cell center coordinates, normal vectors, and areas) and connectivity information (such as cell index numbers and their associated mesh numbers) are fundamental for fine-grained mesh positioning and manipulation. Specifically, when calculating scalar or vector fluxes such as mass, momentum, and energy on a physical boundary surface, the normal vector and area information of each cell on that physical boundary surface are relied upon to achieve accurate integration. The integration of aerodynamic forces and aerodynamic torques depends on the mapping relationship between the pressure and shear stress of each cell on the physical boundary surface and its area and spatial position. Wall heat flux analysis requires combining the wall temperature gradient, heat flux model, and boundary surface geometric characteristics to quantitatively assess the thermal load on complex structural surfaces. Detailed geometric, topological, and physical information about the boundary surface mesh is key to achieving consistent spatial mapping and fusion of different physical field quantities.
[0004] However, existing technologies for extracting detailed boundary surface mesh information typically rely on interactive operations of visualization software or customized script tools for fixed features. These methods suffer from low automation, poor scalability, and difficulty in directly coupling with the numerical solution process and subsequent data processing. This is particularly true in numerical simulations of complex geometries, unstructured meshes, or dynamic meshes, where the number of boundary surfaces is numerous, their topological relationships are complex, and they may change dynamically over time. Existing methods struggle to completely and accurately identify and extract key information from boundary surfaces, easily leading to issues such as boundary omissions, inconsistent numbering, or inaccurate geometric feature extraction. This affects the reliability of subsequent boundary surface flux calculations and result analysis, and particularly fails to meet the demands of complex numerical simulations for unified, efficient, and accurate extraction of multidimensional information from boundary surface meshes.
[0005] Therefore, there is an urgent need for a method that can identify boundary surfaces according to user-specified requirements and automatically extract the geometric, topological, and physical information of the boundary surface mesh, so as to improve the efficiency and accuracy of data post-processing for boundary surfaces. Summary of the Invention
[0006] The purpose of this invention is to provide a method for outputting detailed information of OpenFOAM boundary surface meshes. This method is designed for complex geometric structures, unstructured meshes, or dynamic mesh problems simulated by OpenFOAM, and can efficiently and conveniently extract the geometric, topological, and physical information of the boundary surface mesh. The results are saved in easily readable formats (such as CSV, DAT, etc.) by commonly used data processing software such as Origin, Tecplot, and MATLAB. This supports subsequent post-processing calculations and result analysis for specified physical quantities on a specified boundary surface.
[0007] To achieve the above objectives, this invention provides a method for outputting detailed OpenFOAM boundary surface mesh information, comprising the following steps: S1. Set the current root directory of the OpenFOAM instance, access the OpenFOAM standard time control function, add a time selector, and allow users to specify specific time steps; S2. Read the normalized grid file stored discretely in OpenFOAM and create the simulation grid; S3. Create a global blank file in the root directory of the example to store the output results of the geometry, topology and physical information of all mesh elements on the specified physical boundary surface at each time step; S4. Write the time variable name and the variable names corresponding to the geometric, topological and physical information of all surface elements on the boundary surface that the program will output on the first line of the global blank file. S5. Define the name of the physical boundary surface of interest as a character type, and find the name of the boundary surface in the discrete mesh file boundary that matches the name of the physical boundary surface of interest. S6. Read the physical field quantity data that needs to be output on the specified boundary surface, which are stored independently in the time folder in the form of OpenFOAM standard output files, and traverse all specified times. S7. Extract the geometric parameters, topological information and physical quantities of all mesh elements from the specified physical boundary surface. All data access uses the const data type. S8. Write the geometric, topological, and physical information of all grid elements corresponding to the variable names at the current time into the global blank file according to the index number of the grid elements on the physical boundary surface. S9. Traverse all elements of the specified physical boundary surface and all time points, complete data reading and output, print information on the screen, indicate that the operation is complete, and then the program ends.
[0008] Preferably, S1 is as follows: The time object runTime is constructed by accessing the createTime.H header file. The time object runTime is initialized by parsing the controlDict control dictionary, which controls the simulation time step and determines the various times when the simulation results are output. The time selector supports the -constant, -latestTime, -noZero, and -time options. The -constant option includes the constant / directory under the root directory, the -latestTime option is used to specify the final time, the -noZero option is used to exclude time 0, and the -time option, combined with a time list, allows for flexible selection of any time.
[0009] Preferably, in S2, the information carried by the discretely stored normalized mesh file in OpenFOAM includes node coordinates, mesh cell owner, adjacent mesh cells, mesh surfaces, and boundary condition definitions; The created simulation mesh can be a one-dimensional mesh, a two-dimensional mesh, or a three-dimensional mesh. The one-dimensional mesh is a structured mesh, and the two-dimensional or three-dimensional mesh is a structured or unstructured mesh. The created computational sample grid can be either a static or dynamic grid: if the computational sample grid used is a static grid, then a unique set of grids is read in at the initial time; if the computational sample grid used is a dynamic grid, then the grid for the current time is read in each time folder.
[0010] Preferably, in S3, the global blank file created is in .dat format or a user-defined format; The geometric, topological, and physical information of all facets on the physical boundary mesh can be arbitrarily sorted according to user preferences. Intermediate results are stored as any number of time folders. The OpenFOAM standard forAll loop is used to read all folders sequentially from the initial time in ascending order until the final time. If you are interested in mesh information on multiple physical boundary surfaces, the number of global blank files created is the same as the number of physical boundary surfaces of interest, in order to store the output results of each physical boundary surface.
[0011] Preferably, in S4, the geometric, topological, and physical information of the boundary surface mesh is selected according to user needs, or new variables are defined based on the existing output quantities, with each variable name separated by a space; Physical quantities can be scalars, vectors, or tensors. Scalars include the area of a surface element, temperature, and pressure. Vectors include the center coordinates of the surface element, the normal vector of the surface element, and velocity. Tensors include viscous stress and shear stress. If a physical quantity is a vector or a tensor, then the variable names of each component of the physical quantity are defined. The geometric parameters and corresponding variables of all surface elements on the boundary surface of interest in nozzle flow, including center coordinates. , , ,area and normal vector , , ; The topological information of all face elements and their corresponding variable names include the index number faceId and the cell number of the mesh to which they belong; Physical field quantities and their corresponding variable names include temperature and pressure .
[0012] Preferably, in S5, the boundary surface name is defined using the label keyword embedded in OpenFOAM and is limited to a character type. This boundary surface name is completely consistent with the boundary surface name defined in the mesh file in S2, and the boundary surface of interest is located by string matching. The boundary face name, boundary type, starting mesh element number, and number of mesh elements defined in the mesh file are all in the constant / polyMesh / boundary file for static meshes, and in the polyMesh / boundary file under each time folder directory for dynamic meshes. The OpenFOAM standard findPatchID boundary lookup function searches for and matches boundary face names defined by the label keyword in the mesh file; if an incorrect boundary face name is defined, it returns an error message and terminates the process.
[0013] Preferably, in S6, the OpenFOAM standard file read / write mechanism IOdictionary class is used for file read and write. For field quantity data already stored in each time folder, the file is read-only and not written; for new physical quantities that need to be calculated, the file is written only and not read. Following the order of the boundary surface physical quantities written by S4, read the physical field quantity data in the specified time folder sequentially, or define and calculate new physical variables in the specified time folder through the field quantity calculation of the OpenFOAM standard; The stored physical quantities, calculated intermediate quantities, or final quantities read at each time point correspond to the physical quantities on the boundary surfaces of interest to S4: Assuming common read Each moment, every moment If there are equivalent physical scalars, then the total number of files read is × The equivalent physical scalar is denoted as the number of scalar fields plus the number of vector fields multiplied by the number of effective vector field components, plus the number of tensor fields multiplied by the number of effective tensor field components.
[0014] Preferably, in S7, the geometric parameters, topological information, and physical quantities of all mesh elements on the specified physical boundary surface corresponding to S4 are extracted from the normalized mesh file stored in OpenFOAM discrete storage. Relevant information is extracted by calling several boundary functions embedded in OpenFOAM, including extracting the area vector of all facets by using the mesh.Sf() function (which is the facet normal multiplied by the area); extracting the area scalar of all facets by using the mesh.magSf() function; and extracting the mesh cell number to which the boundary facet belongs by using the mesh.owner() function. When accessing detailed geometric, topological, and physical information on the physical boundary surface, the const data type is used to ensure that only data access is allowed and no modification permissions are permitted.
[0015] Preferably, in S8, for each time step, a forAll loop iterates through all the mesh elements contained on the boundary surface of interest, indexed by the name of the physical boundary surface of interest defined in S5, and iterates through all the meshes on the boundary surface in turn. For static meshes, the geometric, topological, and physical information written to the global file at each time step has the same data structure; at all time steps, the information of each mesh element is written sequentially according to a fixed mesh element numbering order. For dynamic meshes, the geometric, topological, and physical information written to the global file at different times usually has different data structures.
[0016] Preferably, in S9, the result is output once for each loop time point, and a new blank line is inserted at the same time; starting from the initial time point, the time increments sequentially to the final time point until the program ends; After the program finishes running, it obtains one or more global data files. These global data files contain the geometric parameters, topological information, and physical quantities of the specified boundary surface at each time step. Assuming... The number of mesh elements written at any given time is Then the total number of data points contained in the global file is .
[0017] Therefore, the present invention employs the above-described method for outputting detailed OpenFOAM boundary surface mesh information, and the beneficial effects are as follows: (1) This invention can automatically and in batches extract the geometric parameters, topological information and physical field quantities of the boundary surface mesh for any complex physical boundary in OpenFOAM simulation results, which significantly reduces the operational complexity of the post-processing process and saves a lot of time and cost.
[0018] (2) According to the actual needs of users, the present invention can flexibly and accurately extract any specified geometric, topological and physical information on any specified physical boundary surface, and support the dynamic monitoring and real-time analysis of multiple target parameters on key boundary surfaces.
[0019] (3) This invention establishes the correspondence between boundary surface mesh geometric parameters, topology and physical field quantities, and outputs them in common formats supported by mainstream data processing software such as CSV and DAT, which greatly facilitates subsequent visualization or result analysis.
[0020] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0021] Figure 1 This is an overall flowchart of an embodiment of a method for outputting detailed OpenFOAM boundary surface mesh according to the present invention; Figure 2 This is a schematic diagram of the configuration of JPL nozzle gas phase flow simulation according to an embodiment of a method for outputting detailed OpenFOAM boundary surface mesh information of the present invention; Figure 3 This is an embodiment of the method for outputting detailed OpenFOAM boundary surface mesh information of the present invention, showing the instantaneous pressure spatial distribution on the upper wall of the JPL nozzle; Figure 4 This is an embodiment of a method for outputting detailed OpenFOAM boundary surface mesh information, which shows the instantaneous spatial temperature distribution on the upper wall of a JPL nozzle. Detailed Implementation
[0022] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0023] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects.
[0024] This invention addresses the challenge of accurately extracting boundary surface mesh information due to its dispersed nature and low processing efficiency when OpenFOAM simulates complex geometries, unstructured meshes, or dynamic meshes. It provides an efficient and convenient method for automatically extracting and outputting detailed boundary surface mesh information.
[0025] The method of this invention is written and compiled into an executable file using the C++ computer language, maintaining the same organizational structure as the existing OpenFOAM solver. Taking the JPL nozzle gas phase flow problem based on OpenFOAM simulation as an example, it includes the following steps: S1. Set the current working path of OpenFOAM, i.e., the root directory of the computational instance, connect to the standard time control functions of OpenFOAM, add a time selector, and allow users to specify specific time steps: The time object `runTime` is constructed by accessing the `createTime.H` header file. This time object `runTime` is initialized by parsing the `controlDict` control dictionary, thereby enabling precise control of the simulation time step (progressing from the initial moment to the final moment) and determining the various moments of the simulation result output.
[0026] Furthermore, by adding specific options to specify a particular time, the time selector of this invention supports the -constant option, the -latestTime option, the -noZero option, and the -time option. Among them, the -constant option can include the constant / directory under the root directory, the -latestTime option can be used to specify the final time, the -noZero option can be used to exclude the time 0, and the -time option plus a time list can realize the flexible selection of any specific time.
[0027] S2. Read the normalized grid file stored discretely in OpenFOAM and create a simulation grid, which can be a structured or unstructured grid, or a static or dynamic grid.
[0028] In OpenFOAM, the information carried by the discretely stored normalized mesh file includes node coordinates, mesh cell owners, adjacent mesh cells, mesh faces, and boundary condition definitions. It can be generated by OpenFOAM's built-in blockMesh tool, or imported by third-party software and converted to OpenFOAM's native file format.
[0029] The computational grid created by this invention can be a one-dimensional grid, a two-dimensional grid, or a three-dimensional grid. The one-dimensional grid is a structured grid, and the two-dimensional or three-dimensional grid can be either a structured grid or an unstructured grid.
[0030] The created computational grid can be a static grid or a dynamic grid: if the computational grid used is a static grid, that is, the same grid is used at all times, then a unique set of grids is read in at the initial time; if the computational grid used is a dynamic grid, then the grid for the current time is read in each time folder.
[0031] S3. Create a global blank file in the root directory of the example to store the output results of the geometry, topology and physical information of all mesh elements on the specified physical boundary surface at each time step.
[0032] The format of the created global blank file is unrestricted, such as the .dat data format, to facilitate reading by common data post-processing software such as Origin and Tecplot. Users can also customize the output to any other file format according to their needs.
[0033] The order of the geometric, topological, and physical information of all elements on the physical boundary mesh is unrestricted, and different variables can be arbitrarily ordered according to user preferences; variable X can be placed in the first, second, third, etc.
[0034] Intermediate results are stored as any number of time folders. The OpenFOAM standard forAll loop is used to read all folders sequentially from the initial time in ascending order until the final time, without requiring the time folders to be distributed at equal intervals.
[0035] If you are interested in mesh information on multiple physical boundary surfaces, such as inlets, outlets, and walls, then the number of global blank files you need to create is the same as the number of physical boundary surfaces you are interested in, in order to store the output results of each physical boundary surface.
[0036] S4. Write the time variable name and the variable names corresponding to the geometric, topological and physical information of all surface elements on the boundary surface that the program will output on the first line of the global blank file.
[0037] The geometric parameters and corresponding variables of all surface elements on the boundary surface of interest in nozzle flow, including center coordinates. , , ,area and normal vector , , .
[0038] The topological information of all face elements and their corresponding variable names include the index number faceId and the cell number of the mesh to which they belong.
[0039] Physical field quantities and their corresponding variable names include temperature and pressure .
[0040] Users can also select other arbitrary geometric, topological, and physical information of the boundary surface mesh according to their needs, or define new variables based on existing output quantities. Variable names are separated by spaces so that the data post-processing software can accurately identify the different variable names.
[0041] Physical quantities can be scalars, vectors, and tensors. Scalars include the area of a surface element, temperature, and pressure. Vectors include the center coordinates of the surface element, the normal vector of the surface element, and velocity. Tensors include viscous stress and shear stress. If a physical quantity is a vector or a tensor, then the variable names of each component of the physical quantity need to be defined. S5. Define the name of the physical boundary surface of interest as a "character" type, and search for the name of the boundary surface in the discrete mesh file boundary that matches the name of the physical boundary surface of interest; otherwise, it is invalid.
[0042] The boundary surface name is defined using the "label" keyword embedded in OpenFOAM and is limited to a character type. This boundary surface name must be completely consistent with the boundary surface name defined in the mesh file in S2, and the boundary surface of interest is located by string matching.
[0043] The number of definable boundary surfaces is unlimited. You can focus on the geometric, topological, and physical information of a single boundary surface or multiple boundary surfaces simultaneously. However, all defined boundary surfaces must actually exist in the example mesh file.
[0044] The boundary face name, boundary type, starting mesh element number, and number of mesh elements defined in the mesh file are all in the constant / polyMesh / boundary file for static meshes, and in the polyMesh / boundary file under each time folder directory for dynamic meshes.
[0045] The OpenFOAM standard's findPatchID boundary lookup function searches for and matches boundary face names defined by the label keyword in the mesh file; if an incorrect boundary face name is defined, the algorithm returns an error message and terminates.
[0046] S6. Read the physical field data that need to be output on the specified boundary surface, which are stored independently in the time folder in the form of OpenFOAM standard output files, and traverse all specified times.
[0047] File reading and writing are performed using the IOdictionary class, the standard file reading and writing mechanism of OpenFOAM. For field quantity data already stored in each time folder, the file is read-only; for new physical quantities that need to be calculated, the file is written without reading.
[0048] Following the order of the boundary surface physical quantities written by S4, the physical field data in the specified time folder are read sequentially, or new physical variables can be defined and calculated in the specified time folder through the field quantity calculation of the OpenFOAM standard.
[0049] There is no limit to the number of stored physical quantities, calculated intermediate quantities, or final quantities read at each moment. These physical quantities only need to correspond to the physical quantities on the boundary surfaces of interest to S4. Assuming common read Each moment, every moment If there are equivalent physical scalars, then the total number of files read is × The equivalent physical scalar is denoted as the number of scalar fields plus the number of vector fields multiplied by the number of effective vector field components (1 for one dimension, 2 for two dimensions, and 3 for three dimensions), plus the number of tensor fields multiplied by the number of effective tensor field components (1 for one dimension, 4 for two dimensions, and 9 for three dimensions).
[0050] S7. Extract the geometric parameters, topological information and physical quantities of all mesh elements from the specified physical boundary surface. All data access uses the const data type to avoid destroying the original data.
[0051] Extract the geometric parameters, topological information, and physical quantities of all grid elements on the specified physical boundary surface from the normalized grid file of OpenFOAM discrete storage. The information to be extracted corresponds to the information of interest in the fourth step.
[0052] Relevant information can be extracted by directly calling several boundary functions embedded in OpenFOAM, including extracting the area vector of all facets using the mesh.Sf() function (which is the facet normal multiplied by the area); extracting the area scalar of all facets using the mesh.magSf() function; and extracting the mesh cell number to which the boundary facet belongs using the mesh.owner() function.
[0053] When accessing detailed geometric, topological, and physical information on the physical boundary surface, the `const` data type is used to ensure that only data access is allowed, not modification. This protects the original OpenFOAM data (including the mesh and calculation results) from being corrupted by the boundary surface information extraction operations of this invention.
[0054] S8. Write the geometric, topological, and physical information of all grid elements corresponding to the variable names at the current time into the global blank file according to the index number of the grid elements on the physical boundary surface.
[0055] For each time step, a forAll loop iterates through all mesh elements contained on the boundary surface of interest. Indexed by the name of the physical boundary surface of interest as defined in S5, all meshes on that boundary surface are traversed sequentially.
[0056] For static meshes, the geometric, topological, and physical information written to the global file at each time step has the same data structure; at all times, the information of each mesh element is written sequentially according to a fixed mesh element number order (generally from smallest to largest).
[0057] For dynamic grids (i.e., different computational grids are used at different times, such as dynamic grids, adaptive grid densification, and grid topology changes), the geometric, topological, and physical information written to the global file at different times usually has different data structures.
[0058] S9. Traverse all elements of the specified physical boundary surface and all time points, complete data reading and output, print information on the screen, indicate that the operation is complete, and then the program ends.
[0059] The program outputs a result at each loop iteration and inserts a blank newline. Starting from the initial time, the time increments sequentially until the end time, at which point the program terminates.
[0060] After the program finishes running, it obtains one or more global data files. The global data files contain the geometric parameters, topological information and physical field quantities of the specified boundary surface at each time step, which can be further analyzed to understand their evolution over time.
[0061] Assumption The number of mesh elements written at any given time is Then the total number of data points contained in the global file is .
[0062] After completing numerical simulations using OpenFOAM, users can utilize this invention to extract a large amount of geometric parameters, topological information, and physical quantities from the boundary surface mesh. The flowchart of a method for outputting detailed OpenFOAM boundary surface mesh information according to this invention is as follows: Figure 1 As shown.
[0063] First, the necessary time parameter control file for the OpenFOAM example is read, including the createTime.H library file to create the time object runTime. The time object is initialized by reading the control dictionary controlDict, thereby controlling the time step (progressing from the initial time to the final time according to the time increment) and the output of the result (the time and frequency of the result written out).
[0064] Secondly, the discretized mesh file conforming to the OpenFOAM specification is read. This mainly includes the points file containing the coordinates of all mesh nodes, the owner file containing the owner information of the mesh cells, the neighbor file containing the information of adjacent mesh cells, the faces file containing the information of the mesh faces, and the boundary file containing the information of the mesh boundaries. These files together form the OpenFOAM structured or unstructured mesh and are topologically connected according to specific rules.
[0065] Next, determine whether the simulation grid is static (the grid does not change during the calculation process, and a single grid is used for all time points) or dynamic (the grid topology or resolution changes at different time points). If it is a static grid, a unique grid is read in at the initial time point. If it is a dynamic grid, the grid for the current time point is read in before reading the result file for each time point.
[0066] Next, create a global blank file named patchFace.dat in the root directory of the simulation example to store the detailed boundary surface mesh of the upper-wall of the nozzle at each time step. Write the following variable name on the first line of this file: center coordinates. , , ,area normal vector , , ; Index number faceId, grid number cellId; Time ,temperature ,pressure .
[0067] Furthermore, the boundary surface name is defined as upper-wall using the "label" keyword embedded in OpenFOAM and is limited to a character type. The boundary surface named upper-wall is then found using the OpenFOAM standard findPatchID boundary lookup function.
[0068] The OpenFOAM standard forAll function iterates through all time points, sequentially reading the required physical field data from each time point's folder. File reading and writing are handled using the OpenFOAM standard file reading and writing mechanism, the IOdictionary class.
[0069] Finally, within each time folder, the OpenFOAM standard forAll function iterates through all mesh elements on the upper-wall boundary surface, and sequentially writes the geometric parameters, topological information, and physical quantities of the boundary surface mesh at the current time step into the patchFace.dat file according to the mesh element number. During time stepping, the results of the new time step are continuously added to the patchFace.dat file until the program terminates at the final time step.
[0070] Example 1: The physical model of the JPL nozzle gas-phase sub-transition hyperfluidity example is as follows: Figure 2 As shown. A two-dimensional rectangular coordinate system is established with the midpoint of the nozzle throat as the origin, where the length is defined as... Direction and height are defined as follows: Direction. The total length of the nozzle is 9.2. The entrance height is 3.125. , =20.3mm is the throat height. The upstream section of the nozzle is the converging section, which includes three curved sections: a straight section, a circular transition section, and a contraction section. The contraction section... The included angle of the axes is 45°. The middle section is the throat, passing through a radius of 0.625. The arc smoothly transitions between the upstream contraction section and the downstream expansion section. The downstream section is the expansion section, which... The included angle of the axes is 15°. A two-dimensional computational configuration is used to numerically simulate the flow characteristics inside the nozzle, where the upper wall includes all the curves of the expansion section, throat, and expansion section, which is a typical irregular boundary surface.
[0071] Air enters the computational domain through the nozzle inlet, treated as an ideal gas and given a constant mass flow rate. Its mass flow rate is 0.054 kg / s, and the inlet static temperature is 554.6 K. The low-velocity airflow enters the convergent section along the nozzle axis and expands and accelerates, reaching the speed of sound near the nozzle throat. After entering the divergent section, it continues to expand and accelerate, forming a typical nozzle flow field with a wide velocity range (subsonic, transonic, supersonic) and strong compressibility. Simulations are performed using OpenFOAM until the results fully converge. This invention is used to extract the geometric parameters, topology, and physical quantities of the upper wall boundary mesh. Figure 3 This represents the instantaneous pressure spatial distribution on the upper wall of the JPL nozzle. Figure 4 This represents the instantaneous spatial temperature distribution on the upper wall of the JPL nozzle.
[0072] Therefore, the present invention employs the above-mentioned method for outputting detailed OpenFOAM boundary surface mesh information, which can efficiently and conveniently extract and output detailed geometric, topological, and physical information of OpenFOAM simulation results at any intermediate time and any boundary surface mesh, and save it as a single file in a way that is easy to read by commonly used data post-processing software, so as to carry out further visualization and analysis.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for outputting detailed information of OpenFOAM boundary surface mesh, characterized in that, Includes the following steps: S1. Set the current root directory of the OpenFOAM instance, access the OpenFOAM standard time control function, add a time selector, and allow users to specify specific time steps; S2. Read the normalized grid file stored discretely in OpenFOAM and create the simulation grid; S3. Create a global blank file in the root directory of the example to store the output results of the geometry, topology and physical information of all mesh elements on the specified physical boundary surface at each time step; S4. Write the time variable name and the variable names corresponding to the geometric, topological and physical information of all surface elements on the boundary surface that the program will output on the first line of the global blank file. S5. Define the name of the physical boundary surface of interest as a character type, and find the name of the boundary surface in the discrete mesh file boundary that matches the name of the physical boundary surface of interest. S6. Read the physical field quantity data that needs to be output on the specified boundary surface, which are stored independently in the time folder in the form of OpenFOAM standard output files, and traverse all specified times. S7. Extract the geometric parameters, topological information and physical quantities of all mesh elements from the specified physical boundary surface. All data access uses the const data type. S8. Write the geometric, topological, and physical information of all grid elements corresponding to the variable names at the current time into the global blank file according to the index number of the grid elements on the physical boundary surface. S9. Traverse all elements of the specified physical boundary surface and all time points, complete data reading and output, print information on the screen, indicate that the operation is complete, and then the program ends.
2. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 1, characterized in that, S1 specifically refers to: The time object runTime is constructed by accessing the createTime.H header file. The time object runTime is initialized by parsing the controlDict control dictionary, which controls the simulation time step and determines the various times when the simulation results are output. The time selector supports the -constant, -latestTime, -noZero, and -time options. The -constant option includes the constant / directory under the root directory, the -latestTime option is used to specify the final time, the -noZero option is used to exclude time 0, and the -time option, combined with a time list, allows for flexible selection of any time.
3. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 2, characterized in that, In S2, the information carried by the discretely stored normalized mesh file in OpenFOAM includes node coordinates, mesh cell owner, adjacent mesh cells, mesh surfaces, and boundary condition definitions; The created simulation mesh can be a one-dimensional mesh, a two-dimensional mesh, or a three-dimensional mesh. The one-dimensional mesh is a structured mesh, and the two-dimensional or three-dimensional mesh is a structured or unstructured mesh. The created computational sample grid can be either a static or dynamic grid: if the computational sample grid used is a static grid, then a unique set of grids is read in at the initial time; if the computational sample grid used is a dynamic grid, then the grid for the current time is read in each time folder.
4. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 3, characterized in that, In S3, the format of the created global blank file is either .dat or a user-defined format. The geometric, topological, and physical information of all facets on the physical boundary mesh can be arbitrarily sorted according to user preferences. Intermediate results are stored as any number of time folders. The OpenFOAM standard forAll loop is used to read all folders sequentially from the initial time in ascending order until the final time. If you are interested in mesh information on multiple physical boundary surfaces, the number of global blank files created is the same as the number of physical boundary surfaces of interest, in order to store the output results of each physical boundary surface.
5. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 4, characterized in that, In S4, users can select the geometric, topological, and physical information of the boundary surface mesh according to their needs, or define new variables based on existing output quantities, with each variable name separated by a space. Physical quantities can be scalars, vectors, or tensors. Scalars include the area of a surface element, temperature, and pressure. Vectors include the center coordinates of the surface element, the normal vector of the surface element, and velocity. Tensors include viscous stress and shear stress. If a physical quantity is a vector or a tensor, then the variable names of each component of the physical quantity are defined. The geometric parameters and corresponding variables of all surface elements on the boundary surface of interest in nozzle flow, including center coordinates. , , ,area and normal vector , , ; Topological information for all face elements and their corresponding variable names, including index numbers. faceId and the grid number cellId ; Physical field quantities and their corresponding variable names include temperature and pressure .
6. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 5, characterized in that, In S5, the boundary surface name is defined by the label keyword embedded in OpenFOAM and is limited to a character type. This boundary surface name is completely consistent with the boundary surface name defined in the mesh file in S2, and the boundary surface of interest is located by string matching. The boundary face name, boundary type, starting mesh element number, and number of mesh elements defined in the mesh file are all in the constant / polyMesh / boundary file for static meshes, and in the polyMesh / boundary file under each time folder directory for dynamic meshes. The OpenFOAM standard findPatchID boundary lookup function searches for and matches boundary face names defined by the label keyword in the mesh file; if an incorrect boundary face name is defined, it returns an error message and terminates the process.
7. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 6, characterized in that, In S6, the IOdictionary class, a file read / write mechanism based on the OpenFOAM standard, is used for file reading and writing. For field quantity data already stored in each time folder, the file is read-only and not written; for new physical quantities that need to be calculated, the file is written only and not read. Following the order of the boundary surface physical quantities written by S4, read the physical field quantity data in the specified time folder sequentially, or define and calculate new physical variables in the specified time folder through the field quantity calculation of the OpenFOAM standard; The stored physical quantities, calculated intermediate quantities, or final quantities read at each time point correspond to the physical quantities on the boundary surfaces of interest to S4: Assuming common read Each moment, every moment If there are equivalent physical scalars, then the total number of files read is × The equivalent physical scalar is denoted as the number of scalar fields plus the number of vector fields multiplied by the number of effective vector field components, plus the number of tensor fields multiplied by the number of effective tensor field components.
8. The method for outputting detailed OpenFOAM boundary surface mesh information according to claim 7, characterized in that, In S7, the geometric parameters, topological information and physical quantities of all grid elements on the specified physical boundary surface corresponding to S4 are extracted from the normalized grid file stored in OpenFOAM discrete storage. Relevant information is extracted by calling several boundary functions embedded in OpenFOAM, including extracting the area vector of all facets by using the mesh.Sf() function (which is the facet normal multiplied by the area); extracting the area scalar of all facets by using the mesh.magSf() function; and extracting the mesh cell number to which the boundary facet belongs by using the mesh.owner() function. When accessing detailed geometric, topological, and physical information on the physical boundary surface, the const data type is used to ensure that only data access is allowed and no modification permissions are permitted.
9. A method for outputting detailed OpenFOAM boundary surface mesh information according to claim 8, characterized in that, In S8, for each time step, a forAll loop iterates through all the mesh elements contained on the boundary surface of interest, indexed by the name of the physical boundary surface of interest defined in S5, and iterates through all the meshes on that boundary surface in turn. For static meshes, the geometric, topological, and physical information written to the global file at each time step has the same data structure; at all time steps, the information of each mesh element is written sequentially according to a fixed mesh element numbering order. For dynamic meshes, the geometric, topological, and physical information written to the global file at different times usually has different data structures.
10. A method for outputting detailed OpenFOAM boundary surface mesh information according to claim 9, characterized in that, In S9, the result is output once for each time interval of the loop, and a new blank line is inserted at the same time; starting from the initial time, the time increments sequentially to the final time until the program ends. After the program finishes running, it obtains one or more global data files. These global data files contain the geometric parameters, topological information, and physical quantities of the specified boundary surface at each time step. Assuming... The number of mesh elements written at any given time is Then the total number of data points contained in the global file is .
