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

Difference between "fields" and "equations" relaxation sub-directories in fvSolution

Register Blogs Community New Posts Updated Threads Search

Like Tree40Likes
  • 4 Post By tomf
  • 14 Post By rilteber
  • 21 Post By Tobi
  • 1 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2017, 11:05
Default Difference between "fields" and "equations" relaxation sub-directories in fvSolution
  #1
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Hello Foamers,


I was trying to solve a simple problem with porousSimpleFoam and I was getting a time step continuity error. I got rid of this by making a change to fvSolutions file as shown below. Commented line was the earlier version.

Code:
relaxationFactors
{
    fields
    {
        p               0.3;
        U               0.7;
    }
    equations
    {
//        U               0.7;
        k               0.9;
        epsilon         0.9;
    }
}
However, I have no idea what this means. In the OpenFoam user guide, they only have mentioned that under-relaxation factors can be defined like such and such. But there's no explanation.
Quote:
Relaxation factors for under-relaxation of fields are specified within a field sub-dictionary; relaxation factors for equation under-relaxation are within a equations sub-dictionary.
Can anyone tell me the exact difference between "fields" and "equations" sub-directories for the relaxation factors in fvSolution file ? How to decide which variable goes where?
deepbandivadekar is offline   Reply With Quote

Old   January 15, 2018, 05:46
Default
  #2
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Anyone ? Please.
deepbandivadekar is offline   Reply With Quote

Old   January 16, 2018, 05:53
Default
  #3
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 647
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi,

It depends on the solver. Sometimes the equations are relaxed, sometimes the fields. For simpleFoam U is relaxed on the equation, p on the field. For safety you can include a
Code:
default 0
into the subDicts, which will give an error if you have not defined a particular factor.

Example:

Code:
relaxationFactors
{
    fields
    {
        default        0;
        p               0.3;
//         U               0.7;
    }
    equations
    {
        default        0;
        U               0.7;
        k               0.9;
        epsilon         0.9;
    }
}
tomf is offline   Reply With Quote

Old   January 16, 2018, 05:58
Default
  #4
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Thanks. I'll keep it in mind.
deepbandivadekar is offline   Reply With Quote

Old   September 9, 2020, 13:53
Default
  #5
New Member
 
Ilteber Ozdemir
Join Date: Dec 2019
Posts: 2
Rep Power: 0
rilteber is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Can anyone tell me the exact difference between "fields" and "equations" sub-directories for the relaxation factors in fvSolution file ? How to decide which variable goes where?
As far as I understand, the two relaxation processes are fundementally different. Field relaxation calculates the "new" value of the variable by taking a weighted sum of the "predicted" one and one from "previous" iteration. There is no change in terms of matrix equation that is solved. On the other hand, in equation relaxation the entries of the matrix are changed (diagonal terms are added), in order to make the matrix diagonally dominant. In this method, the diagonal terms of the matrix are inflated on the LHS and same amount is added to RHS (this time explicitly) as a source term. Therefore, one can think of this as an implicit-explicit stabilizer term.
As to your question on which one to use where, you should check the source code of the solver to see which variable is relaxed in which way.
I'd suggest you to check the following files to understand the working of field and equation relaxation:
Code:
OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
finiteVolume/fvMatrices/fvMatrix/fvMatrix.C
You can also simply do
Code:
cd $FOAM_SRC
grep -r "relax"
to observe other uses of relaxation right in the source code.
Additionally there is a beautiful video of Dr. Aidan Wimshurst on YouTube where he mentiones these two types of relaxation:
HTML Code:
https://youtu.be/ahdW5TKacok?t=1594
Hope this helps.

Cheers,
salehi144, Tobi, thiagopl and 11 others like this.
rilteber is offline   Reply With Quote

Old   September 10, 2020, 09:27
Default
  #6
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Well explained, totally agree and I want to give a few more informations regarding this particular topic:

