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

plotting residuals

Register Blogs Community New Posts Updated Threads Search

Like Tree20Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 23, 2016, 11:58
Default plotting residuals
  #1
Member
 
subhankar
Join Date: May 2016
Posts: 36
Rep Power: 10
SUBHANKAR is on a distinguished road
Hi everyone,
I am solving flow past cylinder between two parallel channel(laminar case). I am using pisoFoam solver.After completion of iterations, i tried to plot the residuals by creating log files and then plotting by using the command ./plot. But it didn't plot anything. It also didn't create files in the log folder. Can anybody tell what might have gone wrong? Thanks in advance...
regards Subhankar
SUBHANKAR is offline   Reply With Quote

Old   August 23, 2016, 12:24
Default
  #2
Member
 
Charles K.
Join Date: Feb 2016
Location: Germany
Posts: 37
Rep Power: 10
McCharles is on a distinguished road
I usually use the following commands:

Code:
pisoFoam > log1 & 

pyFoamPlotWatcher.py log1
this can be used during the simulation but also afterwards.

to save the residualplot, use

Code:
pyFoamPlotWatcher.py log1 --hardcopy --format-of-hardcopy=pdf
after interrupting/closing pyFoamPlotWatcher with CTRL+C, it will save the Residual and continuity plot in pdf format.

Hope this will help you
Elham, Taataa, wcc and 3 others like this.
McCharles is offline   Reply With Quote

Old   August 24, 2016, 02:52
Default
  #3
Member
 
subhankar
Join Date: May 2016
Posts: 36
Rep Power: 10
SUBHANKAR is on a distinguished road
Hi McCharles,

Thanks for the reply. I used the commands. But it didn't plot anything.It shows "pyFoamPlotWatcher.py: command not found". Also I think i have done some mistakes in the files because in the log file it shows "No finite volume options present". and there is no information about the initial iteration. Can you tell me where i went wrong. Any suggestions are appreciated.
Thanks in advance,

best regards

Subhankar
SUBHANKAR is offline   Reply With Quote

Old   August 24, 2016, 03:45
Default
  #4
Member
 
Charles K.
Join Date: Feb 2016
Location: Germany
Posts: 37
Rep Power: 10
McCharles is on a distinguished road
Is python installed on your Computer? The commands you used are correct, so there is certainly something wrong with your Python installation.

The "no finite volume option present" message is due to the fact that you're not using any options in fvOption, which isn't a problem. What do you mean by "no information about the initial iteration" ?
McCharles is offline   Reply With Quote

Old   August 24, 2016, 10:35
Default
  #5
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 11
Zbynek is on a distinguished road
To plot residuals, you can use the function object called, as expected, residuals. It comes alongside the installation of OF. All you need to do is to add a few lines to your controlDict in the block called functions.

Code:
functions
{
    residuals
    {
        type            residuals;
        functionObjectLibs ("libutilityFunctionObjects.so");
        enabled         true;
        outputControl   timeStep;
        outputInterval  1;

        fields
        (
            p
            U
            k
            epsilon
        );
    }
}
An example of the necessary inputs for the code is in $FOAM_ETC/caseDicts/postProcessing/numerical. This utility ensures that the residual values are written to a folder in your working directory. You can plot them using the foamMonitor utility (gnuplot needed).

Code:
foamMonitor -l postProcessing/residuals/0/residuals.dat
The comment is based experience with version 3.0.1 but I expect that older versions contain the utility as well.
Zbynek is offline   Reply With Quote

Old   September 8, 2016, 12:15
Default
  #6
Senior Member
 
tareqkh's Avatar
 
CFD
Join Date: Nov 2010
Location: United States
Posts: 243
Rep Power: 17
tareqkh is on a distinguished road
Quote:
Originally Posted by Zbynek View Post
To plot residuals, you can use the function object called, as expected, residuals. It comes alongside the installation of OF. All you need to do is to add a few lines to your controlDict in the block called functions.

Code:
functions
{
    residuals
    {
        type            residuals;
        functionObjectLibs ("libutilityFunctionObjects.so");
        enabled         true;
        outputControl   timeStep;
        outputInterval  1;

        fields
        (
            p
            U
            k
            epsilon
        );
    }
}
An example of the necessary inputs for the code is in $FOAM_ETC/caseDicts/postProcessing/numerical. This utility ensures that the residual values are written to a folder in your working directory. You can plot them using the foamMonitor utility (gnuplot needed).

