The application discloses a method for calculating volume integral of field quantity in OpenFOAM unsteady
simulation result, which comprises the following steps: firstly, setting the current working
root directory of OpenFOAM, reading the
grid file discretely stored by OpenFOAM and creating the grid of the example; secondly, accessing the
time control function and reading the
time information; thirdly, creating the global blank file under the working
root directory and storing the calculation result of the volume integral; fourthly, writing the
time variable name and the variable name corresponding to the volume integral of the
physical quantity to be calculated by the program in the first line of the global blank file; fifthly, reading the field quantity data required for calculating the volume integral of the
physical quantity in sequence; sixthly, defining and calculating the
physical quantity and the intermediate physical quantity concerned by using the
regular expression; seventhly, defining the region concerned, calculating the product of the physical quantity concerned and the corresponding grid volume; and eighthly, writing the calculation result in the
time sequence and completing the result output by traversing all the time points. The application can automatically process the multi-time
point data in batches, greatly reduces the manual operation cost and realizes the efficient acquisition of the
time evolution law of the volume integral of the field quantity.