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

Residuals of rhoCentralFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 31, 2020, 04:50
Default Residuals of rhoCentralFoam
  #1
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Dear foamers,



I am struggling to find a way to have a better insight of convergence of simulations done with rhoCentralFoam as the latter does not print residuals. I tried three ways but although it can be seen in the paraview that the case is converged, the residuals obtained by these methods do to reflect this fact. The methods being used so far are:

1) Compare the initial values of rho, rhoU and rhoE with their final calculated values for all cell points and take the maximum value of it; for instance for rho we have: mag(max(rho_f-rho_0)).value() where rho_f and rho_0 refere, respectively, to the final calculated value and initial value for rho. The same is done for rhoU and rhoE.
This was not a very helpful. I can imagine that if the calculation is converged for all the points except one, this method will fail as the maximum of difference could remain the same. So, it is enough that you fix the outlet waveTransmissive boundary condition for pressure to something wrong, the whole domain converges except the final point where the converged value is different from the fixed value.

2) Calculate the difference of calculated variables and their initial values for all cell points and sum the absolute values over all cells; for rho we have: sum(mag(rho_f-rho_0)).value(). Again this method can fail for the same reason as the one mentioned above. If I am not wrong, this method is what is called as unscaled residual in the link below.

3) Calculate the difference of calculated variables and their initial values for all cell points and sum the absolute values over all cells and divide the sum of absolute values per the sum of absolute calculated values; for rho we have: (sum(mag(rho_f-rho_0))/sum(mag(rho_f))).value(). Again this method can fail for the same reason as the one mentioned above. If I am not wrong, this method is what is called as unscaled residual in the link below.


link: https://www.afs.enea.it/project/nept...ug/node812.htm


Could you help me to figure it out how to solve this important issue ?

Thanks in advance,
Mary
mkhm is offline   Reply With Quote

Old   July 31, 2020, 09:45
Default
  #2
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 729
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
1/ Do you mean mag(rho_f).value() / mag(rho_0).value() ?

(alternative order of brackets)

2/ Can you see residual norms on the screen? Capture them in log-file and plot with appropriate tools?

3/ Do you want to see residual fields in paraview?

Cheers, D.
dlahaye is offline   Reply With Quote

Old   July 31, 2020, 09:57
Default
  #3
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by dlahaye View Post
1/ Do you mean mag(rho_f).value() / mag(rho_0).value() ?

(alternative order of brackets)

2/ Can you see residual norms on the screen? Capture them in log-file and plot with appropriate tools?

3/ Do you want to see residual fields in paraview?

Cheers, D.

Dear dlahaye,
1. I think whether you do mag(something_1).value() / mag(something_2).value() or (mag(something_1/something_2)).value(), they are both equivalent. However, I don't understand why this division should reflect the convergence of the solution.
2. Seeing residuals is not a problem. I am using gnuplot.
3. I don't know how to see the residuals in paraview. But, don't forget that here, there is no calculation of residual in the openFoam native solver of rhoCentralFoam. So first, we need to find an appropriate way to calculate residuals and after I'll learn how to do it with paraview.
mkhm is offline   Reply With Quote

Old   July 31, 2020, 14:20
Default
  #4
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 729
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Possibly we are lost in translation.

However, mag(vec1/vec2) <> mag(vec1) / mag(vec2).

Left-hand side involves a division of vectors. This operation is typically not defined.

Right-hand side involves a division of numbers.

D.
dlahaye is offline   Reply With Quote

Old   August 1, 2020, 03:20
Default
  #5
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 10
usv001 is on a distinguished road
Hi Mary,

I am not sure why you're taking the difference between the initial and final values. It may be something particular to your application. My understanding of residuals is that you need to take the difference between subsequent time steps to determine how much difference there is in one time step. When your solution has converged, this should be very small.

So, you may try to replace this code in rhoCentralFoam:
Code:
solve(fvm::ddt(rho) + fvc::div(phi));
with this:
Code:
const volScalarField rho0(rho); // @ previous time step

