# How to plot local residuals' field (for each cell) ? OF 5.x

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

 April 18, 2018, 12:01 How to plot local residuals' field (for each cell) ? OF 5.x #1 Senior Member   Deep Join Date: Oct 2017 Posts: 180 Rep Power: 5 Hello, I was wondering if at all it is possible to do this. If yes, I could locate the problem areas in the mesh quickly whenever the run crashes. So I looked up on the forum and found mostly very old and semi-inconclusive threads. So I am using OF 5.x version and I want to plot residuals for quantities like T, p, U for each cell in the domain and maybe view that in paraview. I came across this relatively recent thread, but this is not what I want. I have been doing this using gnuplot script. But this is average residual of each quantity with respect to time. I want it for each cell and of course for each time step. So that I can see exactly what's happening where in the field right before it crashes. I'm not sure if pyFoam can be used. If so, could you point me to latest resource compatible with OF 5 please (I found very old resources)? I am hoping someone could point me to correct tool/way to do this?

 May 9, 2018, 04:10 #2 New Member   manu ebn Join Date: Aug 2015 Location: Switzerland Posts: 18 Rep Power: 7 Hi deep Have you found a solution for this? I would like to have the same. All i found was the following thread: Residual Field OpenFOAM They calculate the residuals manually, by compiling a new solver. The solver calculates then the residuals based on the matrix equation: Ax = b where A is the coeff.matrix, x is the vector with the cell-values and b stays for BC's. The residuals are defined as followed: r = b - Ax I tried to do the same, but one of the coefficients was to big (i think it was the convection term) and therefore i didnt get sufficient residuals. Best wishes Triggin

May 17, 2018, 13:13
#3
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 5
Quote:
 Originally Posted by Triggin Hi deep Have you found a solution for this? I would like to have the same. All i found was the following thread: Residual Field OpenFOAM They calculate the residuals manually, by compiling a new solver. The solver calculates then the residuals based on the matrix equation: Ax = b where A is the coeff.matrix, x is the vector with the cell-values and b stays for BC's. The residuals are defined as followed: r = b - Ax I tried to do the same, but one of the coefficients was to big (i think it was the convection term) and therefore i didnt get sufficient residuals. Best wishes Triggin
Hey!

Sorry I missed your post. It seems I missed another from a month ago!

No, I haven't yet found any solution to this. However I don't have any sudden changes in variable values so exploring this has taken a back seat for now. However I'm definitely interested in finding a solution.

The thread you've mentioned wasn't much useful. simpleFoamResidual gives me temporal residuals not spatial.

For the record, with OF5.x the correct command is
Code:
`solverName -postProcess -func simpleFoamResidual`

 June 9, 2018, 20:39 How to plot local residuals' field (for each cell) ? OF 5.x #4 Member   abdikerim kurbanaliev Join Date: Jun 2010 Location: Kyrgyzstan, Osh Posts: 79 Rep Power: 12 Dear Deep, Were you able to solve this problem? I'm interested in it too. I found another links for that: 1. Local residuals. 2. https://github.com/Unofficial-Extend...FoamResidual.C Regards, Kerim

June 11, 2018, 06:22
#5
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 5
Quote:
 Originally Posted by kerim Dear Deep, Were you able to solve this problem? I'm interested in it too. I found another links for that: 1. Local residuals. 2. https://github.com/Unofficial-Extend...FoamResidual.C Regards, Kerim
Hello Kerim,
I have been through these before. Weren't much useful, especially because this is for 1.6 and OF has evolved a lot since then. For my purpose, Co was very high and I could plot a Co filed and it sufficed. So still looking for residuals...
Code:
`solverName -postProcess -func CourantNo`
(This is listed on U-185 of user guide OF 5.0)

 October 3, 2018, 10:43 Any new ideas? #6 New Member   Miguel Join Date: Apr 2018 Posts: 2 Rep Power: 0 Hi all, Has any of you found some way of achieving this? I'm also struggling to represent a residual field for each time step. It would be super useful for finding the area of the simulation where the trouble begins... Cheers, Serra

October 4, 2018, 07:23
#7
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 5
Quote:
 Originally Posted by mserra Hi all, Has any of you found some way of achieving this? I'm also struggling to represent a residual field for each time step. Cheers, Serra
