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

Dynamic under-relaxation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By alberto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 19, 2010, 17:55
Default Dynamic under-relaxation
  #1
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
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.
benk is offline   Reply With Quote

Old   February 25, 2010, 02:17
Default
  #2
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by benk View Post
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.
Hi,

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,
fumiya and C. Okubo like this.
__________________
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.
alberto is offline   Reply With Quote

Old   February 25, 2010, 11:44
Default
  #3
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
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?
benk is offline   Reply With Quote

Old   February 25, 2010, 12:53
Default
  #4
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by benk View Post
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?
Unfortunately the code is the only actually complete reference. You find how residuals can be extracted in simpleFoam, and the relaxation with specified URF in the code can be seen applied in pimpleFoam.

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.
alberto is offline   Reply With Quote

Old   March 1, 2010, 12:21
Default
  #5
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
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;
}
benk is offline   Reply With Quote

Old   June 8, 2010, 04:59
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
What happens when you try that line? It might be due to integer division, use " / 5.0" instead.
akidess is offline   Reply With Quote

Old   June 8, 2010, 10:17
Default
  #7
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
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);
benk is offline   Reply With Quote

Old   August 12, 2015, 14:48
Default
  #8
New Member
 
Michael
Join Date: Feb 2015
Posts: 18
Rep Power: 11
allett02015 is on a distinguished road
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.
allett02015 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


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


All times are GMT -4. The time now is 02:20.