solve(fvm::ddt(rho) + fvc::div(phi));

const scalar massError
(
    sum(mag(rho - rho0)*mesh.V()).value()
);

Info<< "Mass error: " << massError << endl;
to compute the mass error. That should give you an indication of the convergence of your results.

Hope this helps.

Cheers,
USV
usv001 is offline   Reply With Quote

Old   August 3, 2020, 03:48
Default
  #6
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hi Mary,

I am not sure why you're taking the difference between the initial and final values. It may be something particular to your application. My understanding of residuals is that you need to take the difference between subsequent time steps to determine how much difference there is in one time step. When your solution has converged, this should be very small.

So, you may try to replace this code in rhoCentralFoam:
Code:
solve(fvm::ddt(rho) + fvc::div(phi));
with this:
Code:
const volScalarField rho0(rho); // @ previous time step

solve(fvm::ddt(rho) + fvc::div(phi));

const scalar massError
(
    sum(mag(rho - rho0)*mesh.V()).value()
);

Info<< "Mass error: " << massError << endl;
to compute the mass error. That should give you an indication of the convergence of your results.

Hope this helps.

Cheers,
USV

Dear USV,
I do consider what you call as the subsequent time steps as follows :
Code:
volScalarField rho_0("rho_0", rho);
solve(fvm::ddt(rho) + fvc::div(phi));
volScalarField rho_f("rho_f", rho);
scalar rho_Res = sum(mag(rho_f-rho_0)).value();
Is it correct what I do ? Why in your code, there is "*mesh.V()"? What does that mean ?
If it is correct what I am doing, I don't understand why it does not reflect the convergence of the simulation. If it is not correct, could you please indicate how I can correct what is wrong ?


Thanks in advance
mkhm is offline   Reply With Quote

Old   August 3, 2020, 09:54
Default
  #7
Senior Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 102
Rep Power: 10
usv001 is on a distinguished road
Hi Mary,

"mesh.V()" is the cell volume. So, when multiplied by density, the residual has units of mass. I think you can try to divide it by "sum(mesh.V()).value()" to get back density.

By the way, what you're doing should also be valid as it measures the change between two time steps. Why do you say that it does not reflect convergence? It should if your solution has converged.

USV
usv001 is offline   Reply With Quote

Old   August 3, 2020, 13:41
Default
  #8
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hi Mary,

"mesh.V()" is the cell volume. So, when multiplied by density, the residual has units of mass. I think you can try to divide it by "sum(mesh.V()).value()" to get back density.

By the way, what you're doing should also be valid as it measures the change between two time steps. Why do you say that it does not reflect convergence? It should if your solution has converged.

USV

Thanks USV for your reply. I attach the plot of residuals. My supervisor had told me that the residuals should usually decrease for 3 order of magnitude. You can see in the attached file that is not the case. However, I am sure that it is not within 10000 iterations that the case is converged, it should be after. And I am sure that the case is converged because if I plot results on three different axis of the geometry, nothing changes after a while. So I am pretty sure that the case is converged but the plot of residuals and more precisely my residual calculation does not reflect that.
Attached Images
File Type: png U_Test2.png (4.0 KB, 22 views)
mkhm is offline   Reply With Quote

Reply

Tags
convergence, residual, rhocentralfoam


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
rhoCentralFoam residuals TommyM OpenFOAM Running, Solving & CFD 6 August 12, 2021 16:40
inviscid rhoCentralFoam: residuals -> convergence ? mkhm OpenFOAM Running, Solving & CFD 0 June 3, 2020 14:29
how to make rhoCentralFoam to write continuity residuals? immortality OpenFOAM Running, Solving & CFD 6 April 18, 2018 03:56
motorBike Residuals for SST k-omega... and mine JR22 OpenFOAM Running, Solving & CFD 6 August 1, 2013 09:08
how to modify rhoCentralFoam to write continuity residuals? immortality OpenFOAM Programming & Development 0 May 1, 2013 12:44


All times are GMT -4. The time now is 16:58.