Code:
foamMonitor -l postProcessing/residuals/0/residuals.dat
The comment is based experience with version 3.0.1 but I expect that older versions contain the utility as well.
I have added the quoted line into cotrolDict and got the following error;

Code:
 --> FOAM FATAL ERROR: 
Unknown function type residuals

Valid functions are : 

21
(
CourantNo
DESModelRegions
Lambda2
Peclet
Q
blendingFactor
coded
dsmcFields
patchProbes
pressureTools
probes
scalarTransport
setTimeStep
sets
surfaces
timeActivatedFileUpdate
turbulenceFields
vorticity
wallShearStress
yPlusLES
yPlusRAS
)



    From function functionObject::New(const word& name, const Time&, const dictionary&)
    in file db/functionObjects/functionObject/functionObject.C at line 92.

FOAM exiting
Any clues on what is going on?

Best,
tareqkh is offline   Reply With Quote

Old   September 9, 2016, 04:16
Default
  #7
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 11
Zbynek is on a distinguished road
It looks like the function object did not compile when you installed OpenFOAM. That should be no problem though, the source code is still present in your installation. You only need to compile it.

The function object residuals is located in $FOAM_SRC/postProcessing/functionObjects/utilities/residuals.

Check that the C files, which define the residuals, have been included in the corresponding library:
  • In file $FOAM_SRC/postProcessing/functionObjects/utilities/Make/files, check whether the following two lines are present (OpenFOAM v3.0)

residuals/residuals.C
residuals/residualsFunctionObject.C
  • If not, add the lines to the file and then compile the function object (./Allwmake in the functionObjects directory)

Now the function object can be used by any solver.
Kummi and mcfdma like this.
Zbynek is offline   Reply With Quote

Old   September 9, 2016, 13:02
Default
  #8
Senior Member
 
tareqkh's Avatar
 
CFD
Join Date: Nov 2010
Location: United States
Posts: 243
Rep Power: 17
tareqkh is on a distinguished road
Quote:
Originally Posted by Zbynek View Post
It looks like the function object did not compile when you installed OpenFOAM. That should be no problem though, the source code is still present in your installation. You only need to compile it.

The function object residuals is located in $FOAM_SRC/postProcessing/functionObjects/utilities/residuals.

Check that the C files, which define the residuals, have been included in the corresponding library:
  • In file $FOAM_SRC/postProcessing/functionObjects/utilities/Make/files, check whether the following two lines are present (OpenFOAM v3.0)

residuals/residuals.C
residuals/residualsFunctionObject.C
  • If not, add the lines to the file and then compile the function object (./Allwmake in the functionObjects directory)

Now the function object can be used by any solver.
Dear Zbynek,

Thank you for the quick repsonse. I am using OpenFoam version 2.3.1. The function residual it is not in the directory at all. I don't know what to do next.

I look forward to hearing from you.

Best,
tareqkh is offline   Reply With Quote

Old   September 9, 2016, 13:20
Default
  #9
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 11
Zbynek is on a distinguished road
There are several options. If you check the source codes of OpenFOAM in github, you can see that version 2.3.x has a code for the function object residuals available. So just download it and compile it. Maybe a simple update of your OF package would do the trick.

Alternatively, you may think about upgrading your OF version.

Or, you can use another way of plotting residuals. There is the option of doing so using some Python scripts (pyFoam). I have never used these though. I am relatively new to OF and so I have experience only with the versions 3 and 4.
Zbynek is offline   Reply With Quote

Old   September 10, 2016, 12:34
Default
  #10
Senior Member
 
tareqkh's Avatar
 
CFD
Join Date: Nov 2010
Location: United States
Posts: 243
Rep Power: 17
tareqkh is on a distinguished road
Quote:
Originally Posted by Zbynek View Post
There are several options. If you check the source codes of OpenFOAM in github, you can see that version 2.3.x has a code for the function object residuals available. So just download it and compile it. Maybe a simple update of your OF package would do the trick.

Alternatively, you may think about upgrading your OF version.

Or, you can use another way of plotting residuals. There is the option of doing so using some Python scripts (pyFoam). I have never used these though. I am relatively new to OF and so I have experience only with the versions 3 and 4.
Hello Zbynek,

Thanks again for you reply. I have copied the residuals residuals.tar.gz function in the directory $FOAM_SRC/postProcessing/functionObjects/utilities/ as you stated. Then I relocate to the directory as follows;

/OpenFOAM/OpenFOAM-2.3.1/src/postProcessing/functionObjects$

