A method for calculating volume integral of field in openfoam unsteady simulation result
By setting the working root directory in OpenFOAM, reading the mesh file, defining the integration region, and using regular expressions to calculate physical quantities, the problem of customizing the volume integration of the region in OpenFOAM unsteady-state simulations is solved, achieving efficient and flexible data post-processing and visualization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI JIAOTONG UNIV
- Filing Date
- 2026-04-07
- Publication Date
- 2026-06-26
AI Technical Summary
OpenFOAM lacks support for volume integration of general field quantities in user-defined regions during computational fluid dynamics data post-processing. This is especially true in unsteady combustion problems, where existing methods are cumbersome, time-consuming, and prone to errors, and cannot directly output the volume integrals of complex physical quantities.
This paper provides a method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results. The method involves setting the working root directory, reading the mesh file, defining the integration region, calculating the physical quantities using regular expressions, and outputting the results using a global summation function. It supports flexible and efficient volume integration in custom regions.
It significantly reduces the complexity of manual operation, improves the efficiency of data post-processing, supports the calculation and visualization of complex physical quantities, and realizes the monitoring of the evolution law of the volume integral of physical quantities over time in a specific region.
Smart Images

Figure CN121981022B_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 calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results. 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] After completing numerical simulations using OpenFOAM, data processing and result analysis are required, typically involving quantifying the overall physical effects across the entire computational domain or a specific local region. For example, in aerodynamics and fluid mechanics, in the external flow fields of automobiles and aircraft, the design of components is optimized by calculating the combined pressure drag and viscous drag forces acting on a virtual control volume surrounding specific components (such as rearview mirrors or wings). For heat transfer and energy analysis, the overall combustion performance and combustion chamber performance are evaluated by calculating the total heat release rate of fuel combustion within the combustion chamber or the heat release rate under different combustion modes. In studying multiphase flow problems, the mass, momentum, and energy exchange rates between two phases in chemically active phase interface regions are calculated to predict the spatial distribution of the two phases and the flow morphology of the system. These research needs essentially boil down to volume integration of field variables (such as pressure, heat release rate, and two-phase exchange) within a selected three-dimensional spatial region (i.e., the control volume).
[0004] However, implementing the above functions in OpenFOAM's current standard post-processing workflow presents significant inconveniences and limitations. While OpenFOAM's built-in postProcess tool and functionObjects (such as fieldAverage and forces) can perform some predefined integration calculations, they only allow specifying the integration region before calculation. Analyzing new regions requires recalculation, lacking direct support for general field volume integration in user-defined regions. Furthermore, this method only supports volume integration of basic field quantities and not the volume integration of derived field quantities that require regular expressions of other field quantities. Complex physical quantities can only be manually post-processed. This process is cumbersome, time-consuming, and error-prone. For example, when simulating the unsteady combustion of hydrogen, the heat release rate of hydrogen in the supersonic combustion mode within the combustion chamber needs to be calculated. This field quantity is not directly output in the simulation results; it needs to be obtained through a series of calculations before volume integration. OpenFOAM's built-in post-processing method cannot obtain the volume integral of this physical quantity, limiting the analysis and research of the supersonic combustion mode of hydrogen.
[0005] Furthermore, when simulating complex unsteady combustion problems, OpenFOAM outputs a large amount of field data, including Mach number, pressure, heat release rate, and component mass fraction across the entire computational domain. This data is stored separately in different time folders as independent files. Assuming a calculation outputs a total of 2000 time points, obtaining the evolution of the supersonic combustion heat release rate over time would require processing each of these 2000 time points individually. This necessitates extensive manual operations or script support, which is inefficient and prone to errors.
[0006] Therefore, there is an urgent need for a native solution that can directly interface with the output of common OpenFOAM solvers, support the calculation of complex physical quantities, and allow flexible and efficient volume integration of custom 3D regions, so as to improve the efficiency of data post-processing and support the visualization and in-depth analysis of results for engineering problems such as multiphase flow, combustion, and heat transfer. Summary of the Invention
[0007] The purpose of this invention is to provide a method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results, overcoming the limitations of existing technologies in terms of data post-processing complexity, functional flexibility, and computational efficiency. The results are written into a file in a format that is easy to read and visualize using common data post-processing software (such as Origin, Tecplot, and Excel), providing a one-stop solution for the post-processing of a large amount of intermediate time data generated by OpenFOAM unsteady-state numerical simulations, especially for obtaining the evolution law of the volume integral of a specific physical quantity over time within a specific region.
[0008] To achieve the above objectives, this invention provides a method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results, comprising the following steps:
[0009] S1. Set the current working root directory of OpenFOAM, read the mesh file stored in OpenFOAM discrete storage and create the simulation mesh. The mesh file carries node coordinates, mesh cell owner, adjacent mesh cells, mesh surface and boundary condition definition information.
[0010] S2. Access the OpenFOAM standard time control function to read the time information of the numerical simulation corresponding to all time folders in the working root directory;
[0011] S3. Create a global blank file in the working root directory to store the calculation results of the volume integral of a specific physical quantity in a specific calculation region at each time point;
[0012] S4. Write the time variable name and the variable name corresponding to the volume integral of the physical quantity that the program will calculate on the first line of the global blank file.
[0013] S5. Read the field quantity data required for calculating the volume integral of physical quantities, which are stored independently in the time folder as OpenFOAM standard output files.
[0014] S6. Define and calculate the physical quantities of interest and other intermediate physical quantities required to calculate these physical quantities using regular expressions;
[0015] S7. Define the integration region of interest, traverse all grids according to grid number, and calculate the product of the physical quantity of interest and the corresponding grid volume in turn.
[0016] S8. Write the calculation results of the volume integral of the physical quantity of interest over a specific region in the global file in chronological order, and iterate through all time points to complete the output of the results.
[0017] Preferably, in S1, the mesh file is generated by the blockMesh tool that comes with OpenFOAM, or it is imported by third-party software and converted into the OpenFOAM local file format.
[0018] Preferably, in S1, the calculation grid is a one-dimensional grid, a two-dimensional grid, or a three-dimensional grid, wherein the one-dimensional grid is a structured grid, and the two-dimensional or three-dimensional grid uses a structured or unstructured grid.
[0019] The calculation example grid can be either static or dynamic. If a static grid is used, a unique grid is read in at the initial moment and reused throughout the calculation. If a dynamic grid is used, the grids in the corresponding time folders are read sequentially according to the time.
[0020] Preferably, in S2, a time object runTime is constructed by accessing the createTime.H header file. This object is initialized by parsing the controlDict control dictionary, controlling the simulation time step from the initial time to the final time, and determining the various times when the simulation results are output.
[0021] Specific times can be specified by adding options, including the -constant option, which includes the constant / directory under the root directory, the -latestTime option which specifies the final time, the -noZero option which excludes time 0, and the -time option which selects a specific time in conjunction with a time list.
[0022] Preferably, in S3, the format of the global blank file includes .dat data format and other formats adapted for reading by data post-processing software;
[0023] If the volume integral of multiple physical quantities in the same region is calculated at the same time, the order of the physical quantities is not restricted in any way; the multiple physical quantities in the same region include the total heat release rate, the heat release rate in the premixed combustion mode and the heat release rate in the supersonic combustion mode.
[0024] If the volume integral of multiple physical quantities in different regions is calculated, the number of global blank files created is the same as the number of target regions, in order to store the calculation results of the volume integral of physical quantities in the corresponding regions; the multiple physical quantities in different regions include the total heat release rate of the entire combustion chamber, the total mass of fuel in the combustion chamber section after the fuel inlet, and the total mass of products.
[0025] Preferably, in S4, the physical quantity variable name for which the volume integral will be calculated in the hydrogen combustion simulation includes the total heat release rate of hydrogen. Hydrogen premixed combustion heat release rate The heat release rate of hydrogen supersonic combustion Total mass of hydrogen in the combustion chamber The total mass of water produced by the combustion of hydrogen in the combustion chamber ;
[0026] Variable names are separated by spaces to allow data post-processing software to recognize different variable names; the physical quantities to be integrated by volume include scalars, vectors and tensors. If it is a vector or tensor, define the variable names corresponding to each component in the first line of the file.
[0027] Preferably, in S5, the file is read and written using the IOdictionary class, which is the standard file read and write mechanism of OpenFOAM. For the 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.
[0028] Other intermediate physical quantities required to calculate the physical quantities of interest are scalars, vectors, and tensors, which are specified and restricted by the volScalarField, volVectorField, and volTensorField entry keywords in IOdictionary;
[0029] The OpenFOAM standard forAll loop function is used to traverse all calculation times in the working root directory, reading the required field data from each time folder. Assuming a total of [number] times are read... Read at each moment If there are multiple field quantities, then the total number of files read is... ;
[0030] There are no restrictions on the number of stored field quantities to be read at any given time, the number of intermediate or final field quantities to be calculated, or the number of time folders to be read. Furthermore, the time distribution of the time folders is not required to be at equal intervals.
[0031] Preferably, S6 is as follows:
[0032] The physical field quantities of interest are created using the IOdictionary class, which is the file reading and writing mechanism of the OpenFOAM standard. The types of volScalarField, volVectorField, and volTensorField are declared as scalar field, vector field, and tensor field, respectively.
[0033] Temporary field files are neither read nor written; the data is obtained from known field quantity data in S5 through field quantity calculations using the OpenFOAM standard.
[0034] Preferably, S7 is as follows:
[0035] For each time step, all grid cells are traversed using a standard forAll loop embedded in OpenFOAM. Physical regions are filtered by adding if conditions, including range limitations based on grid center coordinates.
[0036] For static grids, the data written to the field quantity file at each time step has the same organizational structure. At all times, the product of the physical quantity of interest and the grid volume of the cell is stored in the temporary field quantity file in a fixed grid number order.
[0037] For dynamic meshes, the data written to the temporary field quantity file at different times has different mesh structures, and the calculation is adapted according to the mesh topology at the current time.
[0038] Preferably, in S8, the field quantities or lists are summed using the OpenFOAM standard global summation function gSum;
[0039] At each loop iteration, the summation result of gSum is output once, and a new blank line is inserted. Starting from the initial time, the time increments sequentially to the final time until the program terminates.
[0040] The order of physical quantities written at each time step is fixed and must be consistent with the order of variable names already written in S4; if the volume integrals of multiple physical quantities in different regions are calculated in S3, the results of different regions are written to their respective files.
[0041] After the program finishes running, it outputs a global data file containing the volume integral calculation results of specific regions and specific physical quantities at various times. This data is used to analyze the evolution of the volume integral of physical quantities over time and to monitor the overall combustion performance of hydrogen and the performance of the combustion chamber.
[0042] Therefore, the present invention employs the above-mentioned method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results, and the beneficial effects are as follows:
[0043] (1) This invention automatically reads a large number of transient result data files for OpenFOAM unsteady simulation results, which significantly reduces the complexity of manual operation or script support and greatly improves the efficiency of data post-processing.
[0044] (2) According to actual needs, the present invention supports specifying a specific integration region by the coordinates of the grid center point, which meets the complex geometric requirements in engineering practice and realizes the volume integration of key parameters in important regions in real time.
[0045] (3) The time information is integrated with the calculation results of the volume integral of physical quantities in a specific region to obtain the time evolution of the volume integral of a specific region and a specific physical quantity, and saved to a file in a format supported by mainstream data processing software.
[0046] 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
[0047] Figure 1 This is an overall flowchart of an embodiment of a method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to the present invention;
[0048] Figure 2 This is a schematic diagram of the simulation problem of the combustion chamber of a variable structure scramjet engine, which is an embodiment of the method for calculating the volume integral of field quantities in the results of OpenFOAM unsteady-state simulation according to the present invention.
[0049] Figure 3 This is a schematic diagram of the time evolution of the total heat release rate of hydrogen in the combustion chamber of a variable structure scramjet engine, as described in Embodiment 1 of the method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results.
[0050] Figure 4 This is a schematic diagram of the time evolution of the heat release rate of hydrogen premixed combustion in the combustion chamber of a variable structure scramjet engine, as described in Embodiment 1 of the method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results.
[0051] Figure 5 This is a schematic diagram of the time evolution of the supersonic combustion heat release rate of hydrogen in the combustion chamber of a variable structure scramjet engine, as described in Embodiment 1 of the method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results according to the present invention. Detailed Implementation
[0052] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0053] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.
[0054] This invention proposes a method for calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results. This method is written in C++ and compiled into an executable file, maintaining consistency with the organizational structure of existing OpenFOAM solvers. Taking the unsteady-state hydrogen combustion problem simulated by OpenFOAM as an example, the method includes the following steps:
[0055] S1. Set the current working path of OpenFOAM, i.e. the working root directory, read the mesh file stored in OpenFOAM discrete storage and create the simulation mesh. The mesh file carries node coordinates, mesh cell owner, adjacent mesh cells, mesh surface and boundary condition definition information.
[0056] Mesh files can be generated by the blockMesh tool that comes with OpenFOAM, or imported by third-party software and converted into the OpenFOAM local file format.
[0057] The computational grid in 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 a structured or unstructured grid.
[0058] The calculation grid can be a static grid or a dynamic grid. If the calculation uses a static grid (the same grid is used at all times), a unique grid is read in at the initial time and reused throughout the calculation. If the calculation uses a dynamic grid, the grids in the corresponding time folders are read in sequence according to the time.
[0059] S2. Access the OpenFOAM standard time control function to read the time information of the numerical simulation corresponding to all time folders in the working root directory.
[0060] Specifically, a time object `runTime` is constructed by accessing the `createTime.H` header file. This object is initialized by parsing the `controlDict` dictionary, enabling precise control of the simulation time step from the initial moment to the final moment, and determining the various moments at which the simulation results are output.
[0061] By adding specific options, you can specify a specific time, including the -constant option, which can include the constant / directory under the root directory; the -latestTime option, which can specify the final time; the -noZero option, which can exclude time 0; and the -time option, which, together with the time list, can flexibly select a specific time.
[0062] S3. Create a global blank file in the working root directory to store the calculation results of the volume integral of a specific physical quantity within a specific computational region at each time point.
[0063] The format of the global blank file is unrestricted, including .dat data format and other formats that are compatible with common data post-processing software such as Origin and Tecplot; at the same time, users can also customize the output to any other file format according to their needs.
[0064] If the volume integral of multiple physical quantities in the same region is calculated at the same time, such as the total heat release rate, the heat release rate in the premixed combustion mode and the heat release rate in the supersonic combustion mode, the order of each physical quantity is not restricted in any way, and different physical quantities can be arbitrarily sorted according to user preferences.
[0065] If you need to calculate the volume integral of multiple physical quantities in different regions, such as the total heat release rate of the entire combustion chamber, the total mass of fuel in the combustion chamber section after the fuel inlet, and the total mass of products, then you need to create the same number of global blank files as the number of target regions to store the calculation results of the volume integral of physical quantities in the corresponding regions.
[0066] S4. Write the time variable name and the variable name corresponding to the volume integral of the physical quantity that the program will calculate on the first line of the global blank file.
[0067] In hydrogen combustion simulations, the physical quantities whose volume integrals will be calculated include the total heat release rate of hydrogen. Hydrogen premixed combustion heat release rate The heat release rate of hydrogen supersonic combustion Total mass of hydrogen in the combustion chamber The total mass of water produced by the combustion of hydrogen in the combustion chamber .
[0068] Users can also select any other physical quantity already output by OpenFOAM according to their needs; or define new variables based on existing output quantities. Variable names are separated by spaces to ensure that data post-processing software can accurately identify different variable names.
[0069] The physical quantities to be integrated by volume include scalars (such as heat release rate, mass), vectors (velocity, vorticity), and tensors (viscous stress, shear stress). If it is a vector or tensor, define the variable name corresponding to each component in the first line of the file.
[0070] S5. Read the field quantity data required for calculating the volume integral of physical quantities, which are stored independently in the time folder as OpenFOAM standard output files.
[0071] Files are read and written using the IOdictionary class, a standard file read / write mechanism in OpenFOAM. For field 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 without reading.
[0072] Other intermediate physical quantities required to calculate the physical quantity of interest can be scalars (such as mass, heat release rate), vectors (velocity, vorticity), and tensors (viscous stress, shear stress). Different field quantity types are specified and restricted by the volScalarField, volVectorField, and volTensorField entry keywords in IOdictionary.
[0073] To calculate the volume integral of physical quantities in a specific region, it is usually necessary to use other physical quantities that have already been output. For example, to calculate the heat release rate of the volume integral of hydrogen in supersonic combustion mode, it is necessary to read the Mach number and heat release rate of each grid in the specific region, which are already output information.
[0074] The OpenFOAM standard forAll loop function is used to traverse all calculation times in the working root directory and read the required field data from each time folder. Assume a total of [number] data are read. Read at each moment If there are multiple field quantities, then the total number of files read is... .
[0075] There is no limit to the number of stored field quantities to be read at any given time, no limit to the number of intermediate or final field quantities to be calculated, no limit to the number of time folders to be read, and the time distribution of the time folders is not required to be equally spaced.
[0076] S6. Define and calculate the physical quantities of interest and other intermediate physical quantities required for calculating these physical quantities using regular expressions, specifically:
[0077] The physical field of interest is created using the IOdictionary class, which is the standard file read / write mechanism of OpenFOAM. This field can be a scalar field, vector field, or tensor field, without any restrictions. Its type is declared as scalar field, vector field, and tensor field using volScalarField, volVectorField, and volTensorField, respectively.
[0078] Taking the heat release rate of the volume integral in the supersonic combustion mode of hydrogen as an example, it is necessary to first declare it as a scalar field volScalarField. The size of the field is determined by the mesh. As a temporary field file, it is neither read nor written. The data is obtained by the field quantity calculation of the known field quantity data in S5 through the OpenFOAM standard.
[0079] S7. Define the region of interest for integration. Traverse all grids according to their grid numbers, and calculate the product of the physical quantity of interest and the corresponding grid volume in turn. Specifically:
[0080] For each time step, the OpenFOAM-embedded standard forAll loop iterates through all grid cells. Specific if conditions can be added to filter physical regions that meet certain characteristics, including range limitations based on the grid center coordinates.
[0081] For example, you could use `if (mesh.C()[cell].component(vector::X)`. The conditional statement for 0.109 selects the area where the horizontal coordinate of the grid center is not less than 109mm.
[0082] For static meshes (fixed networks), the data written to the field quantity file at each time step has the same organizational structure. At all times, the product of the physical quantity of interest and the mesh volume of the cell is stored in the temporary field quantity file in a fixed mesh number order.
[0083] For dynamic grids (changing networks, i.e., different computational grids are used at different times, such as dynamic grids, grid refinement, etc.), the data written to the temporary field quantity file at different times usually have different grid structures, and the calculation is adapted according to the grid topology at the current time.
[0084] S8. Write the calculation results of the volume integral of the physical quantity of interest over a specific region in the global file in chronological order, and iterate through all time points to complete the output of the results.
[0085] The OpenFOAM standard global summation function gSum is used to sum field quantities or lists; its function is equivalent to cyclic accumulation over all selected grids, and the gSum function can be applied to scalar fields, vector fields, and tensor fields.
[0086] The summation result of gSum is output once for each time step of the loop, and a new blank line is inserted at the same time; starting from the initial time step, the time increments sequentially to the final time step until the program ends; calculations can also be performed for a specific time step specified in the second step.
[0087] The order of physical quantities written at each time step is fixed and must be consistent with the order of variable names already written in S4. If the volume integrals of multiple physical quantities in different regions are calculated in S3, the results of different regions must be written to their respective files.
[0088] After the program finishes running, it outputs one or more global data files containing the volume integral calculation results of specific regions and specific physical quantities at various times. These files can be further used to analyze the evolution of the volume integral of physical quantities over time, monitor the overall combustion performance of hydrogen, and assess the performance of the combustion chamber.
[0089] This invention, through the above steps, provides a flexible and efficient method for processing the volume integrals of physical quantities over the entire computational domain or a specific local region, addressing the numerous intermediate time-series calculation results generated by OpenFOAM unsteady-state simulations. It transforms the originally complex and manual post-processing workflow into a one-step automated online calculation. After adding timestamp information, the results are written to a file in a format easily readable and visualized by common data post-processing software (such as Origin, Tecplot, and Excel). This supports the post-processing of OpenFOAM unsteady-state numerical simulation results, particularly for monitoring the evolution of the volume integral of specific physical quantities over time within a specific region.
[0090] The following provides a further detailed description of the invention. After completing an unsteady-state numerical simulation using OpenFOAM, users can utilize the method established by this invention to perform volume integration on any physical quantity within the entire computational domain or a custom region, thereby obtaining the overall change of that physical quantity over time. Taking the volume integration of the heat release rate of hydrogen under different combustion modes over the entire computational domain as an example, the process of performing volume integration of physical quantities based on the OpenFOAM unsteady-state simulation results is as follows: Figure 1 .
[0091] First, the working root directory for the current computational example is set, and the discretized mesh files conforming to the OpenFOAM specification are read from this directory. These mainly include the points file (containing coordinate information for all mesh nodes), the owner file (containing information for the mesh cell owners), the neighbor file (containing information for adjacent mesh cells), the faces file (containing information for mesh facets), and the boundary file (containing information for mesh boundaries). These data files together form the OpenFOAM structured or unstructured mesh system, achieving spatial relationships between mesh cells through strict topology sorting rules.
[0092] Secondly, determine whether the computational grid is static (i.e., the grid does not change over time throughout the entire computation process, and a fixed grid is used at all times) or dynamic (the grid topology or resolution changes at different times). If it is a static grid, it is read in once at the initial time and used at all other times without repeated reading; if it is a dynamic grid, the grid file for the current time is read in before reading the result file for each time.
[0093] Next, the necessary time control parameters for the simulation are read from the system / controlDict file in the working root directory. These mainly include the start time (startTime), end time (endTime), time step (timeStep), and the input control parameters for the numerical simulation result output. Based on these parameters, the time step and the output of the physical quantity volume integral calculation results within a specific region are determined. Starting from the initial time, the calculation progresses in an incremental manner until the final time, at which the numerical simulation result output time is used to output the physical quantity volume integral calculation results within the specific region.
[0094] Next, create a blank global file named Vol-Intg-HRR.dat in the working root directory to store the calculation results of the volume integral of the heat release rate of hydrogen under different combustion modes throughout the entire computational domain. Write the following variable names in sequence on the first line of this file: time, HRR, HRR-Pre, and HRR-Sup, representing time, the total volume integral of the heat release rate, and so on, respectively. Heat release rate by volume integral under premixed combustion mode and the heat release rate of volume integral under supersonic combustion mode The appropriate output variables and their names can be adjusted according to actual needs.
[0095] The OpenFOAM standard's `forAll` function is then used to iterate through all time points. At each time point, other field quantities required for calculating the volume integral of the physical quantity are read, and the physical quantities of interest are defined and initialized. In this example, the defined field quantity is the heat release rate of the total volume integral. Heat release rate by volume integral under premixed combustion mode and the heat release rate of volume integral under supersonic combustion mode The volumetric field quantities required include the heat release rate. ,Mach number Scalar product of fuel / oxidizer concentration gradient The heat release rate under premixed combustion mode. Heat release rate in supersonic combustion mode They are respectively:
[0096] ;
[0097] ;
[0098] in, For extremely small amounts, such as 10 -9 .
[0099] Next, write the product of the physical quantity of interest and the mesh volume of that cell onto all mesh cells, overwriting the original field value of that physical quantity. An if statement can be added to limit the region where volume integration will be performed subsequently.
[0100] Finally, within the time loop, the physical quantities of interest are summed over the entire computational domain using OpenFOAM's global summation function gSum, thus obtaining the total volume integral heat release rate. Heat release rate by volume integral under premixed combustion mode and the heat release rate of volume integral under supersonic combustion mode Write the results, along with the time information, sequentially into the Vol-Intg-HRR.dat file. Iterate through all time points and output the calculation results for all time points in the working root directory.
[0101] Example 1:
[0102] A schematic diagram of the physical problems of the variable structure combustion chamber of a scramjet engine with a support plate configuration is shown below. Figure 2 The initial height of the combustion chamber inlet ( Direction) is 50mm, total length ( (Direction) is 340mm. Downstream of the combustion chamber inlet, along... A wedge-shaped support plate, 32mm long and 6mm high, is placed along the centerline of 25mm. The back of the support plate (located at...) =109mm) has a 1mm diameter circular hole for hydrogen fuel injection. The upper wall of the combustion chamber is self- =Starting from 100mm, with a 3º tilt angle. This embodiment uses a two-dimensional calculation configuration.
[0103] The Mach number of the airflow at the combustion chamber inlet is =2.0, static temperature is =340K, static pressure is =0.1 MPa. Based on mass fraction, the polluted air consists of 73.6% nitrogen, 23.2% oxygen, and 3.2% water vapor. Pure hydrogen gas is injected into the combustion chamber at a speed of 1200 m / s sound, and its static temperature is... =250K, static pressure is =0.1 MPa. Hydrogen and air are mixed and forced to ignite, with combustion organized downstream of the support plate. The initial global equivalence ratio is... =0.034. The upper wall of the combustion chamber is... =0.2m / s along The direction shifts horizontally downwards, while simultaneously the upper wall surface above the support plate moves downwards at half its velocity, ensuring the support plate remains at the centerline of the combustion chamber. As the upper wall surface continuously moves downwards by 20mm, the system's global equivalence ratio... The value increased from 1.0 to 1.667. This embodiment uses a four-component hydrogen gas (…). , , and The single-step chemical reaction mechanism of the system. Under the complex shock wave-flame-turbulence interaction, this is a typical unsteady combustion system.
[0104] Unsteady-state numerical simulations were conducted using OpenFOAM. The total computation time was 0.1 s. Calculation results were saved every 50 µs, resulting in a total of 2000 time points. The algorithm of this invention was used to calculate the total volume integral heat release rate over the entire computational domain in this embodiment. Heat release rate by volume integral under premixed combustion mode and the heat release rate of volume integral under supersonic combustion mode Data that evolves over time.
[0105] This invention is used to post-process intermediate results. Figure 3 The curves show the evolution of the heat release rate of the total volume integral of the combustion chamber in the variable structure model over time at different moments. Figure 4 This is the evolution curve of the heat release rate of the volume integral over time in the premixed combustion mode. Figure 5 These are the heat release rate curves of the volume integral over time in the supersonic combustion mode. They clearly demonstrate the complete time evolution of the corresponding field quantity volume integral during this process.
[0106] Therefore, the present invention employs the above-mentioned method for calculating the volume integral of a field quantity in OpenFOAM unsteady-state simulation results. This method can efficiently and conveniently calculate the volume integral of any physical quantity at any number of intermediate times in the OpenFOAM unsteady-state simulation results over any specific region. Furthermore, the data is saved as a single file in a manner easily readable by commonly used data post-processing software, so as to facilitate further visualization and analysis.
[0107] 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 calculating the volume integral of field quantities in OpenFOAM unsteady-state simulation results, characterized in that, Includes the following steps: S1. Set the current working root directory of OpenFOAM, read the mesh file stored in OpenFOAM discrete storage and create the simulation mesh. The mesh file carries node coordinates, mesh cell owner, adjacent mesh cells, mesh surface and boundary condition definition information. S2. Access the OpenFOAM standard time control function to read the time information of the numerical simulation corresponding to all time folders in the working root directory; S3. Create a global blank file in the working root directory to store the calculation results of the volume integral of a specific physical quantity in a specific calculation region at each time point; S4. Write the time variable name and the variable name corresponding to the volume integral of the physical quantity that the program will calculate on the first line of the global blank file. S5. Read the field quantity data required for calculating the volume integral of physical quantities, which are stored independently in the time folder as OpenFOAM standard output files. S6. Define and calculate the physical quantities of interest and other intermediate physical quantities required to calculate these physical quantities using regular expressions; S7. Define the integration region of interest, traverse all grids according to grid number, and calculate the product of the physical quantity of interest and the corresponding grid volume in turn. S8. Write the calculation results of the volume integral of the physical quantity of interest over a specific region in the global file in chronological order, and iterate through all time points to complete the output of the results.
2. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 1, characterized in that, In S1, the mesh file is generated by the blockMesh tool that comes with OpenFOAM, or it can be imported by third-party software and converted into the OpenFOAM local file format.
3. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 2, characterized in that, In S1, the simulation grid can be a one-dimensional grid, a two-dimensional grid, or a three-dimensional grid. The one-dimensional grid is a structured grid, while the two-dimensional or three-dimensional grid can be a structured or unstructured grid. The calculation example grid can be either static or dynamic. If a static grid is used, a unique grid is read in at the initial moment and reused throughout the calculation. If a dynamic grid is used, the grids in the corresponding time folders are read sequentially according to the time.
4. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 3, characterized in that, In S2, a time object `runTime` is constructed by accessing the `createTime.H` header file. This object is initialized by parsing the `controlDict` control dictionary, controlling the simulation time step from the initial time to the final time, and determining the various times when the simulation results are output. Specific times can be specified by adding options, including the -constant option, which includes the constant / directory under the root directory, the -latestTime option which specifies the final time, the -noZero option which excludes time 0, and the -time option which selects a specific time in conjunction with a time list.
5. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 4, characterized in that, In S3, the global blank file format includes .dat data format and other formats that are compatible with data post-processing software. If the volume integral of multiple physical quantities in the same region is calculated at the same time, the order of the physical quantities is not restricted in any way; the multiple physical quantities in the same region include the total heat release rate, the heat release rate in the premixed combustion mode and the heat release rate in the supersonic combustion mode. If the volume integral of multiple physical quantities in different regions is calculated, the number of global blank files created is the same as the number of target regions, in order to store the calculation results of the volume integral of physical quantities in the corresponding regions; the multiple physical quantities in different regions include the total heat release rate of the entire combustion chamber, the total mass of fuel in the combustion chamber section after the fuel inlet, and the total mass of products.
6. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 5, characterized in that, In S4, the physical quantity variables for which the volume integral will be calculated in the hydrogen combustion simulation include the total heat release rate of hydrogen. Hydrogen premixed combustion heat release rate The heat release rate of hydrogen supersonic combustion Total mass of hydrogen in the combustion chamber The total mass of water produced by the combustion of hydrogen in the combustion chamber ; Variable names are separated by spaces to allow data post-processing software to recognize different variable names; the physical quantities to be integrated by volume include scalars, vectors and tensors. If it is a vector or tensor, define the variable names corresponding to each component in the first line of the file.
7. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 6, characterized in that, In S5, the OpenFOAM standard file read and write mechanism IOdictionary class 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. Other intermediate physical quantities required to calculate the physical quantities of interest are scalars, vectors, and tensors, which are specified and restricted by the volScalarField, volVectorField, and volTensorField entry keywords in IOdictionary; The OpenFOAM standard forAll loop function is used to traverse all calculation times in the working root directory, reading the required field data from each time folder. Assume a total of [number] data are read. Read at each moment If there are multiple field quantities, then the total number of files read is 1. ; There are no restrictions on the number of stored field quantities to be read at any given time, the number of intermediate or final field quantities to be calculated, or the number of time folders to be read. Furthermore, the time distribution of the time folders is not required to be at equal intervals.
8. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 7, characterized in that, S6 specifically refers to: The physical field quantities of interest are created using the IOdictionary class, which is the file reading and writing mechanism of the OpenFOAM standard. The types of volScalarField, volVectorField, and volTensorField are declared as scalar field, vector field, and tensor field, respectively. Temporary field files are neither read nor written; the data is obtained from known field quantity data in S5 through field quantity calculations using the OpenFOAM standard.
9. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 8, characterized in that, S7 specifically refers to: For each time step, all grid cells are traversed using a standard forAll loop embedded in OpenFOAM. Physical regions are filtered by adding if conditions, including range limitations based on grid center coordinates. For static grids, the data written to the field quantity file at each time step has the same organizational structure. At all times, the product of the physical quantity of interest and the grid volume of the cell is stored in the temporary field quantity file in a fixed grid number order. For dynamic meshes, the data written to the temporary field quantity file at different times has different mesh structures, and the calculation is adapted according to the mesh topology at the current time.
10. The method for calculating the volume integral of field quantities in OpenFOAM unsteady simulation results according to claim 9, characterized in that, In S8, the field quantities or lists are summed using the OpenFOAM standard global summation function gSum. At each loop iteration, the summation result of gSum is output once, and a new blank line is inserted. Starting from the initial time, the time increments sequentially to the final time until the program terminates. The order of physical quantities written at each time point is fixed and must be consistent with the order of variable names already written in S4; If the volume integrals of multiple physical quantities in different regions are calculated in S3, the results for each region are written to their respective files. After the program finishes running, it outputs a global data file containing the volume integral calculation results of specific regions and specific physical quantities at various times. This data is used to analyze the evolution of the volume integral of physical quantities over time and to monitor the overall combustion performance of hydrogen and the performance of the combustion chamber.
Citation Information
Patent Citations
Efficient local grid encryption method and system based on OpenFOAM
CN119788326A
Boundary physical quantity calculation method for OpenFOAM unsteady state simulation result
CN121145734A