[version 10][version 9][version 8][version 7][version 6]
6.2 Post-processing command line interface (CLI)
In OpenFOAM version 4.0, the ‘non-GUI’ post-processing tools have been unified within a single command line interface (CLI). Post-processing functionality includes data processing, sampling (e.g. probes, graph plotting) visualisation, case control and run-time I/O. Functionality can be executed by:
- conventional post-processing, a data processing activity that occurs after a simulation has run;
- run-time processing, data processing that is performed during the running of a simulation.
Both approaches have advantages. Conventional post-processing allows the user to choose how to analyse data after the results are obtained. Run-time processing offers greater flexibility because it has access to all the data in the database of the run at all times, rather than just the data written during the simulation. It also allows the user to monitor processed data during a simulation and provides a greater level of convenience because the processed results can be available immediately to the user when the simulation ends.
There are 3 methods of post-processing that cover the options described above
- Every solver, e.g. simpleFoam can be configured to include run-time processing.
- The postProcess utility provides conventional post-processing of data written by a simulation.
- Every solver can be run with the -postProcess option, which only executes post-processing, but with additional access to data available on the database for the particular solver.
6.2.1 Post-processing functionality
All modes of post-processing access the same functionality implemented in OpenFOAM in the function object framework. Function objects can be listed by running a solver with the -listFunctionObjects option, e.g.
126.96.36.199 Field calculation
- Calculates the Courant Number field from the flux field.
- Calculates and writes the second largest eigenvalue of the sum of the square of the symmetrical and anti-symmetrical parts of the velocity gradient tensor.
- Calculates the Mach Number field from the velocity field.
- Calculates the Peclet Number field from the flux field.
- Calculates the second invariant of the velocity gradient tensor.
- Calculates the Reynolds stress tensor field and stores it on the database.
- Writes the turbulent flame-speed and reaction-rate volScalarFields for the Xi-based combustion models.
- Add a list of fields.
- Writes the component scalar fields (e.g. Ux, Uy, Uz) of a field (e.g. U).
- Calculates the Eulerian time derivative of a field.
- Calculates the divergence of a field.
- Calculates the enstrophy of the velocity field.
- Calculates and writes the flowType of velocity field where: -1 = rotational flow; 0 = simple shear flow; +1 = planar extensional flow.
- Calculates the gradient of a field.
- Calculates the magnitude of a field.
- Calculates the magnitude-squared of a field.
- Adds a random component to a field, with a specified perturbation magnitude.
- Multiplies a field by a scale factor
- Writes the steam-function pointScalarField, calculated from the specified flux surfaceScalarField.
- From the first field, subtracts the remaining fields in the list.
- Calculates specified turbulence fields and stores it on the database.
- Calculates and writes the turbulence intensity field I.
- Calculates the vorticity field, i.e. the curl of the velocity field.
- Calculates the heat flux at wall patches, outputting the data as a volVectorField.
- Calculates the estimated incompressible flow heat transfer coefficient at wall patches, outputting the data as a volScalarField.
- Calculates the shear stress at wall patches, outputting the data as a volVectorField.
- Writes the cell-centres volVectorField and the three component fields as volScalarFields; useful for post-processing thresholding.
- Writes the cell-volumes volScalarField
- Writes out specified objects, e.g. fields, stored on the case database.
- Calculates the turbulence y+, outputting the data as a yPlus field.
188.8.131.52 Flow rate calculation
- Calculates the flow rate through a specified face zone by summing the flux on patch faces. For solvers where the flux is volumetric, the flow rate is volumetric; where flux is mass flux, the flow rate is mass flow rate.
- Calculates the flow rate through a specified patch by summing the flux on patch faces. For solvers where the flux is volumetric, the flow rate is volumetric; where flux is mass flux, the flow rate is mass flow rate.
- Calculates volumetric flow rate through a specified triangulated surface by interpolating velocity onto the triangles and integrating over the surface area. Triangles need to be small (¡= cell size) for an accurate result.
184.108.40.206 Forces and force coefficients
- Calculates lift, drag and moment coefficients by summing forces on specified patches for a case where the solver is compressible (pressure is in units M/(LTˆ2), e.g. Pa).
- Calculates lift, drag and moment coefficients by summing forces on specified patches for a case where the solver is incompressible (pressure is kinematic, e.g. mˆ2/sˆ2).
- Calculates pressure and viscous forces over specified patches for a case where the solver is compressible (pressure is in units M/(LTˆ2), e.g. Pa).
- Calculates pressure and viscous forces over specified patches for a case where the solver is incompressible (pressure is kinematic, e.g. mˆ2/sˆ2).
220.127.116.11 Sampling for graph plotting
18.104.22.168 Lagrangian data
- Calculate intensive fields UMean, translationalT, internalT, overallT from averaged extensive fields from a DSMC calculation.
22.214.171.124 Monitoring minima and maxima
- Writes out the maximum cell value for one or more fields.
- Writes out the minimum cell value for one or more fields.
- Writes out the maximum face value for one or more fields.
- Writes out the minimum face value for one or more fields.
- Writes out the minimum and maximum values, by component for non-scalar fields, and the locations where they occur.
- Writes out the minimum and maximum values, by magnitude for non-scalar fields, and the locations where they occur.
126.96.36.199 Numerical data
- For specified fields, writes out the initial residuals for the first solution of each time step; for non-scalar fields (e.g. vectors), writes the largest of the residuals for each component (e.g. x, y, z).
- Writes run time, CPU time and clock time and optionally the CPU and clock times per time step.
188.8.131.52 Pressure tools
- Calculates the difference between the average pressures on 2 specified patches.
- Interpolates pressures onto 2 specified triangulated surfaces and calculates the difference between the average pressures.
- Calculates the pressure field in units M/(LTˆ2) (e.g. Pa) from kinematic pressure by scaling by a specified density.
- Calculates the total pressure field for a case where the solver is compressible (pressure is in units M/(LTˆ2), e.g. Pa).
- Calculates the total pressure field for a case where the solver is incompressible (pressure is kinematic, e.g. mˆ2/sˆ2).
- Writes out values of fields at a cloud of points, interpolated to specified boundary patches.
- Reports the height of the interface above a set of locations. For each location, it writes the vertical distance of the interface above both the location and the lowest boundary. It also writes the point on the interface from which these heights are computed.
- Writes out values of fields interpolated to a specified cloud of points.
- Writes out values of fields from cells nearest to specified locations.
184.108.40.206 ‘Pluggable’ solvers
- Tracks a cloud of parcels driven by the flow of the continuous phase.
- Solves a transport equation for a scalar field.
220.127.116.11 Visualisation tools
- Writes out files of streamlines with interpolated field data in VTK format.
- Writes out surface files with interpolated field data in VTK format, e.g. cutting planes, iso-surfaces and patch boundary surfaces.
6.2.2 Run-time data processing
When a user wishes to process data during a simulation, they need to configure the case accordingly. The configuration process is as follows, using an example of monitoring flow rate at an outlet patch named outlet.
Firstly, the user should include the flowRatePatch function in functions sub-dictionary in the case controlDict file, using the #includeFunc directive.
... other function objects here ...
The configuration of flowRatePatch requires the name of the patch to be supplied. Option 1 for doing this is that the user copies the flowRatePatch file into their case system directory. The foamGet script copies the file conveniently, e.g.
Option 2 for specifying the patch name is to provide the name as an argument to the flowRatePatch in the #includeFunc directive, using the syntax keyword=entry.
... other function objects here ...
In the case where the keyword is field or fields, only the entry is needed when specifying an argument to a function. For example, if the user wanted to calculate and write out the magnitude of velocity into time directories during a simulation they could simply add the following to the functions sub-dictionary in controlDict.
... other function objects here ...
Some functions require the setting of many parameters, e.g. forces, forceCoeffs, surfaces, etc. For those functions, it is more reliable and convenient to copy and configure the function using option 1 (above) rather than through arguments.
6.2.3 The postProcess utility
The user can execute post-processing functions after the simulation is complete using the postProcess utility. Let us illustrate the use of postProcess using the pitzDaily case from the tutorials directory. The case can be copied, e.g. into the user’s run directory; the user can then go into the case directory, generate the mesh with blockMesh and then run simpleFoam
cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
postProcess -func "mag(U)"
postProcess -func "flowRatePatch(name=outlet)"
postProcess -func totalPressureIncompressible
--> FOAM Warning : functionObject pressure: Cannot find required field p
postProcess -func "totalPressureIncompressible(p,U)"
postProcess -fields "(p U)" -func totalPressureIncompressible
6.2.4 Solver post-processing
A more complex example is calculating wall shear stress using the wallShearStress function.
postProcess -fields "(p U)" -func wallShearStress
--> FOAM FATAL ERROR:
Unable to find turbulence model in the database
simpleFoam -postProcess -help
simpleFoam -postProcess -func wallShearStress