Dynamic under-relaxation
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. |
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, |
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? |
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 :D) Best, |
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:
|
What happens when you try that line? It might be due to integer division, use " / 5.0" instead.
|
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; |
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.
|
All times are GMT -4. The time now is 04:40. |