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

How to limit the maximal velocities

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 21, 2015, 14:46
Default How to limit the maximal velocities
  #1
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
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 21, 2015, 23:13
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 320
Rep Power: 10
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, 20:32
Default
  #3
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
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, 20:35
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 320
Rep Power: 10
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, 10:03
Default
  #5
New Member
 
Matej Muller
Join Date: Oct 2011
Location: Slovenia
Posts: 22
Rep Power: 7
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, 15:04
Default
  #6
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 320
Rep Power: 10
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: 22
Rep Power: 7
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, 14:20
Default
  #8
New Member
 
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 19
Rep Power: 9
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

Reply

Tags
celli, limit, loop, max velocity

Thread Tools
Display Modes

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 On
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 01:54
converting velocities from cell centers to corner torsy87 OpenFOAM Paraview & paraFoam 1 April 14, 2013 08:09
Image size limit Far Site Help, Feedback & Discussions 0 January 13, 2013 11:45
How do I increase Newton Pressure Iteration Limit when used with CFX-RIF? alpha754293 CFX 1 November 28, 2012 09:28
The limit of mu_t/mu or mu_t when implementing turbulence model xl2000 Main CFD Forum 0 April 27, 2012 11:50


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