Field relaxation:
  • Does not influence the matrix that is solved
  • Just estimates the new value by using a weighted approach of how much will the quantity change with respect to the old values and the new calculated values. Hence it follows:

\phi^{n} = \phi^{n-1} + \alpha (\phi^n - \phi^{n-1})

Here alpha is the relaxation factor. If it is 1, the new value corresponds to the new calculated one. If it is zero, it will not change. n is the iteration counter as we can iterate over one variable more often.

Matrix Relaxation
The matrix relaxation is, as Rilteber already mentioned, completely different. What we do is actually very simple. Simply spoken: We divide the main diagonal by the relaxation factor. As this factor is commonly smaller than one, we increase the main diagonal numbers such as:
Code:
1 / 0.8 -> 1.25
For spare matrices, as we do have in CFD analysis, it is important that the sum of the off-diagonal elements is always smaller or equal to the value of the diagonal element. This is a requirement of the linear solver we are using to solve the matrix system Ax = b. The more diagonal-dominant a matrix gets, the easier it is for the linear solver to find the solution.

However, it can happen that the value of the sum of the off-diagonal elements is larger compared to the value of the main diagonal element (commonly for shock-waves etc.), hence, for stabilizing the linear solvers and to get to the needed requirements for linear solver, we have to make the matrix at least diagonal dominant. Now you can imagine that the worst diagonal-dominant matrix is defined to be as follows:
  • all diagonal elements are equal to the sum of the off-diagonal elements
  • and at least one entry in the matrix has to have a larger diaganal value compared to the sum of the off-diagonals

The linear solvers work much better if we do have a diagonal-dominant matrix. By the way, e.g., for the pressure field we commonly do have a field relaxation. However, if you switch on the transonic option, you can see in the pEqn.H of pimpleFoam for example, that the pressure equation can be relaxed in addition.

So far so good. However, this is not the full story. Just imagine that you have the equation:
Ax = b

And you add something to the RHS, you also do have to make it equally on the LHS to get the correct solution:
Ax + W = b + W

Hence, as we change the diagonal elements of the matrix, we have to incorporate this change to the RHS (the solution vector b) too. This leads in fact to an increase of the explicit part in b which - could lead - to more outer iterations as we have to converge the explicit part too.


Therefore, matrix relaxation is primarily used to support our linear solver but will make the equation more explicit. So it is a con and pro topic. However, better to have more explicit part and one has to make 4 more outer loops than ignoring the criterion for the linear solvers and the solution will just crash all the time


**** The above given information is not the complete story but it is a good summary ****

More information can be found in the source code primarly in the fvMatrix class.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 30, 2021, 10:57
Default
  #7
Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 41
Rep Power: 12
lourencosm is on a distinguished road
Quote:
Originally Posted by tomf View Post
Hi,

It depends on the solver. Sometimes the equations are relaxed, sometimes the fields. For simpleFoam U is relaxed on the equation, p on the field. For safety you can include a
Code:
default 0
into the subDicts, which will give an error if you have not defined a particular factor.

Example:

Code:
relaxationFactors
{
    fields
    {
        default        0;
        p               0.3;
//         U               0.7;
    }
    equations
    {
        default        0;
        U               0.7;
        k               0.9;
        epsilon         0.9;
    }
}
Quote:
default 0;
is a great solution!
Thank you
lourencosm is offline   Reply With Quote

Old   July 17, 2022, 18:31
Default
  #8
New Member
 
Join Date: Dec 2021
Posts: 7
Rep Power: 4
frubicle93 is on a distinguished road
Is there a way to choose a good value for an equation relaxation factor based on the unrelaxed matrix?

For an unrelaxed matrix, the number of non-dominant cells, maximum relative non-dominance, and average relative non-dominance are calculated in fvMatrix (debug mode). Can these or other quantities be used to calculate a relaxation factor, or do they only tell us when relaxation is necessary?

It appears that the typical strategy is to reduce the relaxation factors until SIMPLE converges.
frubicle93 is offline   Reply With Quote

