|
[Sponsors] |
February 19, 2010, 17:55 |
Dynamic under-relaxation
|
#1 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Just out of curiosity, has anybody tried to implement (or perhaps it exists and I just don't know about it) a type of "dynamic under/over-relaxation" function where the relaxation parameter changes on the fly based on the residual history?
I've done this before in my own simple matlab code and I've found that it can help speed up convergence or simply get a simulation to converge, especially for highly coupled systems. |
|
February 25, 2010, 02:17 |
|
#2 | |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Quote:
you can quite easily change the relaxation factor in OpenFOAM, also dynamically. You simply need to specify the value when you call relax(). For example UEqn.relax(0.7); Of course in your case the fixed value is replaced by a variable. In addition, you can access the residuals defining a solverPerformance object solverPerformance sp; then, when you solve sp = solve(....); or sp = UEqn.solve(); and, to recover the initial residual (a scalar called resU in my example) resU = sp.initialResidual(); Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
||
February 25, 2010, 11:44 |
|
#3 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
Aha! Thanks. That sounds like exactly what I need.
What's the best way to find these sorts of things out? Do I have to dig through the code or is there a better way? |
|
February 25, 2010, 12:53 |
|
#4 | |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Quote:
Sooner or later I'll add these info to the wiki as part of my plan to provide a bit more info, but if you can do that, I can review the page (yes, I'm shamelessly asking for wiki volunteers to help ) Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
||
March 1, 2010, 12:21 |
|
#5 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
There's another piece that I can't figure out:
How can I return the current value of the relaxation factor? Or better yet, set it using code like: C_Eqn.relaxationFactor() = C_Eqn.relaxationFactor() / 5; I've tried: C_Eqn.relaxationFactor(), C_Eqn.relax().value(), none seem to work... For example, this is the code that I'm trying to implement in my solver which keeps track of the last 10 residual values and if the residual value is increasing, then I want to divide the relaxation factor by 5: Code:
double residual[10]; int res_index = count % 10; // count is just the number of iterations lduMatrix::solverPerformance C_res; fvScalarMatrix C_Eqn ( fvm::laplacian(Dc, C) ); C_Eqn.relax(); C_res = solve(C_Eqn); residual[res_index] = C_res.initialResidual(); // this all works and stores last 10 residual values if (residual[9]-residual[0] > 10) { // This part doesn't work. I'd like to just reduce the relaxation factor by 5 C_Eqn.relaxationFactor() = C_Eqn.relaxationFactor() / 5; } |
|
June 8, 2010, 04:59 |
|
#6 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
What happens when you try that line? It might be due to integer division, use " / 5.0" instead.
|
|
June 8, 2010, 10:17 |
|
#7 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
I found that it's easier just to define a variable as my relaxation factor and then relax with that variable. Something like this:
Code:
scalar dampingCoeff = 0.5; <insert algorithm to change dampingCoeff based on convergence> CEqn.relax(dampingCoeff); |
|
August 12, 2015, 14:48 |
|
#8 |
New Member
Michael
Join Date: Feb 2015
Posts: 18
Rep Power: 11 |
Hello to everybody. Does anybody know wy when I use a segregated approuch for the velocity solve ( ...) gives back a non empty opject of the type solverPerformance but when I solve it coupled solve (...) gives me back the standard constructor containing zeros for ntierations, initalResidual, finialResidual and so one.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh Problem. | Tom Clark | FLUENT | 10 | June 21, 2021 05:27 |
Regarding Negative volume detected in Dynamic mesh | Vinay Morabad | FLUENT | 10 | December 16, 2015 01:31 |
Relaxation and convergence | sammi | Phoenics | 0 | March 20, 2008 04:32 |
Dynamic mesh + grid adapt = Crash! (Files included | BillH | FLUENT | 4 | July 24, 2007 16:31 |
Question on adjusting relaxation factor | CFD Rookie | Main CFD Forum | 3 | January 26, 2004 15:37 |