Then I typed ./Allmake. However, the function is still not working. Do you have any other trick that could save me install Openfoam?

I look forward to hearing from you.

Best regards,
tareqkh is offline   Reply With Quote

Old   September 10, 2016, 14:56
Default
  #11
Member
 
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10
PositronCascade is on a distinguished road
Why don't you plot it using gnuplot? It is very easy if you have a log file. You just need to write one simple file to read residuals. You can find it online or I can share it with you if you can't.



Quote:
Originally Posted by SUBHANKAR View Post
Hi everyone,
I am solving flow past cylinder between two parallel channel(laminar case). I am using pisoFoam solver.After completion of iterations, i tried to plot the residuals by creating log files and then plotting by using the command ./plot. But it didn't plot anything. It also didn't create files in the log folder. Can anybody tell what might have gone wrong? Thanks in advance...
regards Subhankar
PositronCascade is offline   Reply With Quote

Old   September 10, 2016, 15:01
Default
  #12
Senior Member
 
tareqkh's Avatar
 
CFD
Join Date: Nov 2010
Location: United States
Posts: 243
Rep Power: 17
tareqkh is on a distinguished road
Hello Hasan,

The problem of using "log.simpleFoam" or any solver using gnuplot is that I can not export the data to be read in matlab. Therefore, residual function makes the data readable in matalb, so that you can make nice eps plots.

I hope that you understand why I need it to work in OpenFoam 2.3.1

Best,


tareqkh is offline   Reply With Quote

Old   September 10, 2016, 15:12
Default
  #13
Member
 
Hasan Celik
Join Date: Sep 2016
Posts: 64
Rep Power: 10
PositronCascade is on a distinguished road
Oh, I see. I hope you can find an easy way to do it. If you can't find a solution and if you really need to obtain residuals in Matlab, I may suggest you to work with log file in the sense of gnuplot. You can try to catch the number followed by a string. As an example what I mean, please check this link:

https://www.mathworks.com/matlabcent...ng-in-txt-file


I wish you good luck!


Quote:
Originally Posted by tareqkh View Post
Hello Hasan,

The problem of using "log.simpleFoam" or any solver using gnuplot is that I can not export the data to be read in matlab. Therefore, residual function makes the data readable in matalb, so that you can make nice eps plots.

I hope that you understand why I need it to work in OpenFoam 2.3.1

Best,


tareqkh likes this.
PositronCascade is offline   Reply With Quote

Old   September 11, 2016, 07:48
Default
  #14
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 11
Zbynek is on a distinguished road
Quote:
Originally Posted by tareqkh View Post
Hello Zbynek,

Thanks again for you reply. I have copied the residuals Attachment 50436 function in the directory $FOAM_SRC/postProcessing/functionObjects/utilities/ as you stated. Then I relocate to the directory as follows;

/OpenFOAM/OpenFOAM-2.3.1/src/postProcessing/functionObjects$

Then I typed ./Allmake. However, the function is still not working. Do you have any other trick that could save me install Openfoam?

I look forward to hearing from you.

Best regards,
First, I hope that you uncompressed the downloaded .tar file. Second, you still need to add those two lines that I mentioned earlier in the files file. Third, you may rather run Allwmake than Allmake, depending on what script is in your corresponding folder.
Zbynek is offline   Reply With Quote

Old   September 13, 2016, 11:48
Default
  #15
New Member
 
Join Date: Aug 2016
Posts: 12
Rep Power: 10
sage is on a distinguished road
Hey! I am trying to use the wallShearStress function but i get the error library not found. what can i do about it?
sage is offline   Reply With Quote

Old   September 13, 2016, 11:58
Default
  #16
Senior Member
 
tareqkh's Avatar
 
CFD
Join Date: Nov 2010
Location: United States
Posts: 243
Rep Power: 17
tareqkh is on a distinguished road
Quote:
Originally Posted by sage View Post
Hey! I am trying to use the wallShearStress function but i get the error library not found. what can i do about it?
Hey Sage,

You need to download the source files from github. Then paste the files into the following directory;

OpenFoam/OpenFoamV/src/postProcessing/functionObjects/utilities

Finally, go to the following directory;

OpenFoam/OpenFoamV/src/postProcessing/functionObjects/utilities/Make/

Open the file "files" and add the following lines;

wallShearStress/wallShearStress.C
wallShearStress/wallShearStressFunctionObject.C

Hit cd ../cd .. to relocate to

OpenFoam/OpenFoamV/src/postProcessing/functionObjects

