[version 12][version 11][version 10][version 9][version 8][version 7][version 6]
7.2 Post-processing command line interface (CLI)
Post-processing is provided directly within OpenFOAM through the command line including 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.
- The case can be configured to include run-time processing during the simulation.
- The foamPostProcess utility provides conventional post-processing of data after a simulation is completed.
- The foamPostProcessutility is run with a -solver which provides additional access to data available on the database for the particular solver.
All modes of post-processing access the same functionality implemented in OpenFOAM in the function object framework. Function objects can be listed using foamToC by the following command.
foamToC -functionObjects
foamPostProcess -list
7.2.1 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 patchFlowRate function in functions sub-dictionary in the case controlDict file, using the #includeFunc directive.
functions
{
#includeFunc patchFlowRate
... other function objects here ...
}
The configuration of patchFlowRate requires the name of the patch to be supplied. Option 1 for doing this is that the user copies the patchFlowRate file into their case system directory. The foamGet script copies the file conveniently, e.g.
foamGet patchFlowRate
Option 2 for specifying the patch name is to provide the name as an argument to the patchFlowRate in the #includeFunc directive, using the syntax keyword=entry.
functions
{
#includeFunc patchFlowRate(patch=outlet)
... 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.
functions
{
#includeFunc mag(U)
... other function objects here ...
}
Some functions require the setting of many parameters, e.g. to calculate forces and generate elements for visualisation, etc. For those functions, it is more reliable and convenient to copy and configure the function using option 1 (above) rather than through arguments.
7.2.2 The foamPostProcess utility
The user can execute post-processing functions after the simulation is complete using the foamPostProcess utility. We can us illustrate the use of foamPostProcessusing the pitzDailySteady case from section 2.1 . The tutorial does not need to be run to use the case, it can instead be copied into the user’s run directory and run using its accompanying Allrun script as follows.
run
cp -r $FOAM_TUTORIALS/incompressibleFluid/pitzDailySteady .
cd pitzDaily
./Allrun
foamPostProcess -help
foamPostProcess -func "mag(U)"
foamPostProcess -func "patchFlowRate(name=outlet)"
foamPostProcess -func "totalPressureIncompressible(rhoInf=1.2)"
--> FOAM FATAL IO ERROR:
request for volVectorField U from objectRegistry region0 failed
foamPostProcess -func "totalPressureIncompressible(rhoInf=1.2)" -field U
A more complex example is calculating wall shear stress using the wallShearStress function.
foamPostProcess -fields "(p U)" -func wallShearStress
--> FOAM FATAL ERROR:
Unable to find turbulence model in the database
foamPostProcess -solver incompressibleFluid -func wallShearStress