There are a set of general post-processing functions for sampling data across the domain for graphs and visualization. In this article, we use the lid-driven cavity case set up in the tutorial to demonstrate these post-processing functions.
Probing data
When we want to get the time series data of the fields on certain point locations, the functions boundaryCloud, internalCloud, and probes can help us. All functions work on the basis that the user provides some point locations and a list of fields, and the function writes out values of the fields on those locations in each time interval.
We use the method mention in the previous post to include the functions. The configuration is started by adding the #includeFunc directive to functions in the controlDict file.
functions
{
#includeFunc probes
... other function objects here ...
}
The probes function is configured by copying the file to the local system directory using foamGet.
foamGet probes
Let’s say we want to obtain the pressure and velocity value on certain locations, then specify the locations we need in probeLocations in the probes file as follows.
#includeEtc "caseDicts/postProcessing/probes/probes.cfg"
fields (p U);
probeLocations
(
(0 0 0) // point 1
(0 0.5 0) // point 2 ...
);
When the simulation is running, time-value data is written into p and U files in postProcessing/probes/0.
Time-Value Data
The pressure data record by probes function.
Sampling line data
The singleGraph function samples data from a line defined by the user. Again, we add the #includeFunc directive to functions in the controlDict file.
functions
{
#includeFunc singleGraph
... other function objects here ...
}
Copy the configuration file of the singleGraph function using foamGet.
foamGet singleGraph
In the configuration file we can specify:
- The start and end points of the line where data is sampled.
- The fields need to be sampled.
- The type of sampling.
In the configuration below, the singleGraph function will extract velocity and pressure data from the 100 uniform distributed data points on the line. During the simulation, distance-value data is written into files in time directories within postProcessing/singleGraph.
start (0.05 0 0);
end (0.05 0.1 0);
fields (U p);
// Sampling and I/O settings
#includeEtc "caseDicts/postProcessing/graphs/sampleDict.cfg"
// Override settings here, e.g.
setConfig
{
type lineUniform; // lineCell, lineCellFace
axis distance; // x, y, z, xyz
nPoints 100;
}
// Must be last entry
#includeEtc "caseDicts/postProcessing/graphs/graph.cfg"
We can quickly display the data for x-component of velocity, last time (0.5 in my case), by running gnuplot with the following commands.
gnuplot
gnuplot> set style data linespoints
gnuplot> plot "postProcessing/singleGraph/0.5/line_U.xy" u 2:1
Velocity-x Along the Line
The x-component of velocity along the line.
Sampling surface data
The surfaces functions can be used to generate files for visualization. First, add the #includeFunc directive to functions in the controlDict file.
functions
{
#includeFunc surfaces
... other function objects here ...
}
The target surface can be specified by cutting plane, isosurface, patch surface. The surfaces function is configured by copying the surfaces file to the system directory using foamGet.
foamGet surfaces
In this demonstration, we specify the target surface by cutting plane which the base point and normal vector should be edited.
#includeEtc "caseDicts/postProcessing/visualization/surfaces.cfg"
fields (p U);
surfaces
(
zNormal
{
$cuttingPlane;
pointAndNormalDict
{
basePoint (0.05 0.05 0); // Overrides default basePoint (0 0 0)
normalVector $z; // $z: macro for (0 0 1)
}
}
);
Then surfaces function produces VTK format files of the cutting plane with pressure and velocity data in time directories in the the postProcessing/surfaces directory. The user can display the cutting plane by opening these VTK files in ParaView (type paraview).
Visualization of Velocity Data
Visualization of velocity data from VTK file.
Live monitoring of data
To monitor the data during the simulation, the user should then run foamMonitor the terminal. If the command is executed before the simulation is complete, then we can see the graph being updated live.
Firstly, include the residuals function in the controlDict file.
functions
{
#includeFunc residuals
... other function objects here ...
}
The default fields whose residuals are captured are p and U. If we wish to get other fields, we should either make copy the residuals file in their system and edit the fields entry (method 1) or define the arguments to the residuals function in the controlDict file (method 2). Here, we use the method 1. The residuals file can then be copied into the system directory conveniently using foamGet:
foamGet residuals
It is advisable to delete the postProcessing directory to avoid duplicate files for each function. The user can delete the directory, then run simulation in the background.
rm -rf postProcessing
icoFoam > log &
Then run foamMonitor before the simulation is complete.
foamMonitor -l postProcessing/residuals/0/residuals.dat
foamMonitor
The graph being updated live.
- Reference: