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

How to limit the maximal velocities

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 21, 2015, 15:46
Default How to limit the maximal velocities
  #1
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15
matejmuller is on a distinguished road
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;}
}
and call it right after the Ueqn.h, it compiles without errors, but the velocities from the results are still greater than 1. I'm pretty new to openfoam code...I've read that one should do this without a loop... has anyone any idea how to do that?

Thanks in advance!

Matej
matejmuller is offline   Reply With Quote

Old   October 22, 2015, 00:13
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
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
kmooney is offline   Reply With Quote

Old   October 23, 2015, 21:32
Default
  #3
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15
matejmuller is on a distinguished road
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)
in interfoam.c, at compiling I get the message:

Code:
error: ‘k’ was not declared in this scope
Do I have to compile a new turbulence model? Perhaps there is a simpler way to do this? I would imagine openfoam has this already implemented but where can i define the max values?

Regards, Matej
matejmuller is offline   Reply With Quote

Old   October 23, 2015, 21:35
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
Quote:
Originally Posted by matejmuller View Post
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)
in interfoam.c, at compiling I get the message:

Code:
error: ‘k’ was not declared in this scope
Do I have to compile a new turbulence model? Perhaps there is a simpler way to do this? I would imagine openfoam has this already implemented but where can i define the max values?

Regards, Matej

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

Old   October 24, 2015, 11:03
Default
  #5
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15
matejmuller is on a distinguished road
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");
I get:

Code:
error: ‘db’ was not declared in this scope
What does " // The "db()" above may vary" in your provided link mean?

Thanks in advance!

Matej
matejmuller is offline   Reply With Quote

Old   October 24, 2015, 16:04
Default
  #6
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
Instead of
Code:
db()
try:
Code:
mesh
Which should work in the top level solver (for most solvers).
kmooney is offline   Reply With Quote

Old   October 26, 2015, 18:22
Default
  #7
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 25
Rep Power: 15
matejmuller is on a distinguished road
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
matejmuller is offline   Reply With Quote

Old   July 25, 2016, 15:20
Default
  #8
New Member
 
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 17
vitor.geraldes@ist.utl.pt is on a distinguished road
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.
vitor.geraldes@ist.utl.pt is offline   Reply With Quote

Old   April 26, 2017, 04:17
Default
  #9
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
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.
akidess is offline   Reply With Quote

Reply

Tags
celli, limit, loop, max velocity


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
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


All times are GMT -4. The time now is 05:47.