# parabolic inlet velocity condition

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

 March 26, 2012, 15:19 parabolic inlet velocity condition #1 New Member   solOF Join Date: Mar 2012 Posts: 26 Rep Power: 7 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 solefire likes this.

March 26, 2012, 16:18
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by ofslcm 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)

 March 27, 2012, 04:35 #3 New Member   solOF Join Date: Mar 2012 Posts: 26 Rep Power: 7 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!

March 27, 2012, 14:45
#4
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by ofslcm 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

 March 27, 2012, 19:10 #5 New Member   solOF Join Date: Mar 2012 Posts: 26 Rep Power: 7 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

March 27, 2012, 19:34
#6
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by ofslcm 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

 April 7, 2012, 10:40 #7 New Member   solOF Join Date: Mar 2012 Posts: 26 Rep Power: 7 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. 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

April 9, 2012, 17:39
#8
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by ofslcm 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 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)

 April 11, 2012, 12:16 #9 New Member   solOF Join Date: Mar 2012 Posts: 26 Rep Power: 7 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 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? 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

April 11, 2012, 15:42
#10
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by ofslcm 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 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 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

 February 4, 2014, 13:51 Parser Error for driver PatchValueExpressionDriver at "1.85" :"syntax error, unexpect #11 Member   Thamali Join Date: Jul 2013 Posts: 63 Rep Power: 6 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. Thanks in advance. Thamali

February 4, 2014, 19:39
#12
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
Quote:
 Originally Posted by Thamali 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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 February 5, 2014, 01:30 #13 Member   Thamali Join Date: Jul 2013 Posts: 63 Rep Power: 6 oh sorry,I did not mean to. I will tag next time. And thank you very much for the reply. Thamali

 Tags boundary conditions, parabolic inlet, parabolic velocity

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Zaqie Fluent UDF and Scheme Programming 9 June 25, 2016 19:08 Lcw FLUENT 3 August 3, 2012 05:53 ZHANG Xian-Ming Main CFD Forum 0 October 18, 2006 21:06 Faruk Beyca FLUENT 3 November 28, 2005 15:25 Jongdae Kim FLUENT 0 June 15, 2004 11:21

All times are GMT -4. The time now is 06:54.