|
[Sponsors] |
Difference between "fields" and "equations" relaxation sub-directories in fvSolution |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 | |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 ![]() |
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; } } Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 ![]() |
Anyone ? Please.
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
|
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 Example: Code:
relaxationFactors { fields { default 0; p 0.3; // U 0.7; } equations { default 0; U 0.7; k 0.9; epsilon 0.9; } } |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 8 ![]() |
Thanks. I'll keep it in mind.
|
|
![]() |
![]() |
![]() |
![]() |
#5 | |
New Member
Ilteber Ozdemir
Join Date: Dec 2019
Posts: 2
Rep Power: 0 ![]() |
Quote:
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 Code:
cd $FOAM_SRC grep -r "relax" 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 ![]() Cheers, |
||
![]() |
![]() |
![]() |
![]() |
#6 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 ![]() ![]() ![]() |
Well explained, totally agree and I want to give a few more informations regarding this particular topic:
Field relaxation:
![]() 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 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:
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: ![]() And you add something to the RHS, you also do have to make it equally on the LHS to get the correct solution: ![]() 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 |
|
![]() |
![]() |
![]() |
![]() |
#7 | ||
Member
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 41
Rep Power: 12 ![]() |
Quote:
Quote:
Thank you |
|||
![]() |
![]() |
![]() |
![]() |
#8 |
New Member
Join Date: Dec 2021
Posts: 7
Rep Power: 4 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Member
Join Date: Mar 2015
Posts: 36
Rep Power: 11 ![]() |
@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. |
|
![]() |
![]() |
![]() |
![]() |
#10 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 ![]() ![]() ![]() |
Quote:
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 |
||
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
|
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. |
|
![]() |
![]() |
![]() |
![]() |
#12 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 ![]() ![]() ![]() |
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
__________________
Keep foaming, Tobias Holzmann |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
|
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? |
|
![]() |
![]() |
![]() |
|
|