|
[Sponsors] |
How to add random perturbation for velocity in Openfoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 21, 2017, 05:29 |
How to add random perturbation for velocity in Openfoam
|
#1 |
Member
Maria
Join Date: Jul 2013
Posts: 84
Rep Power: 13 |
Hi dear all,
I have a model in which the inlet velocity is in x direction, while random perturbations in Y direction is needed. What kind of boundary condition or functions should I use, and how? Thanks in advance! Maria |
|
June 22, 2017, 04:14 |
|
#2 |
Senior Member
|
Hi Maria,
I think you should look at either groovyBC (from swak4Foam) or turbulentInlet. I guess the latter would do just fine. Please note that there may be some pressure fluctuations introduced and when the fluctuations are too large you may get problems with convergence.. Regards, Tom |
|
June 22, 2017, 04:24 |
|
#3 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Maria and Tom,
I think Tom's idea is one of the easiest and simplest. For competence, you also could use a codedFixedBC, in which you define your x-value as a constant and the y-value could be build randomly using the Random class of OpenFOAM. However, using groovyBC should be more easier (depend on the point of view and your programming knowledge). I just wanted to mention this way too. Cheers.
__________________
Keep foaming, Tobias Holzmann |
|
June 22, 2017, 06:18 |
|
#4 |
Member
Maria
Join Date: Jul 2013
Posts: 84
Rep Power: 13 |
Thanks, Tom and Tobias,
I tried to use groovyBC, but I dont know which random function I should use. I tried random(), but it seems Openfoam does not recognize it. Also, for turbulentInlet or codedFixedBC, should I install more subroutines? Best, Maria |
|
June 22, 2017, 06:34 |
|
#5 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi,
the random functionality within groovy is a function of groovy. So it should do the work. Right now I cannot test it - so I am sorry. The codedFixedBC is named codedFixedValue in OpenFOAM and is an boundary condition which already exists. In the header file (finiteVolume/fields/fvPatchFields/derived/codedFixedValue/) you will find an example of how to use it. Out of the box an example which I did not tried but should give you some hints: Code:
myPatch { type codedFixedValue; value uniform (0 0 0); name myOwnBC; code #{ const Random randObj(time(NULL)); const scalar Uy = randObj.scalar01()*10; const vector U = vector(1,Uy,0); operator==(U); #}; } However, based on the fact that I am using the Random function too, I guess it is not the best idea using that code above because the initialization of the RandomObj is slow because we build some X vector etc. (http://pubs.opengroup.org/onlinepubs...h/drand48.html). I think groovy is much faster here but I wanted to show you how to make it with the codedFixedValue boundary condition. GroovyBC Code:
type groovyBC; variables "Uy=random(); Ux=10;"; valueExpression "vector(Ux,Uy,0)"; value uniform (Ux 0 0);
__________________
Keep foaming, Tobias Holzmann |
|
June 22, 2017, 06:39 |
|
#6 | |
Member
Maria
Join Date: Jul 2013
Posts: 84
Rep Power: 13 |
Quote:
Also, the codedFixedValue BC in your reply doesn not work in my case. Should I add some libs? |
||
June 22, 2017, 06:53 |
|
#7 |
Senior Member
|
Hi,
Just to complete the options, the turbulentInlet option would be like this (version 4.x). No additional libraries are needed. Code:
inlet { type turbulentInlet; referenceField uniform (10 0 0); fluctuationScale (0 0.01 0); value uniform (10 0 0); } The source code tells us that Code:
fluctuationScale is RMS fluctuation scale (fraction of mean) Tom |
|
June 22, 2017, 07:00 |
|
#8 | |
Member
Maria
Join Date: Jul 2013
Posts: 84
Rep Power: 13 |
Quote:
|
||
December 4, 2019, 07:40 |
|
#9 | |
Member
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 16 |
Quote:
|
||
April 3, 2023, 05:48 |
|
#10 | |
New Member
Stefan Zitz
Join Date: Dec 2022
Location: Denmark
Posts: 2
Rep Power: 0 |
Quote:
Code:
myPatch { type codedFixedValue; value uniform (0 0 0); name myOwnBC; code #{ const Random randObj(1234); const scalar Uy = randObj.sample01<scalar>()*10; const vector U = vector(1,Uy,0); operator==(U); #}; codeInclude #{ #include "Random.H" #}; } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin | CFDFoundation | OpenFOAM Announcements from Other Sources | 0 | January 4, 2017 07:15 |
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 5, 2016 04:18 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
OpenFOAM Debian packaging current status problems and TODOs | oseen | OpenFOAM Installation | 9 | August 26, 2007 14:50 |
Adding jpeg picture file in OpenFoam post in add a message window | kumar2 | OpenFOAM | 1 | March 22, 2006 23:17 |