CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] log velocity profile with groovyBC - syntax (https://www.cfd-online.com/Forums/openfoam-community-contributions/85895-log-velocity-profile-groovybc-syntax.html)

grjmell March 9, 2011 05:36

log velocity profile with groovyBC - syntax
 
Hi,
I'm trying to implement a logarithmic velocity profile using groovy BC. I've used this code:

Code:

    inlet
    {
        type            groovyBC;
        variables            "u_f=0.05;ks=0.0132;z0=ks/30;K=0.41;vel=2.303*(u_f/K)*log(pos().z/z0)*normal();";
        valueExpression "vector(vel,0,0)";
    }

When I run it with pimpleFoam, I get the following error:


Code:

--> FOAM FATAL ERROR:
 Parser Error at "1.11" :"syntax error, unexpected ','"
"vector(vel,0,0)"
"              ^    "

    From function parsingValue
    in file PatchValueExpressionDriver.C at line 192.

FOAM exiting


Can someone advise on what is wrong with the syntax?

Thanks.

Bernhard March 9, 2011 06:48

In the expression for vel you have '*normal()', which means that vel is a vector. You can just put "vel" in het valueexpression as far as I know.

grjmell March 18, 2011 04:19

In case anyone is looking for this information... This works, to put a Karman-Prandtl velocity profile on your inlet:

Code:

    inlet
    {
        type            groovyBC;
        variables            "u_f=0.0239;z0=0.0000333;K=0.41;vel=(u_f/K)*log(pos().z/z0)*normal();";
        valueExpression "-vel";
    }

Greg

Mojtaba.a March 11, 2013 14:53

Hi guys,
I am having some troubles creating my own velocity profile.
This is what I use as boundary condition:

Quote:

type groovyBC;
variables "yp=pts().y;ph=(yp-2.712)/3.22;arctanph=ph-0.33*pow(ph,3)+0.2*pow(ph,5)-0.1428*pow(ph,7);vel=(arctanph+0.7)/0.19;";
valueExpression "vector(vel,0,0)";
// value uniform (25 0 0);
And here is what I get when i run the case:

Quote:

--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.5-9" :"syntax error, unexpected value"
"(yp-2.712)/3.22"
^^^^^
------|

Context of the error:


- From dictionary: /home/onixa/OpenFOAM/onixa-2.1.1/run/sehatSanj/0/U::boundaryField::velocity_inlet.2
Evaluating expression "(yp-2.712)/3.22"


From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 1028.

FOAM exiting



gschaider March 11, 2013 17:16

Quote:

Originally Posted by Mojtaba.a (Post 413208)
Hi guys,
I am having some troubles creating my own velocity profile.
This is what I use as boundary condition:

And here is what I get when i run the case:

yp is defined on the vertices. Constants are defined on the face centers. Something like "toPoint(2.712)" would fix that. There are examples for that in .... the Examples

Mojtaba.a March 12, 2013 03:04

Quote:

Originally Posted by gschaider (Post 413251)
yp is defined on the vertices. Constants are defined on the face centers. Something like "toPoint(2.712)" would fix that. There are examples for that in .... the Examples

Thank you Gschaider,
I think I understand the problem. So I did something like this:

Quote:

variables "yp=pts().y;ph=(yp-toPoint(2.712))/toPoint(3.22);arctanph=ph-toPoint(0.33)*pow(ph,3)+toPoint(0.2)*pow(ph,5)-toPoint(0.1428)*pow(ph,7);vel=((arctanph+toPoint(0 .7))/toPoint(0.19);";
valueExpression "vector(vel,0,0)";
and I got this error for valueExpression:

Quote:

--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.12" :"syntax error, unexpected value"
"vector(vel,0,0)"

What am I doing wrong? Is it again something about vertices and face centers?
Thank you so much for you help.

gschaider March 12, 2013 10:26

Quote:

Originally Posted by Mojtaba.a (Post 413323)
Thank you Gschaider,
I think I understand the problem. So I did something like this:



and I got this error for valueExpression:




What am I doing wrong? Is it again something about vertices and face centers?
Thank you so much for you help.

Same problem in reverse: vel is a value defined on the points but valueExpression needs it on the faces. A well-set "toFace" should fix that

Mojtaba.a March 12, 2013 13:42

Quote:

Originally Posted by gschaider (Post 413472)
Same problem in reverse: vel is a value defined on the points but valueExpression needs it on the faces. A well-set "toFace" should fix that

Yes it fixed the problem, Thank you Gschaider.
Now I have some convergency problems. I will play with it a little bit, maybe I can make it work.

gschaider March 12, 2013 13:47

Quote:

Originally Posted by Mojtaba.a (Post 413519)
Yes it fixed the problem, Thank you Gschaider.
Now I have some convergency problems. I will play with it a little bit, maybe I can make it work.

Convergence is not my responsibility. Good luck

LamiaOF2.1 April 15, 2013 09:32

Hi Bernhard
first I would thank you for all your help
well, I have a velocity profile on my inlet as condition, I used groovy Bc and it works perfectly, but in the experimental the maximum velocity

should'nt exceed 5 m/s, how can I respect it and add the value of U max = 5 m/s if I am using the following:

inlet { type groovyBC; variables "u_f=0.43;y0=0.0007;y=0.78;c=5.75;K=0.41;vel=( u_f/K)*log(((pos().y+y0)/y0)+c)*normal();"; valueExpression "-vel"; }would you please help me
with best regards
another thing, I asked you for a tutorial about the groovy bc, can you send me a link of your workshop or of any documentation concerning groovy bc, I need it so much to learn more about it.

gschaider April 15, 2013 13:53

Quote:

Originally Posted by LamiaOF2.1 (Post 420663)
Hi Bernhard
first I would thank you for all your help
well, I have a velocity profile on my inlet as condition, I used groovy Bc and it works perfectly, but in the experimental the maximum velocity

should'nt exceed 5 m/s, how can I respect it and add the value of U max = 5 m/s if I am using the following:

inlet { type groovyBC; variables "u_f=0.43;y0=0.0007;y=0.78;c=5.75;K=0.41;vel=( u_f/K)*log(((pos().y+y0)/y0)+c)*normal();"; valueExpression "-vel"; }would you please help me
with best regards
another thing, I asked you for a tutorial about the groovy bc, can you send me a link of your workshop or of any documentation concerning groovy bc, I need it so much to learn more about it.

Something like
Code:

vel=min((u_f/K)*log(((pos().y+y0)/y0)+c),5)*normal();
should limit it (min(a,b) returns the minimum of a and b)

All available documentation is linked from the swak-page on the Wiki

LamiaOF2.1 April 16, 2013 10:16

thank's
I'll see if it gonna works

LamiaOF2.1 April 28, 2013 10:30

OpenFoam
 
Hi
from tecPlot I've got the equation of my experimental velocity profile , I need to program it with groovy BC, I tried many codes but it dose'nt work with me
this is the equation from tecplot

Y = e^(A*log(X) + B),

A = 3.31453803168746710000E+000
B = -5.62522091753798930000E+000
X= 5 m/s

where Y means velocity
can anyone help me
I need to have the same profile than my experimental case to generate my modelisation with OpenFoam

best regards

gschaider April 28, 2013 17:21

Quote:

Originally Posted by LamiaOF2.1 (Post 423649)
Hi
from tecPlot I've got the equation of my experimental velocity profile , I need to program it with groovy BC, I tried many codes but it dose'nt work with me
this is the equation from tecplot

Y = e^(A*log(X) + B),

A = 3.31453803168746710000E+000
B = -5.62522091753798930000E+000
X= 5 m/s

where Y means velocity
can anyone help me
I need to have the same profile than my experimental case to generate my modelisation with OpenFoam

best regards

What have you tried and what doesn't work? Be a bit more specific. The expression should look like this: "exp(3.31453803168746*log(5)-5.62522091753)" (more elegant if you use variables)

LamiaOF2.1 April 29, 2013 11:45

so is that correct?
inlet
{
type groovyBC;
variables "vel=exp(3.31453803168746*log(5)-5.62522091753)*normal();";
valueExpression "vel";

}
thank's a lot

gschaider April 29, 2013 14:07

Quote:

Originally Posted by LamiaOF2.1 (Post 423940)
so is that correct?
inlet
{
type groovyBC;
variables "vel=exp(3.31453803168746*log(5)-5.62522091753)*normal();";
valueExpression "vel";

}
thank's a lot

Well Yeah. But with "elegant" I meant

Code:

inlet
    {
        type            groovyBC;
        variables  (
              "A=3.31453803168746;"
              "X=5;"
              "B=-5.62522091753;"
      );
        valueExpression "exp(A*log(X) + B)*normal()";
    }

BTW: that is a constant velocity for the whole patch ... which stretches the definition of "profile"

LamiaOF2.1 May 12, 2013 11:30

I need help
 
In OpenFoam I need to enter a tabular data to program my velocity profile
is it possible to do it with groovy bc
here is the data of both altitude and velocity values
please help me for I can pass to the next level of my work
y (altitude)[m], U Velocity [m s^-1]
0.87500, 4.15580
0.85000, 4.15580
0.80000, 4.15580
0.75000, 4.15580
0.70000, 4.15580
0.65000, 4.15580
0.60000, 4.15580
0.55000, 4.15580
0.50000, 4.15580
0.45000, 4.15580
0.40187, 4.15580
0.39866, 4.15580
0.39548, 4.15580
0.39231, 4.15580
0.38916, 4.15580
0.38603, 4.15580
0.38291, 4.15580
0.37980, 4.15580
0.37673, 4.15580
0.37367, 4.05580
0.37063, 4.04580
0.36760, 4.03580
0.36459, 4.02580
0.36160, 4.01580
0.35862, 4.00580
0.35566, 3.99580
0.35272, 3.98580
0.34979, 3.97580
0.34689, 3.96580
0.34400, 3.95580
0.34112, 3.94580
0.33827, 3.93580
0.33542, 3.92580
0.33260, 3.91580
0.32979, 3.90580
0.32700, 3.89580
0.32423, 3.88580
0.32147, 3.87580
0.31873, 3.86580
0.31601, 3.85580
0.31330, 3.84580
0.31061, 3.83580
0.30793, 3.82580
0.30527, 3.81580
0.30263, 3.80580
0.30000, 3.79580
0.29739, 3.78580
0.29479, 3.77580
0.29221, 3.76580
0.28965, 3.75580
0.28710, 3.74580
0.28457, 3.73580
0.28205, 3.72580
0.27955, 3.71580
0.27706, 3.70580
0.27459, 3.69580
0.27214, 3.68580
0.26970, 3.67580
0.26727, 3.66580
0.26486, 3.65580
0.26247, 3.64580
0.26009, 3.63580
0.25773, 3.62580
0.25538, 3.61580
0.25305, 3.60580
0.25073, 3.59580
0.24842, 3.58580
0.24614, 3.57580
0.24386, 3.56580
0.24160, 3.55580
0.23936, 3.54580
0.23713, 3.53580
0.23491, 3.52580
0.23271, 3.51580
0.23052, 3.50580
0.22835, 3.49580
0.22619, 3.48580
0.22405, 3.47580
0.22192, 3.46580
0.21980, 3.45580
0.21770, 3.44580
0.21562, 3.43580
0.21354, 3.42580
0.21148, 3.41580
0.20944, 3.40580
0.20741, 3.39580
0.20539, 3.38580
0.20339, 3.37580
0.20140, 3.36580
0.19942, 3.35580
0.19746, 3.34580
0.19551, 3.33580
0.19357, 3.32580
0.19165, 3.31580
0.18974, 3.30580
0.18784, 3.29580
0.18596, 3.28580
0.18409, 3.27580
0.18224, 3.26580
0.18039, 3.25580
0.17856, 3.24580
0.17675, 3.23580
0.17494, 3.22580
0.17315, 3.21580
0.17137, 3.20580
0.16961, 3.19580
0.16786, 3.18580
0.16612, 3.17580
0.16439, 3.16580
0.16267, 3.15580
0.16097, 3.14580
0.15928, 3.13580
0.15760, 3.12580
0.15594, 3.11580
0.15429, 3.10580
0.15265, 3.09580
0.15102, 3.08580
0.14940, 3.07580
0.14780, 3.06580
0.14621, 3.05580
0.14463, 3.04580
0.14306, 3.03580
0.14150, 3.02580
0.13996, 3.01580
0.13842, 3.00580
0.13690, 2.99580
0.13540, 2.98580
0.13390, 2.97580
0.13241, 2.96580
0.13094, 2.95580
0.12948, 2.94580
0.12803, 2.93580
0.12659, 2.92580
0.12516, 2.91580
0.12374, 2.90580
0.12233, 2.89580
0.12094, 2.88580
0.11956, 2.87580
0.11818, 2.86580
0.11682, 2.85580
0.11547, 2.84580
0.11413, 2.83580
0.11280, 2.82580
0.11149, 2.81580
0.11018, 2.80580
0.10888, 2.79580
0.10760, 2.78580
0.10632, 2.77580
0.10506, 2.76580
0.10380, 2.75580
0.10256, 2.74580
0.10133, 2.73580
0.10011, 2.72580
0.09889, 2.71580
0.09769, 2.70580
0.09650, 2.69580
0.09532, 2.68580
0.09415, 2.67580
0.09299, 2.66580
0.09184, 2.65580
0.09069, 2.64580
0.08956, 2.63580
0.08844, 2.62580
0.08733, 2.61580
0.08623, 2.60580
0.08514, 2.59580
0.08405, 2.58580
0.08298, 2.57580
0.08192, 2.56580
0.08087, 2.55580
0.07982, 2.54580
0.07879, 2.53580
0.07776, 2.52580
0.07675, 2.51580
0.07574, 2.50580
0.07474, 2.49580
0.07375, 2.48580
0.07278, 2.47580
0.07181, 2.46580
0.07084, 2.45580
0.06989, 2.44580
0.06895, 2.43580
0.06802, 2.42580
0.06709, 2.41580
0.06618, 2.40580
0.06527, 2.39580
0.06437, 2.38580
0.06348, 2.37580
0.06260, 2.36580
0.06173, 2.35580
0.06086, 2.34580
0.06001, 2.33580
0.05916, 2.32580
0.05832, 2.31580
0.05749, 2.30580
0.05667, 2.29580
0.05585, 2.28580
0.05505, 2.27580
0.05425, 2.26580
0.05346, 2.25580
0.05268, 2.24580
0.05190, 2.23580
0.05114, 2.22580
0.05038, 2.21580
0.04963, 2.20580
0.04889, 2.19580
0.04816, 2.18580
0.04743, 2.17580
0.04671, 2.16580
0.04600, 2.15580
0.04530, 2.14580
0.04460, 2.13580
0.04391, 2.12580
0.04323, 2.11580
0.04256, 2.10580
0.04189, 2.09580
0.04123, 2.08580
0.04058, 2.07580
0.03994, 2.06580
0.03930, 2.05580
0.03867, 2.04580
0.03805, 2.03580
0.03743, 2.02580
0.03682, 2.01580
0.03620, 2.00580
0.03562, 1.99580
0.03504, 1.98580
0.03445, 1.97580
0.03388, 1.96580
0.03331, 1.95580
0.03275, 1.94580
0.03220, 1.93580
0.03165, 1.92580
0.03111, 1.91580
0.03057, 1.90580
0.03004, 1.89580
0.02952, 1.88580
0.02901, 1.87580
0.02850, 1.86580
0.02799, 1.85580
0.02750, 1.84580
0.02701, 1.83580
0.02652, 1.82580
0.02604, 1.81580
0.02557, 1.80580
0.02510, 1.79580
0.02464, 1.78580
0.02419, 1.77580
0.02374, 1.76580
0.02330, 1.75580
0.02286, 1.74580
0.02243, 1.73580
0.02200, 1.72580
0.02158, 1.71580
0.02117, 1.70580
0.02076, 1.69580
0.02036, 1.68580
0.01996, 1.67580
0.01957, 1.66580
0.01918, 1.65580
0.01880, 1.64580
0.01843, 1.63580
0.01805, 1.62580
0.01769, 1.61580
0.01733, 1.60580
0.01697, 1.59580
0.01662, 1.58580
0.01628, 1.57580
0.01594, 1.56580
0.01560, 1.55580
0.01527, 1.54580
0.01495, 1.53580
0.01463, 1.52580
0.01431, 1.51580
0.01400, 1.50580
0.01370, 1.49580
0.01340, 1.48580
0.01310, 1.47580
0.01281, 1.46580
0.01252, 1.45580
0.01224, 1.44580
0.01196, 1.43580
0.01169, 1.42580
0.01142, 1.41580
0.01115, 1.40580
0.01089, 1.39580
0.01063, 1.38580
0.01038, 1.37580
0.01013, 1.36580
0.00989, 1.35580
0.00965, 1.34580
0.00941, 1.33580
0.00918, 1.32580
0.00895, 1.31580
0.00873, 1.30580
0.00851, 1.29580
0.00830, 1.28580
0.00808, 1.27580
0.00788, 1.26580
0.00767, 1.25580
0.00747, 1.24580
0.00727, 1.23580
0.00708, 1.22580
0.00689, 1.21580
0.00670, 1.20580
0.00652, 1.19580
0.00634, 1.18580
0.00617, 1.17580
0.00600, 1.16580
0.00583, 1.15580
0.00566, 1.14580
0.00550, 1.13580
0.00534, 1.12580
0.00518, 1.11580
0.00503, 1.10580
0.00488, 1.09580
0.00474, 1.08580
0.00459, 1.07580
0.00445, 1.06580
0.00432, 1.05580
0.00418, 1.04580
0.00405, 1.03580
0.00392, 1.02580
0.00380, 1.01580
0.00368, 1.00580
0.00356, 0.99580
0.00344, 0.98580
0.00332, 0.97580
0.00321, 0.96580
0.00310, 0.95580
0.00300, 0.94580
0.00289, 0.93580
0.00279, 0.92580
0.00269, 0.91580
0.00260, 0.90580
0.00250, 0.89580
0.00241, 0.88580
0.00232, 0.87580
0.00224, 0.86580
0.00215, 0.85580
0.00207, 0.84580
0.00199, 0.83580
0.00191, 0.82580
0.00184, 0.81580
0.00176, 0.80580
0.00169, 0.79580
0.00162, 0.78580
0.00155, 0.77580
0.00149, 0.76580
0.00143, 0.75580
0.00136, 0.74580
0.00130, 0.73580
0.00125, 0.72580
0.00119, 0.71580
0.00114, 0.70580
0.00108, 0.69580
0.00103, 0.68580
0.00098, 0.67580
0.00094, 0.66580
0.00089, 0.65580
0.00085, 0.64580
0.00080, 0.63580
0.00076, 0.62580
0.00072, 0.61580
0.00068, 0.60580
0.00065, 0.59580
0.00061, 0.58580
0.00058, 0.57580
0.00055, 0.56580
0.00051, 0.55580
0.00048, 0.54580
0.00046, 0.53580
0.00043, 0.52580
0.00040, 0.51580
0.00038, 0.50580
0.00035, 0.49580
0.00033, 0.48580
0.00033, 0.47580
0.00029, 0.46580
0.00027, 0.45580
0.00025, 0.44580
0.00023, 0.43580
0.00021, 0.42580
0.00020, 0.41580
0.00018, 0.40580
0.00017, 0.39580
0.00015, 0.38580
0.00014, 0.37580
0.00013, 0.36580
0.00012, 0.35580
0.00011, 0.34580
0.00010, 0.33580
0.00009, 0.32580
0.00008, 0.31580
0.00007, 0.30580
0.00006, 0.29580
0.00005, 0.27580
0.00004, 0.25580
0.00003, 0.22580
0.00002, 0.19580
0.00001, 0.14580
0.00000, 0.00000

best regards

gschaider May 12, 2013 17:24

Quote:

Originally Posted by LamiaOF2.1 (Post 427015)
In OpenFoam I need to enter a tabular data to program my velocity profile
is it possible to do it with groovy bc
here is the data of both altitude and velocity values
please help me for I can pass to the next level of my work
y (altitude)[m], U Velocity [m s^-1]
0.87500, 4.15580
0.85000, 4.15580
<snip>
0.00002, 0.19580
0.00001, 0.14580
0.00000, 0.00000

best regards

Yeah. You can either use timelines (for data that depends on time) or lookuptables (for a more general approach. This is what you'll want here). Have a look at the wobbler-case for a usage example.

This builds on OF-routines for such files so available file formats is the OF-specific format or CSV (a short documentation is found in the Documentation-folder of the swak-sources)

LamiaOF2.1 May 14, 2013 09:03

Hi again
for introducing a tabular data, I did that:


boundaryField
{
inlet
{
type groovyBC;

fields
(
U Yn
);

lookuptables (
{
name profile;
outOfBounds clamp;
fileName "$FOAM_CASE/profile.data";
}
valueExpression "profile(U)";
);

}

is that correct??
and should I add something in the other files as the controlDict or another!!

gschaider May 14, 2013 09:53

Quote:

Originally Posted by LamiaOF2.1 (Post 427468)
Hi again
for introducing a tabular data, I did that:

Code:

boundaryField
{
    inlet
    {
        type            groovyBC;
       
        fields
        (
        U Yn
        );

        lookuptables (
        {
        name profile;
        outOfBounds clamp;
        fileName "$FOAM_CASE/profile.data";
    }
        valueExpression "profile(U)";
    );

    }

is that correct??
and should I add something in the other files as the controlDict or another!!

No you don't have to add anything to the controlDict.

I was just going through my own documentation "what does the fields-entry mean". Anyway. Lookups only work for scalars.

This is a boundary condition for U where you want the velocity on the inlet to be a function of the height, right (my interpretation from the dat file you posted). In that case the valueExpression could either be "-normal()*profile(pos().y)" or "vector(profile(pos().y),0,0)" (depends on your case what is more appropriate).

If the format of your data file is like in your posting then you'll want to add to the dictionary of profile the entry "readerType csv;". This will require some additional options which are described in swak4FoamReference.org in the Documentation folder


All times are GMT -4. The time now is 12:28.