These guidelines are based on the working folder located here.

Monitoring & Post-processing


1) Monitoring

1.1 Wall heat flux

Pre-requirement: the patch type in constant/polyMesh/boundary has to be wall.

Open the transportProperties dictionary and make sure the switch is active

    writeWallHeatFlux              on;

The field named wallHeatFlux will be printed as a result in each time folder. In addition, the wall heat flux is integrated for each wall and printed in the log file at write time

Wall heat fluxes [W]
Patch 4 named lowerWall: 416.2644537

Thus, the integrated wall heat flux can easily be monitored (and later plotted) during the simulation using the grep command. In the present case

grep lowerWall log.hy2Foam

Alternatively, use the dedicated monitoring script given in the gnuplot/ folder, called monitorIntegratedWallHeatFlux, and replace #patchName by the name of the wall patch.

set output "gnuplot/integratedWallHeatFlux.eps"

set size 0.95,0.47
set origin 0.03,0.53
set xlabel "Time  [sec]"
set ylabel "Integrated wall heat flux  [kW]"

plot \
"< cat log.hy2Foam | grep -e 'named #patchName:' -e '^Time =' | awk '/^Time =/,/^Time =/ {lastc = $0; next}{ if ( lastc != \"\") { print lastc; lastc = \"\"; } print }' $1 | cut -d ':' -f 2 | cut -d '=' -f 2 | paste -d ' ' - -" u 1:($2/1000.0) w l ls 1 lw 1.8 not

 

1.2 Wall shear stress

In the system/controlDict dictionary, uncomment the include statement that prints surface quantities

functions
{
    //#include "probes"
    
    //#include "forces"

    #include "surfaceQuantities"
}

and review/edit the relevant subdictionary in the system/surfaceQuantities dictionary

wallShearStress
{
    type            wallShearStress;
    libs            ("libstrathFieldFunctionObjects.so");
    patches         ("cylinder");
    writeControl    outputTime;
    log             no;
}

 

1.3 Forces

In the system/controlDict dictionary, uncomment the include statement that prints forces and aerodynamic coefficients

functions
{
    //#include "probes"
    
    #include "forces"

    //#include "surfaceQuantities"
}

Open the system/forces dictionary

#include "../0/include/initialConditions"

forces
{
    type forces;
    functionObjectLibs ("libstrathForces.so");
    log false;
    writeFields false;
    patches (cylinder); // edit accordingly
    CofR (0 0 0);
    dragDir (1 0 0);
    liftDir (0 1 0);
    pitchAxis (0 0 1);
}

forceCoeffs
{
    #include "../0/include/initialConditions"

    type forceCoeffs;
    functionObjectLibs ("libstrathForces.so");
    log false;
    writeFields false;
    patches (cylinder); // edit accordingly
    rho rhoInf;
    rhoInf $rhoInlet;
    magUInf $velocityInlet;
    CofR (0 0 0);
    dragDir (1 0 0);
    liftDir (0 1 0);
    pitchAxis (0 0 1);
    lRef 0.05; // edit accordingly, see constant/transportProperties/rarefiedParameters/characteristicLength
    Aref 1.96646e-05; // edit accordingly
}

Review and edit the relevant entries. Forces / aerodynamic coefficients (e.g. drag coefficient) can be monitored using the script file given in the gnuplot/ folder

set output "gnuplot/dragCoefficient.eps"

set size 0.95,0.47
set origin 0.03,0.53
set xlabel "Write time"
set ylabel "Drag coefficient"

plot \
"< cat log.hy2Foam | grep 'Cd' | cut -d '=' -f 2" w l ls 1 not

 

1.4 Residuals

An example is given below for monitoring the residuals. The fields (Ux, Uy, e_{ve, N2}, e) may be edited depending on the simulation set-up.

set output "gnuplot/residuals.eps"

set size 0.95,0.47
set origin 0.03,0.53
set logscale y
set format y "10^{\%01T}"
set xlabel "Timestep [x 100]"
set ylabel "Residuals"
set mytics 10

plot \
"< cat log.hy2Foam | grep 'Solving for Ux' | cut -d '=' -f 2 | cut -d ',' -f 1" every 100 w l ls 12 t 'Ux initial',\
"< cat log.hy2Foam | grep 'Solving for Ux' | cut -d '=' -f 3 | cut -d ',' -f 1" every 100 w l ls 1  t 'Ux final',\
"< cat log.hy2Foam | grep 'Solving for Uy' | cut -d '=' -f 2 | cut -d ',' -f 1" every 100 w l ls 22 t 'Uy initial',\
"< cat log.hy2Foam | grep 'Solving for Uy' | cut -d '=' -f 3 | cut -d ',' -f 1" every 100 w l ls 2 t 'Uy final',\
"< cat log.hy2Foam | grep 'Solving for evel_N2' | cut -d '=' -f 2 | cut -d ',' -f 1" every 100 w l ls 32 t 'e_{vel,{N_2}} initial',\
"< cat log.hy2Foam | grep 'Solving for evel_N2' | cut -d '=' -f 3 | cut -d ',' -f 1" every 100 w l ls 3 t 'e_{vel,{N_2}} final',\
"< cat log.hy2Foam | grep 'Solving for e,' | cut -d '=' -f 2 | cut -d ',' -f 1" every 100 w l ls 42 t 'e initial',\
"< cat log.hy2Foam | grep 'Solving for e,' | cut -d '=' -f 3 | cut -d ',' -f 1" every 100 w l ls 4 t 'e final'

and this script can be run as follows

gnuplot gnuplot/monitorResiduals



2) Post-processing

In a terminal window, type in

hy2Foam -postProcess -dict 'system/surfaceCoefficients' -latestTime

where system/surfaceCoefficients is a dictionary that contains the desired surface coefficients. Their implementation in the functions sub-dictionary is shown below.

2.1 Pressure coefficient

In the functions sub-dictionary, add

pressureCoefficient
{
    type            pressureCoefficient;
    libs            ("libstrathFieldFunctionObjects.so");
    writeControl    outputTime;
    log             no;
}

 

2.2 Stanton number

The wallHeatFlux field is a required input. In the functions sub-dictionary, add

StantonNumber
{
    type            StantonNo;
    //- see constant/transportProperties/transportModels: writeWallHeatFlux
    wallHeatFlux    "wallHeatFlux"; 
    libs            ("libstrathFieldFunctionObjects.so");
    writeControl    outputTime;
    log             no;
}

 

2.3 Skin-friction coefficient

The wallShearStress field is a required input. In the functions sub-dictionary, add

frictionCoefficient
{
    type            frictionCoefficient;
    libs            ("libstrathFieldFunctionObjects.so");
    writeControl    outputTime;
    log             no;
}

 

2.4 y+

In the functions sub-dictionary, add

yPlus
{
    type            yPlus;
    libs            ("libstrathFieldFunctionObjects.so");
    writeControl    outputTime;
    log             no;
}

 

2.5 ParaView

  • Open ParaView and load wall patches in Mesh Regions
  • Plot any of these surface quantities using the plotData filter