CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Monitor residuals with OpenFoam ESI

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By trailer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2021, 10:56
Default Monitor residuals with OpenFoam ESI
  #1
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Hello to all,


I am using OpenFoam 2012 and would like to plot the residuals of pressure and velocity during the execution of the simulation.


I am using the functionObject solverInfo as:



Code:
    solverInfo
    {
        type            solverInfo;
        libs            ("libutilityFunctionObjects.so");
        fields          (U p);
        writeResidualFields no;
        executeControl      timeStep;
        executeInterval     10;
    }
However, this outputs a lot of information... And I only require the value of the initial residual of p and U.



Afterwards, when I plot the residuals with foamMonitor the plot gets very crowded.



Is it possible to restrict the information output from the functionObject to just the initial residuals? Or alternatively to just plot the initial residuals of variables with foamMonitor?
trailer is offline   Reply With Quote

Old   May 18, 2021, 18:04
Default
  #2
Senior Member
 
Klaus
Join Date: Mar 2009
Posts: 250
Rep Power: 22
klausb will become famous soon enough
There's also a very powerful python tool called "pyFoam" for that purpose.

It includes utilities like pyFoamRunner and pyFoamPlotWatcher which are relevant for the purpose you mention. You should also have a look at youtube e.g. "How to plot residuals in OpenFOAM: functionObject and pyFoam utilities" which goes into custom configuration of residual plots to some extend.
klausb is offline   Reply With Quote

Old   May 19, 2021, 04:40
Default
  #3
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Quote:
Originally Posted by klausb View Post
There's also a very powerful python tool called "pyFoam" for that purpose.

It includes utilities like pyFoamRunner and pyFoamPlotWatcher which are relevant for the purpose you mention. You should also have a look at youtube e.g. "How to plot residuals in OpenFOAM: functionObject and pyFoam utilities" which goes into custom configuration of residual plots to some extend.

Hi,


Thanks for the reply.


I ended up using solverInfo functionObject but filtered the data with an executable script. The code bellow will look for _initial termination and plot only the variables with it.

Code:
 filename=$1
 gnuplot -persist <<-EOFMarker
     set datafile commentschars "" 

    set datafile separator tab
     set key noenhanced 

    set logscale y 

    set title 'Residuals'  

    set ylabel 'Residual'
    set xlabel 'Iteration'
     myHeaders = system("head $filename | grep -o '[^ ]*_initial[^ ]*'")
      plot for [i=1:words(myHeaders)] '$filename' u "# Time":word(myHeaders,i) skip 1 w l ti columnheader  

 EOFMarker
Usage of the script:


Create a file called foamPlot. Paste the code inside.
Make it an executable file with:

Code:
chmod +x foamPlot
Navigate to the folder with the solverInfo.dat file

Use it with:

Code:
foamPlot solverInfo.dat
Yann, SHUBHAM9595 and davcrisp like this.
trailer is offline   Reply With Quote

Old   May 20, 2021, 16:04
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
Would you mind to comment on what could be improved/what should be done item by item in the "solverInfo" function object, so that the user might have lesser pain?
HPE is offline   Reply With Quote

Old   May 20, 2021, 17:57
Default
  #5
Member
 
Join Date: Mar 2021
Posts: 39
Rep Power: 5
trailer is on a distinguished road
Quote:
Originally Posted by HPE View Post
Would you mind to comment on what could be improved/what should be done item by item in the "solverInfo" function object, so that the user might have lesser pain?



Hi,

Sure! Just put a switch to just filter the initial residuals instead of "everything". This would be a similar behavior to what OpenFOAM foundation has: https://github.com/OpenFOAM/OpenFOAM...ties/residuals


This way, you could just plot the residuals with :


Code:
foamMonitor -l solverInfo.dat
trailer is offline   Reply With Quote

Old   May 21, 2021, 16:19
Default
  #6
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
hmm interesting. The "solverInfo" FO is the updated version of the "residuals"; in fact, it was renamed. I have put it at the end of my to-do list (which is longer than Gandalf's hair atm).
HPE is offline   Reply With Quote

Reply


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
Getting Started with OpenFOAM wyldckat OpenFOAM 25 August 14, 2022 13:55
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
How to contribute to the community of OpenFOAM users and to the OpenFOAM technology wyldckat OpenFOAM 17 November 10, 2017 15:54
OpenFOAM Training Beijing 22-26 Aug 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 May 3, 2016 04:57
The OpenFOAM extensions project mbeaudoin OpenFOAM 16 October 9, 2007 09:33


All times are GMT -4. The time now is 09:43.