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 Members List Search Today's Posts Mark Forums Read

Like Tree20Likes
  • 2 Post By tomf
  • 7 Post By rilteber
  • 11 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2017, 10:05
Default Difference between "fields" and "equations" relaxation sub-directories in fvSolution
  #1
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 6
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, 04:46
Default
  #2
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 6
deepbandivadekar is on a distinguished road
Anyone ? Please.
deepbandivadekar is offline   Reply With Quote

Old   January 16, 2018, 04:53
Default
  #3
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 593
Rep Power: 29
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;
    }
}
lourencosm and wdx_cfd like this.
tomf is offline   Reply With Quote

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

Old   September 9, 2020, 12: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, tonnykz and 4 others like this.
rilteber is offline   Reply With Quote

Old   September 10, 2020, 08:27
Default
  #6
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,654
Blog Entries: 6
Rep Power: 48
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, 09:57
Default
  #7
Member
 
Lourenšo SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 33
Rep Power: 9
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

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:24.