|
[Sponsors] |
October 21, 2015, 15:46 |
How to limit the maximal velocities
|
#1 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
Hello!
I'm having some trouble with limiting the maximal velocities inside the whole domain. I've tried with a loop, something like in this thread http://www.cfd-online.com/Forums/ope...terfoam-2.html When i try Code:
forAll(U,celli) { if (U[celli].component(vector::X) > 1){ U[celli].component(vector::X) = 1;} if (U[celli].component(vector::Y) > 1){ U[celli].component(vector::Y) = 1;} if (U[celli].component(vector::Z) > 1){ U[celli].component(vector::Z) = 1;} } Thanks in advance! Matej |
|
October 22, 2015, 00:13 |
|
#2 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
You probably want to double check that you're performing the limit after the last time U is updated. With piso this is often at the very end of the timestep loop.
See line #128: https://github.com/OpenFOAM/OpenFOAM...oam/pisoFoam.C |
|
October 23, 2015, 21:32 |
|
#3 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
Hi!
Thank you for your answer. That was actually the problem... However, I also want to bound the max k and epsilon values when using a k-epsilon model and k and omega values when using a k-omega model. But when I use Code:
forAll(k, celli) Code:
error: ‘k’ was not declared in this scope Regards, Matej |
|
October 23, 2015, 21:35 |
|
#4 | |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
Quote:
Hi Matej, You just need to lookup the field of interest before trying to operate on it at the top level of the solver. This should explain how: https://openfoamwiki.net/index.php/Contrib/IOReferencer Cheers! Kyle |
||
October 24, 2015, 11:03 |
|
#5 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
Hi Kyle!
So I've looked in the code kEpsilon.H, and k nad epsilon are IObjects. But when compiling with: Code:
const volScalarField& k = db().lookupObject<volScalarField>("k"); Code:
error: ‘db’ was not declared in this scope Thanks in advance! Matej |
|
October 24, 2015, 16:04 |
|
#6 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
Instead of
Code:
db() Code:
mesh |
|
October 26, 2015, 18:22 |
|
#7 |
New Member
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15 |
Hi!
Thanks for the response. The mesh part did the trick. However, I couldn't access the k and epsilon values, because they are somehow write-protected. I have found it easier to compile a new turbulence model according to http://www.tfd.chalmers.se/~hani/kur...lenceModel.pdf and manipulated the k and epsilon values in it. Regards, Matej |
|
July 25, 2016, 15:20 |
|
#8 |
New Member
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16 |
I managed to ensure that the velocity can not increase beyond a given threshold value by introducing an artificial hydrodynamic resistance that increases polynomially as the velocity magnitude approaches that limit.
The code is this one forAll(Rdamp,cellI) { Rdamp[cellI] = Rref.value()*Foam:ow((mag(U[cellI])/maxVelocity.value()),10); } Rdamp.correctBoundaryConditions(); Rdamp.relax(); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - fvm::laplacian(mu, U) - fvc::div(mu*fvc::grad(U)().T()) + fvm::Sp(Rdamp, U) ); In my case, the units of Rdamp are [1 -3 -1 0 0 0 0]. With this technique, the pressure correction equation remains conservative. I imposed an high power of 10 to ensure that the dampening resistance is negligible when the velocity is slightly lower than the threshold value. Underelaxation of Rdamp on the order of 0.5 - 0.8 appears to have good effects on the numerical stability of the algorithm. I would be glad to know if this numerical trick works for other cases too. |
|
April 26, 2017, 04:17 |
|
#9 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
For completeness, OpenFOAM now includes fvOptions to do this: limitVelocity (dev), velocityDampingConstraint (plus).
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
Tags |
celli, limit, loop, max velocity |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to increase "Newton Pressure Iteration Limit" | kus | CFX | 9 | April 21, 2013 02:54 |
[OpenFOAM] converting velocities from cell centers to corner | torsy87 | ParaView | 1 | April 14, 2013 09:09 |
Image size limit | Far | Site Help, Feedback & Discussions | 0 | January 13, 2013 11:45 |
The limit of mu_t/mu or mu_t when implementing turbulence model | xl2000 | Main CFD Forum | 0 | April 27, 2012 12:50 |