No Serra Serra. (#sorry)

Quote:
 Originally Posted by mserra It would be super useful for finding the area of the simulation where the trouble begins...
Indeed. However, I haven't found any solution so far. Will update this if I do.

 October 4, 2018, 07:55 #8 Senior Member   Yann Join Date: Apr 2012 Location: France Posts: 207 Rep Power: 14 Hi! I didn't have a chance to try it yet, but the residuals function object seems to do the job in openFoam-v1806 according to the releases notes : https://www.openfoam.com/releases/op...esidual-fields Not sure it's available in the foundation branch though, I didn't check.

October 4, 2018, 08:26
#9
New Member

Miguel
Join Date: Apr 2018
Posts: 2
Rep Power: 0
Quote:
 Originally Posted by Yann Hi! I didn't have a chance to try it yet, but the residuals function object seems to do the job in openFoam-v1806 according to the releases notes : https://www.openfoam.com/releases/op...esidual-fields Not sure it's available in the foundation branch though, I didn't check.
Great!! Thanks for sharing it! It seems to be just what we wanted I'm going to try it in the CFD-Support version for windows (The only one that could be installed at my work )

Quote:
 Originally Posted by deepbandivadekar No Serra Serra. (#sorry)

October 4, 2018, 08:58
#10
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 5
Quote:
 Originally Posted by Yann Hi! I didn't have a chance to try it yet, but the residuals function object seems to do the job in openFoam-v1806 according to the releases notes : https://www.openfoam.com/releases/op...esidual-fields Not sure it's available in the foundation branch though, I didn't check.

That's interesting. It does look like there's a similar function for OF 5 as well as OF 6:
https://github.com/OpenFOAM/OpenFOAM...ls/residuals.H

When I had posted this question I was primarily working on a branch of OF 2.4.x. It didn't have functionObjects. However, am still not sure if this is the right utility that we are looking for. I tried it on a case and it doesn't write the residuals as suggested in the header file. Or perhaps am not using the it the right way (I added it in the controlDict file)?

October 4, 2018, 09:28
#11
Senior Member

Yann
Join Date: Apr 2012
Location: France
Posts: 207
Rep Power: 14
Quote:
 Originally Posted by deepbandivadekar When I had posted this question I was primarily working on a branch of OF 2.4.x. It didn't have functionObjects. However, am still not sure if this is the right utility that we are looking for. I tried it on a case and it doesn't write the residuals as suggested in the header file. Or perhaps am not using the it the right way (I added it in the controlDict file)?

residuals is quite an old functionObject. As far as I remember, it was already there in OF 2.3.x. But the original function only writes a dat file reporting the residuals in the postProcessing directory.
What's new is the possibility to write residuals as a volume field.

This new functionality seems to be specific to OF v1806 since the residuals functionObject source code in OF 6 lacks the writeFields option.

2 options for you : trying the residuals functionObject in OF v1806 or trying to compile the source code from the v1806 function in OF 6.

October 4, 2018, 10:02
#12
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 5
Quote:
 Originally Posted by Yann residuals is quite an old functionObject. As far as I remember, it was already there in OF 2.3.x. But the original function only writes a dat file reporting the residuals in the postProcessing directory. What's new is the possibility to write residuals as a volume field. This new functionality seems to be specific to OF v1806 since the residuals functionObject source code in OF 6 lacks the writeFields option.
Yes I knew that, I meant the functionObject that writes residuals as volume field rather than the typical dat file.

Quote:
 Originally Posted by Yann 2 options for you : trying the residuals functionObject in OF v1806 or trying to compile the source code from the v1806 function in OF 6.

 October 9, 2018, 00:47 #13 Super Moderator     Tobias Holzmann Join Date: Oct 2010 Location: Augsburg Posts: 2,514 Blog Entries: 6 Rep Power: 46 Hi all, to sum up, the information of the discussed residual object function is presented here https://www.openfoam.com/releases/op...esidual-fields C. Okubo likes this. __________________ Keep foaming, Tobias Holzmann

 January 24, 2019, 05:47 #14 New Member   Gerhard Join Date: Mar 2017 Posts: 24 Rep Power: 6 Yes, this is exactly what I would also like to do. Thanks for the thread you posted Tobi. It is great, but I just do not know how to implement this into OpenFOAM v5.0? The residuals functionObject in OF50 does not allow for writeFields to be set to true. The date of this "New and Improved Post-Processing" post was on 29/06/2018. OpenFOAM v5.0 is older. Is there thus a way to update it or something so that the new residuals functionObject comes into play?

 Tags openfoam 5.x, pyfoam, residual, residual field