CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

plot a difference value each iteration

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 14, 2025, 07:04
Default plot a difference value each iteration
  #1
Member
 
Join Date: Oct 2018
Posts: 32
Rep Power: 9
elia_l is on a distinguished road
Hi guys,

I have an issue regarding the real time plot of static pressure rise across the fan I'm running. I explain.
I already got average static pressure on inlet and outlet patches by use of:


patchAverage_inlet_inletdom
{
type surfaceFieldValue;
libs ("libfieldFunctionObjects.so");

writeControl timeStep;
writeInterval 1;

patch inlet_inletdom;
select patch;

fields (p);

operation areaAverage;

writeFields false;

log true;
}



patchAverage_outlet_outletdom
{
type surfaceFieldValue;
libs ("libfieldFunctionObjects.so");

writeControl timeStep;
writeInterval 1;

patch outlet_outletdom;
select patch;

fields (p);

operation areaAverage;

writeFields false;

log true;
}



At this point two .dat files are created inside postProcessing/ folder and I can plot them by use of gnuplot, using the following script:

gnuplot -persist <<EOF2 &
set title "Static Pressure"
set xlabel "Iterations"
set ylabel "Static pressure [Pag]"
set grid
do for [i=1:100000] {
plot \
"postProcessing/patchAverage_inlet_inletdom/0/surfaceFieldValue.dat" using 1:2 with lines title "psin", \
"postProcessing/patchAverage_outlet_outletdom/0/surfaceFieldValue.dat" using 1:2 with lines title "psout"
pause 1
}
EOF2

My question is: how can I calculate inside OF (I’m using OpenFOAM 13 Foundation) the difference of previous two average values, write it inside a .dat file and plot it using gnuplot inside the same plot of psin and psout?

Thanks in advance.

elia
elia_l is offline   Reply With Quote

Old   November 14, 2025, 13:21
Default
  #2
New Member
 
Michael Häckel
Join Date: Nov 2025
Posts: 16
Rep Power: 2
michael_h is on a distinguished road
You can use the ddt postprocessing function to calculate the time derivative of the pressure field. Then you can calculate the average of the derivative. The result is not exactly the same as with your proposed calculation method, but almost.
https://doc.cfd.direct/openfoam/user...-functionality
There is no documentation but the usage is like for most other postprocessing functions.

Instead of your gnuplot script you can also use foamMonitor. That is a bit more comfortable.
michael_h is offline   Reply With Quote

Old   November 17, 2025, 15:22
Default
  #3
Member
 
Join Date: Oct 2018
Posts: 32
Rep Power: 9
elia_l is on a distinguished road
Thank you michael for the reply. Finally I solved the issue in this way:

dps
{
type fieldValueDelta;
libs ("libfieldFunctionObjects.so");
operation subtract;
writeControl timeStep;
writeInterval 1;
log true;

region1
{
#includeEtc "caseDicts/functions/surfaceFieldValue/surfaceValue.cfg"
patch outlet_outletdom;
operation areaAverage;
fields (static(p));
}

region2
{
#includeEtc "caseDicts/functions/surfaceFieldValue/surfaceValue.cfg"
patch inlet_inletdom;
operation areaAverage;
fields (static(p));
}
}

dfr
{
type fieldValueDelta;
libs ("libfieldFunctionObjects.so");
operation add;
writeControl timeStep;
writeInterval 1;
log true;

region1
{
#includeEtc "caseDicts/functions/surfaceFieldValue/surfaceValue.cfg"
patch outlet_outletdom;
operation sum;
fields (phi);
}

region2
{
#includeEtc "caseDicts/functions/surfaceFieldValue/surfaceValue.cfg"
patch inlet_inletdom;
operation sum;
fields (phi);
}
}
elia_l is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
tolerance in solver VS tolerance in residualControl FluidKo OpenFOAM Running, Solving & CFD 13 January 30, 2024 11:59
pimpleFoam residual increase in final iteration AhmedHafez OpenFOAM Running, Solving & CFD 0 December 1, 2022 04:03
Change foamLog for Pimple iteration and new variables Magistrane OpenFOAM Post-Processing 1 April 26, 2019 05:26
contour plot: mass flow difference jai CFX 3 December 16, 2017 07:20
difference plot: turbulent kinetic energy (URANS) vs. Reynolds Stresses (LES) fabfi CFX 2 November 21, 2017 11:29


All times are GMT -4. The time now is 11:38.