And then ./Allwmake

Best,
sage likes this.
tareqkh is offline   Reply With Quote

Old   September 13, 2016, 12:27
Default
  #17
New Member
 
Join Date: Aug 2016
Posts: 12
Rep Power: 10
sage is on a distinguished road
Quote:
Originally Posted by tareqkh View Post
Hey Sage,

You need to download the source files from github. Then paste the files into the following directory;

OpenFoam/OpenFoamV/src/postProcessing/functionObjects/utilities

Finally, go to the following directory;

OpenFoam/OpenFoamV/src/postProcessing/functionObjects/utilities/Make/

Open the file "files" and add the following lines;

wallShearStress/wallShearStress.C
wallShearStress/wallShearStressFunctionObject.C

Hit cd ../cd .. to relocate to

OpenFoam/OpenFoamV/src/postProcessing/functionObjects

And then ./Allwmake

Best,
Hey! Thanks a lot! I managed to get root access, download the source and header files in utilities. but when i enter ./Allwmake, it starts giving me errors.

+ wmake libso field
./Allwmake: 6: ./Allwmake: wmake: not found
+ wmake libso forces
./Allwmake: 7: ./Allwmake: wmake: not found
+ wmake libso IO
./Allwmake: 8: ./Allwmake: wmake: not found
+ wmake libso utilities
./Allwmake: 9: ./Allwmake: wmake: not found
+ wmake libso jobControl
./Allwmake: 10: ./Allwmake: wmake: not found
+ wmake libso systemCall
./Allwmake: 11: ./Allwmake: wmake: not found

Your help would be greatly appreciated.

Last edited by sage; September 13, 2016 at 15:52.
sage is offline   Reply With Quote

Old   January 7, 2017, 05:31
Default foamMonitor for chtMultiRegionSimpleFoam
  #18
Member
 
Join Date: Sep 2016
Posts: 63
Rep Power: 10
sitajeje is on a distinguished road
Happy New Year everybody,

I use OF4.0. For the cavity case I can plot the residuals by adding the following lines in controlDict

functions { #includeFunc residuals }
and run the following command

foamMonitor -l postProcessing/residuals/0/residuals.dat

The same method does not work for chtMultiRegionSimpleFoam. The solver broke the computation and in the log.chtMultiRegionSimpleFoam it is written:

--> FOAM FATAL IO ERROR:
"ill defined primitivEntry starting at keyword 'residuals'... "

in the log.foamMonitor it is written:
file postprocessing/residuals/0/residuals.dat does not exit

Does anyone know to to plot residuals for chtMultiRegionSimpleFoam?

Thank you very much in advance!
sitajeje is offline   Reply With Quote

Old   May 28, 2017, 09:37
Default
  #19
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
Quote:
Originally Posted by SUBHANKAR
I used the commands. But it didn't plot anything.It shows "pyFoamPlotWatcher.py: command not found".
I want to be able to watch the residuals in real time during the solve, but I get the same error using OpenFoam 2.4.0.

Quote:
Originally Posted by McCharles View Post
Is python installed on your Computer? The commands you used are correct, so there is certainly something wrong with your Python installation.
Can someone help me figure out how to get python properly installed? I am using OpenSuse 13.2, Gnome 3.14.1. I'm pretty new to Linux and don't know how to check to see if python is installed, or how to install it if found missing.

Thanks,
M Ridzon
m_ridzon is offline   Reply With Quote

Old   August 5, 2018, 22:59
Default
  #20
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 17
Elham is on a distinguished road
Ok guys. Anyone knows how to plot variables from log file not just residuals. I have tried making logs directory and see alpha values when I list,ie, execute ls. But when I execute
Code:
plot './alpha.water_0' with lines
in gnuplot, there is just a straight line equal to zero in respect to time for alpha.water thought I see it changes during the time.

Cheers,

Elham
Elham 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
plotting grid-wise residuals defrak OpenFOAM 1 May 20, 2015 04:30
[PyFoam] Plotting values (e.g. residuals) from all iterations with pyFoam chriss85 OpenFOAM Community Contributions 5 November 11, 2014 12:13
Plotting residuals krembil OpenFOAM Running, Solving & CFD 2 August 16, 2014 04:38
Plotting Residuals using HelyxOS EFoster2 OpenFOAM Running, Solving & CFD 0 February 17, 2014 21:05
Plotting Residuals ata OpenFOAM 12 July 8, 2011 03:50


All times are GMT -4. The time now is 13:12.