CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   parabolic inlet velocity condition (http://www.cfd-online.com/Forums/openfoam-programming-development/99126-parabolic-inlet-velocity-condition.html)

 ofslcm March 26, 2012 15:19

parabolic inlet velocity condition

Hi,

I'm trying to program a parabolic inlet velocity condition with openFOAM-2.0 for a 3D channel. My function is:

U(0,y,z)=U*y*z*(H-y)/H^4

where U=U(0,H/2,H/2,t)

and H is the height of the channel.

I've copied

parabolicVelocityFvPatchVectorField.C
parabolicVelocityFvPatchVectorField.H

on

~/OpenFoam/OF-Org-2.0/OpenFOAM-2.0.0/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/.

and now I'm trying to modify this file, but I don't know how I can get U=U(0,H/2,H/2,t)

Could you help me please? Or could you give me a piece of advice to do it on a different way?

Thank you!

solOF

 gschaider March 26, 2012 16:18

Quote:
 Originally Posted by ofslcm (Post 351579) Hi, I'm trying to program a parabolic inlet velocity condition with openFOAM-2.0 for a 3D channel. My function is: U(0,y,z)=U*y*z*(H-y)/H^4 where U=U(0,H/2,H/2,t) and H is the height of the channel. I've copied parabolicVelocityFvPatchVectorField.C parabolicVelocityFvPatchVectorField.H on ~/OpenFoam/OF-Org-2.0/OpenFOAM-2.0.0/src/finiteVolume/fields/fvPatchFields/derived/parabolicVelocity/. and now I'm trying to modify this file, but I don't know how I can get U=U(0,H/2,H/2,t) Could you help me please? Or could you give me a piece of advice to do it on a different way? Thank you! solOF
Not sure which parabolicVelocityFvPatchVectorField.C/H you're referring to. Maybe the ones discussed in
http://www.cfd-online.com/Forums/ope...ion-1-7-a.html
(which gives you pointers at two alternate approaches)

 ofslcm March 27, 2012 04:35

Thank you for the fast reply!

I'm going to use groovyBC, however I still don't know how I could define the velocity Um of my function:

U(0,y,z)=Um*y*z*(H-y)/H^4

where Um=U(0,H/2,H/2,t)

Thank you!

 gschaider March 27, 2012 14:45

Quote:
 Originally Posted by ofslcm (Post 351674) Thank you for the fast reply! I'm going to use groovyBC, however I still don't know how I could define the velocity Um of my function: U(0,y,z)=Um*y*z*(H-y)/H^4 where Um=U(0,H/2,H/2,t) could you help me, please? Thank you!
I see from http://www.cfd-online.com/Forums/ope...tml#post351786 that you already found that information.

Just one remark: I don't know what you want to acomplish with U@in: if it is to access a remote patch: the syntax has changed in swak4Foam. Also: in your case it is not required: variables are calculated on patch "in" anyway

 ofslcm March 27, 2012 19:10

Hi,

thank you! What I want to do is to take U(0,H/2,H/2) from the "in" patch. I thought that it was a possible way to do that, but I'm not sure... It seems to be wrong, doesn't it?
I think that what you told me is that I should install swak4Foam and then I should implement the function:

U(0,y,z)=Um*y*z*(H-y)*(H-z)/h^4
V=0
W=0

where Um=4*U(0,H/2,H/2,t)

on that way:

in
{
type groovyBC;
variables "yp{in}=pts().y;zp{in}=pts().z;minZ=min(zp);maxZ=m ax(zp);H =(maxZ-minZ)/2;v{in}=4*v(0,H,H);";
valueExpression "vector(v*yp*zp*(H-yp)*(H-zp)/pow(H,4),0,0)";
}

Am I wrong?

Thank you very much

 gschaider March 27, 2012 19:34

Quote:
 Originally Posted by ofslcm (Post 351823) Hi, thank you! What I want to do is to take U(0,H/2,H/2) from the "in" patch. I thought that it was a possible way to do that, but I'm not sure... It seems to be wrong, doesn't it? I think that what you told me is that I should install swak4Foam and then I should implement the function: U(0,y,z)=Um*y*z*(H-y)*(H-z)/h^4 V=0 W=0 where Um=4*U(0,H/2,H/2,t) on that way: in { type groovyBC; variables "yp{in}=pts().y;zp{in}=pts().z;minZ=min(zp);maxZ=m ax(zp);H =(maxZ-minZ)/2;v{in}=4*v(0,H,H);"; valueExpression "vector(v*yp*zp*(H-yp)*(H-zp)/pow(H,4),0,0)"; } Am I wrong? Thank you very much
You can skip the {in} with variables. You're on the patch and variables therefor "live" there anyway

 ofslcm April 7, 2012 10:40

Finally groovyBC is working. I have changed the extension ".so" by ".dylib" and now OpenFoam is able to find the library.

Now I have a different problem. I have program the boundary conditions on that way:

in
{
type groovyBC;
variables "yp=pts().y;zp=pts().z;minZ=min(zp);maxZ=max(zp);m inY=min(yp);maxY=max(yp);Hz=(maxZ-minZ)/2;Hy=(maxY-minY)/2;v=4*U(0,Hy,Hz)/9;";
valueExpression "vector(16*v*yp*zp*(Hy-yp)*(Hz-zp)/pow(H,4),0,0)";
}

I want to extract the velocity in (0,Hy,Hz), but it seems that I have a syntax error and I get:

--> FOAM FATAL ERROR:
Parser Error at "1.3" :"syntax error, unexpected '(', expecting \$end"
"4*U(0,Hy,Hz)/9"
" ^ "

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

FOAM exiting

How can I extract the velocity in that point?

Thank you

Ofslcm

 gschaider April 9, 2012 17:39

Quote:
 Originally Posted by ofslcm (Post 353598) Thank you for your help, Finally groovyBC is working. I have changed the extension ".so" by ".dylib" and now OpenFoam is able to find the library.
Do I get this right: you're on a Mac and to get it to work you have to replace .so with .dylib? Which patches/version are you using on the Mac. Because the patches I published for the Mac do this on the fly (they find .so in the library name and replace it) otherwise I would get crazy switching my cases from Mac to Linux ... and back

Quote:
 Originally Posted by ofslcm (Post 353598) Now I have a different problem. I have program the boundary conditions on that way: in { type groovyBC; variables "yp=pts().y;zp=pts().z;minZ=min(zp);maxZ=max(zp);m inY=min(yp);maxY=max(yp);Hz=(maxZ-minZ)/2;Hy=(maxY-minY)/2;v=4*U(0,Hy,Hz)/9;"; valueExpression "vector(16*v*yp*zp*(Hy-yp)*(Hz-zp)/pow(H,4),0,0)"; } I want to extract the velocity in (0,Hy,Hz), but it seems that I have a syntax error and I get: --> FOAM FATAL ERROR: Parser Error at "1.3" :"syntax error, unexpected '(', expecting \$end" "4*U(0,Hy,Hz)/9" " ^ " From function parsingValue in file PatchValueExpressionDriver.C at line 192. FOAM exiting How can I extract the velocity in that point? Thank you Ofslcm
The syntax of the expressions does not support getting the value of a function on a location. But there is a workaround

But first: you're sure you want to make the BC depend on the current solution? I just ask because there are all kinds of ways that this kind of feedback can make your simulation instable

The workaround would be to define a sampled set at the location in question (for instance named probe). Then you can use it in the variables as "v{set'probe}=4*U/9;" (U is the value at the probe location). The only downside is that the location of the probe currently can't be calculated (for details on using that see either the fillingTheDam case in the swak-Examples or the presentation from last years workshop)

 ofslcm April 11, 2012 12:16

Hi,

the version that I'm using of OpenFOAM is 2.0. But I don't know why it doesn't recognize the extension ".so".

Thank you for your answer. I've been having a look to the fillingTheDam example. As you told me, I can program it to get U(0,H,H) doing this:

in
{
type groovyBC;
value uniform(0,0,0);
valueExpression "((pos().y==(max(pos().y)+min(pos().y)/2) && pos().z==(max(pos().z)+min(pos().z)/2)) ? -normal() : vector(0,0,0))";
storedVariables(
{
name probe;
initialValue "0";
}
);
variables(
"v{set'probe}=4*U/9;"
);
}

However, I get the following error:

--> FOAM Warning :
From function entry::getKeyword(keyType&, Istream&)
in file db/dictionary/entry/entryIO.C at line 77
found on line 58 the punctuation token ')'
expected either } or EOF

--> FOAM FATAL IO ERROR:
ill defined primitiveEntry starting at keyword 'variables(' on line 60 and ending at line 70

file: ./cylinder_00/0/U at line 70.

in file db/dictionary/primitiveEntry/primitiveEntryIO.C at line 165.

FOAM exiting

Why?

On the other hand, I'm interested in defining:

valueExpression "vector(16*v*yp*zp*(Hy-yp)*(Hz-zp)/pow(H,4),0,0)";

Is it possible to define 2 valueExpression? One with the conditional sentence followed by another one with this vector expression?

Thank you

 gschaider April 11, 2012 15:42

Quote:
 Originally Posted by ofslcm (Post 354215) Hi, the version that I'm using of OpenFOAM is 2.0. But I don't know why it doesn't recognize the extension ".so".
But you're on a Mac (that was the reason for the dylib/so-business). Usually you'll have to patch OF to compile on a Mac. Did you do that yourself or did you get it from somewhere else?

Quote:
 Originally Posted by ofslcm (Post 354215) Thank you for your answer. I've been having a look to the fillingTheDam example. As you told me, I can program it to get U(0,H,H) doing this: in { type groovyBC; value uniform(0,0,0); valueExpression "((pos().y==(max(pos().y)+min(pos().y)/2) && pos().z==(max(pos().z)+min(pos().z)/2)) ? -normal() : vector(0,0,0))"; storedVariables( { name probe; initialValue "0"; } ); variables( "v{set'probe}=4*U/9;" ); } However, I get the following error: --> FOAM Warning : From function entry::getKeyword(keyType&, Istream&) in file db/dictionary/entry/entryIO.C at line 77 Reading ./cylinder_00/0/U found on line 58 the punctuation token ')' expected either } or EOF --> FOAM FATAL IO ERROR: ill defined primitiveEntry starting at keyword 'variables(' on line 60 and ending at line 70 file: ./cylinder_00/0/U at line 70. From function primitiveEntry::readEntry(const dictionary&, Istream&) in file db/dictionary/primitiveEntry/primitiveEntryIO.C at line 165. FOAM exiting Why?