Old   September 27, 2022, 08:14
Default
  #9
Member
 
Join Date: Mar 2015
Posts: 36
Rep Power: 11
K.C. is on a distinguished road
@frubicle93:
The "best" set of relaxfactors probably depends on your requirement and your case. Tobias stated, that sometimes relaxation is necessary to make the linear solver converge. To check that you must take a look at your matrices (and the matrices depend on your case and mesh) and choose the relaxfactors such, that the matrices become diagonal dominant. This will give you the minimum relaxfactor for each equation. Anymay I have no idea how to check a given matrix in OpenFoam, if it is alreay diagonal-dominant. That might be a cool feature!!!


You could use more relaxation than necessary but this will be a trade-off.

higher relax-factors (alpha ~ 1):
-less outer iterations in PIMPLE loop (overall iterations in SIMPLE loop)
-more iterations of your linear equation solver, because the residual is harder to decrese

smaller relax-factors (alpha ~ 0):
-more outer iterations in PIMPLE loop (overall iterations in SIMPLE loop)
-less iterations of your linear equation solver, because the residual is very easy to decrese




@overall topic:
I found some very usefull YouTube Videos in the channel fluidmechanics 101.
I do not know, if it is allowed to post the link directly here, but you should be able to find the videos on your own by searching for "fluid mechanics 101 relaxation"


Based on these information I wonder, why the implicit relaxation is always used for U and explicit relaxation is always used for p in the solution algorithms like SIMPLE and PIMPLE. Implicit relaxation should always be superior to explicit relaxation, shoudn't it?



Does anyone have an idea about that?


Greets,
K.C.
K.C. is offline   Reply With Quote

Old   September 28, 2022, 13:30
Default
  #10
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by K.C. View Post
@frubicle93:
Anymay I have no idea how to check a given matrix in OpenFoam, if it is alreay diagonal-dominant. That might be a cool feature!!!

You can switch on the debug switch for the linear solvers. Hence, you can check the convergence of the linear solver.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 28, 2022, 14:14
Default
  #11
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
Blog Entries: 1
Rep Power: 18
dlahaye is on a distinguished road
Here is a naughty observation:

I fail to understand why explicit relaxation cannot be incorporated directly into the preconditioner to arrive at a more robust black-box approach.

Examples of the need for explicit relaxation would be valuable to see.

Suggestions welcome.
dlahaye is offline   Reply With Quote

Old   September 29, 2022, 06:39
Default
  #12
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
The matrix should be relaxed (and hence explicitly relaxed - the diag element get larger and we incorporate that into the source -> explicit) before we are starting to solve. Check the code:

Code:
XEqn.relax();  // relax the equation and make it more diagonal dominant if alpha < 1 

XEqn.solve(); // solve the equation -> preconditioner + LS
Maybe I got your statement wrong.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 29, 2022, 08:41
Default
  #13
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
Blog Entries: 1
Rep Power: 18
dlahaye is on a distinguished road
Thank you for getting in touch and apologies for the ambiguity.

Suppose that OpenFoam would allow preconditioning by incomplete factorisation with partial fill-in and drop tolerance. Would then relaxation (in pre-processing stage) still be required?

Does the wish for full-fledged ILU preconditioning motivate changing the OpenFoam matrix format (as the one currently used is too rigid to allow for modern ILU approaches)?

Should this argument be brought to the attention of the ExaFoam project?
dlahaye is offline   Reply With Quote

Old   September 29, 2022, 12:04
Default
  #14
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
So I am not an expert in that particular topic. Hence, I cannot give any feedback. Sorry
dlahaye likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 30, 2022, 05:08
Default
  #15
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
Blog Entries: 1
Rep Power: 18
dlahaye is on a distinguished road
Thank you for confirming that the issue is not as clearly settled as initially imagined. Cheers.
dlahaye 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



All times are GMT -4. The time now is 21:08.