Have a look at the error message. OF thinks that variables( is a keyword. A space in the right place might do wonders

A note about the expression: == hardly ever works with floating point. You'd better check that the value is within a (small) range

Quote:
 Originally Posted by ofslcm (Post 354215) On the other hand, I'm interested in defining: valueExpression "vector(16*v*yp*zp*(Hy-yp)*(Hz-zp)/pow(H,4),0,0)"; Is it possible to define 2 valueExpression? One with the conditional sentence followed by another one with this vector expression? Thank you
I don't understand: The boundary condition can only have one value

 Thamali February 4, 2014 13:51

Parser Error for driver PatchValueExpressionDriver at "1.85" :"syntax error, unexpect

Dear all,
I am new to swak4Foam and I am trying to develop a boundary condition to make a fixed temperature using temperature gradient.Real application is to find out the temperature using radiative heat as a heat flux at the boundary.
so
I am trying to implement this boundary condition using the following.

interFace
{

type groovyBC;
#include "commonVariables"

fractionExpression "1";
value uniform 298;

}
&(commonVariables)

variables "sig=5.67e-8;emiss=0.9;Tenv=773;Yvolat=YCOs+YCO2s+YH2s+YCH4s+ YCxHyOzs;epsilon=0.5+0.5*((0.7207-Yvolat)+(0.1457-Ychar)+(0.0426-Yash));";

But Iam getting the following error,which I cannot fix.

swak4Foam: Allocating new repository for sampledGlobalVariables

--> FOAM FATAL ERROR:
Parser Error for driver PatchValueExpressionDriver at "1.85" :"syntax error, unexpected ')', expecting '('"
"sig*emiss*2*(pow(Tenv,4)-pow(ts,4))*pow((epsilon*effectiveThermalConductivi tyS*delta),-1)"
^
--------------------------------------------------------------------------------------|

Context of the error:

- From dictionary: /home/thamali/OpenFOAM/thamali-2.2.2/run/tutorials/combustion/woodchipcombustion/wood_chip_boiler6/0/ts.boundaryField.interFace
Evaluating expression "sig*emiss*2*(pow(Tenv,4)-pow(ts,4))*pow((epsilon*effectiveThermalConductivi tyS*delta),-1)"

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

FOAM exiting

I saw a similar thing in this thread ,so I choosed to write here anticipating for a reply from anyone.

Thamali

 gschaider February 4, 2014 19:39

Quote:
 Originally Posted by Thamali (Post 473395) Dear all, I am new to swak4Foam and I am trying to develop a boundary condition to make a fixed temperature using temperature gradient.Real application is to find out the temperature using radiative heat as a heat flux at the boundary. so lambda*epsilon*grad(ts) =radiative heat(which requires (Tenv^4-Tboundary^4) So both grad and radiative heat requires Tboundary. I am trying to implement this boundary condition using the following. interFace { type groovyBC; #include "commonVariables" gradientExpression "sig*emiss*2*(pow(Tenv,4)-pow(ts,4))*pow((epsilon*effectiveThermalConductivi tyS*delta),-1)" ; fractionExpression "1"; value uniform 298; } &(commonVariables) variables "sig=5.67e-8;emiss=0.9;Tenv=773;Yvolat=YCOs+YCO2s+YH2s+YCH4s+ YCxHyOzs;epsilon=0.5+0.5*((0.7207-Yvolat)+(0.1457-Ychar)+(0.0426-Yash));"; But Iam getting the following error,which I cannot fix. swak4Foam: Allocating new repository for sampledGlobalVariables --> FOAM FATAL ERROR: Parser Error for driver PatchValueExpressionDriver at "1.85" :"syntax error, unexpected ')', expecting '('" "sig*emiss*2*(pow(Tenv,4)-pow(ts,4))*pow((epsilon*effectiveThermalConductivi tyS*delta),-1)" ^ --------------------------------------------------------------------------------------| Context of the error: - From dictionary: /home/thamali/OpenFOAM/thamali-2.2.2/run/tutorials/combustion/woodchipcombustion/wood_chip_boiler6/0/ts.boundaryField.interFace Evaluating expression "sig*emiss*2*(pow(Tenv,4)-pow(ts,4))*pow((epsilon*effectiveThermalConductivi tyS*delta),-1)" From function parsingValue in file lnInclude/CommonValueExpressionDriverI.H at line 1181. FOAM exiting I saw a similar thing in this thread ,so I choosed to write here anticipating for a reply from anyone.

Point 2: please enclose output and code in the CODE-tag (the # above). It makes it much more readable (especially the position indicator of the error)

I guess the problem is the variable delta. The patch-parser has a function delta() (this is a discretization property of the patch) and your variable clashes with that. You'll have to rename the variable

 Thamali February 5, 2014 01:30

oh sorry,I did not mean to.
I will tag next time.
And thank you very much for the reply.

Thamali

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