
[Sponsors] 
October 30, 2012, 03:36 
swak4foam capabilities

#1 
New Member
Join Date: Apr 2011
Posts: 28
Rep Power: 6 
Hi all,
I'm looking for a way to assign non uniform velocity inflow boundary condition preferably by points rather than using algebraic expression. Can anyone tell me if swak4foam is able to do it? Thanks all for your support. Regards, Andrea 

November 5, 2012, 13:44 

#2 
New Member
Join Date: Apr 2011
Posts: 28
Rep Power: 6 
Hi all,
waiting for some replies, in the meantime I've taken a quite deep look to swak4foam. It's clear that it could be used to assign velocity profile manipulating scalar expressions. But it's still not completely clear to me how to solve my problem...I try to explain better the issue: I need to assign non uniform velocity inlet, with (Ux, Uy, Uz) varying along vertical axis in agreement with a law defined by pow, sin, cos, sqrt. Since the velocity profile is varying along vertical axis some operators (pow, sqrt) should work for vector. As example, part of the formula is: A = 20 * ( z/40 )^0.2 where z is a vector of coordinates in vertical direction. So in my mind the problem is the pow() operators, that should work for the vector z. Any suggests to implement such a condition are welcome. Thanks in advance. Best regards, Andrea 

November 6, 2012, 04:09 

#3 
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 6 
Hi pepe,
If you take a look here: http://openfoamwiki.net/index.php/Co...ression_syntax You can see that the power is only defined for scalars. However, if I'm not mistaken (someone please correct me if I am wrong), pos().z etc are not vectors but rather lists of scalars. This explains why this example on the same site is apparently supposed to work: Code:
funkySetFields field gamma expression 0 time 0 keepPatches condition "pow(pos().x1.5,2) + pow(pos().y1.5,2) < pow(3,2)" Code:
20*pow(pos().z/40,0.2) Michiel 

November 6, 2012, 05:39 

#4  
New Member
Join Date: Apr 2011
Posts: 28
Rep Power: 6 
Quote:
thank you very much for your reply. Maybe you have focused the issue. I need to assign boundary condition, so I think I should use funkySetBoundaryFields instead of funkySetFields. It's not completely clear to me the usage of funkySetBoundaryFields, also looking on the example swak4Foam/Examples/FunkySetBoundaryFields/funkySetBoundaryDict.dambreak . Here is the content of the example: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // velocities { field U; expressions ( { target value; patchName leftWall; variables "maxY=max(pts().y);thres=0.25*maxY;"; expression "(pos().y<thres) ? vector(1,0,0)*(maxYpos().y) : vector(0,0,0)"; } { target value; patchName rightWall; variables "maxY=max(pts().y);"; expression "vector(0,1,0)*(maxYpos().y+p_rgh)"; } ); } dropIn { field alpha1; expressions ( { target inletValue; patchName atmosphere; variables "maxX=max(pts().x);thres1=0.4*maxX;thres2=0.6*maxX ;"; expression "(pos().x>thres1 && pos().x<thres2) ? 1 : 0"; } ); } // ************************************************** *********************** // Do I have to add these lines at the end of my controlDict?? How do I have to modifiy also the 0/U file? In general I have no idea about how to use funkySetBoundaryFields. If you have any experience about its usage it could be great if you'll post a simple but complete working example! Thanks in advance! Yours sincerely, Andrea 

November 6, 2012, 10:10 

#5 
New Member
Join Date: Apr 2011
Posts: 28
Rep Power: 6 
Hi all,
I keep working on non uniform condition with swak4Foam and I'm quite close to solution. I am now using funkySetFields to initialize boundaries and internal field to a desired velocity profile. This is my funkySetFieldsDict: FoamFile { version 2.0; format ascii; class dictionary; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // expressions ( velocities { field U; // this with pos() is working: // expression "pos().z<75.0 && pos().z>=0.0 ? vector(1.0,0.0,0.0)*(10.288*pow(pos().z/40.0,0.1)) : vector(10.955472,0.0,0.0)"; // this with pst() in not working expression "pts().z<75.0 && pts().z>=0.0 ? vector(1.0,0.0,0.0)*(10.288*pow(pts().z/40.0,0.1)) : vector(10.955472,0.0,0.0)"; keepPatches 0; } ); The following error is reported: Create time Create mesh for time = 0 Time = 0 Using funkySetFieldsDict Part: velocities Modifying field U of type volVectorField Putting "pts().z<75.0 && pts().z>=0.0 ? vector(1.0,0.0,0.0)*(10.288*pow(pts().z/40.0,0.1)) : vector(10.955472,0.0,0.0)" into field U at t = "0" if condition "true" is true > FOAM FATAL ERROR: Parser Error for driver FieldValueExpressionDriver at "1.912" :"syntax error, unexpected number" "pts().z<75.0 && pts().z>=0.0 ? vector(1.0,0.0,0.0)*(10.288*pow(pts().z/40.0,0.1)) : vector(10.955472,0.0,0.0)" ^^^^  Context of the error:  Driver constructed from scratch Evaluating expression "pts().z<75.0 && pts().z>=0.0 ? vector(1.0,0.0,0.0)*(10.288*pow(pts().z/40.0,0.1)) : vector(10.955472,0.0,0.0)" From function parsingValue in file lnInclude/CommonValueExpressionDriverI.H at line 876. FOAM exiting The issue is that I need to use vertices ( pts().z ) at z=0 instead of the cell centres ( defined by pos().z ) which have not zero as vertical coordinate (first cell centre is at z=2.5 in my system). The final aim is having value expression zero at coordinate z=0, and so the desired velocity profile. Hope the brief explanation could be clear and someone can help me to close the issue. Thanks again, Andrea 

November 14, 2012, 18:22 

#6  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:
Anyway: problem here is that 75 evaluates to a volumeField (or a patchValue if you're doing a boundary condition) and you're comparing it to a pointField. To make 75 a pointField use "interpolateToPoint(75)" ("toPoint(75)" in groovyBC and funkySetBoundaryFields). To get point values back to the cells use interpolateToCell (toFace if you're working on the patch) Some examples use toPoint/toFace so check there: rule of thumb is swak does not automatically transform your data between cells/points/faces it wants you to say so
__________________
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 

March 27, 2015, 12:03 

#7  
New Member
Join Date: Jul 2014
Posts: 3
Rep Power: 3 
Quote:
Did you get how to solve this problem? I am facing the same. Could you help me? sorry for the silly question. I have just started to use these utilities and from their descriptions they look so powerful... I'd like to use them. Thanx for your time 

March 27, 2015, 20:21 
groovybc

#8 
New Member
Join Date: Oct 2013
Posts: 2
Rep Power: 0 
Hi guys,,
I am trying to change inlet velocity based on certain properties calculation (like temperature at certain location ) using groovybc but it is not working fine can somebody help me with this please inlet { type groovyBC; valueExpression "(Tave<299)? vector(0,0,0):vector(0,0,0.3)"; variables "Tave@location=average(T);"; value uniform(0 0 0.3); } and I got this error field Tave not existing or of wrong type Best,, 

March 29, 2015, 12:18 

#9 
New Member
Join Date: Jul 2014
Posts: 3
Rep Power: 3 
Sorry for bothering.
I solved my problem. (Didn't install correctly my swak4Foam, and didn't have the right expression.) Forget my posts (I didn't know how to delete them.) Thanks Code:
/**\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.3.0   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ Build : 2.3.0f5222ca19ce6 Exec : funkySetBoundaryField time 0 Date : Mar 29 2015 Time : 12:13:28 Host : "giuli_work" PID : 4575 Case : /home/giuli/OpenFOAM/giuli2.3.0/run/a008_pisoEC/case_SBF nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring runtime modified files using timeStampMaster allowSystemOperations : Disallowing usersupplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // swakVersion: 0.3.1 (Release date: 20140711) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time > FOAM Warning : From function dlOpen(const fileName&, const bool) in file POSIX.C at line 1179 dlopen error : libswak4FoamParsers: cannot open shared object file: No such file or directory > FOAM Warning : From function dlLibraryTable::open(const fileName&, const bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99 could not load "libswak4FoamParsers" Create mesh for time = 0 > FOAM FATAL IO ERROR: "ill defined primitiveEntry starting at keyword 'expressions' on line 21 and ending at line 82" file: /home/giuli/OpenFOAM/giuli2.3.0/run/a008_pisoEC/case_SBF/system/funkySetBoundaryDict at line 82. From function primitiveEntry::readEntry(const dictionary&, Istream&) in file lnInclude/IOerror.C at line 132. FOAM exiting giuli@giuli_work:~/.../a008_pisoEC/case_SBF$ Code:
//** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.3.0   \\ / A nd  Web: www.OpenFOAM.com   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object funkySetBoundaryDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // velocities { field U; expressions ( { target value; patchName inlet; variables( "Umax=0.001;" "yCoord=pos().y;" "yCoordMax=max(yCoord);" ); expression "yCoord/yCoordMax * Umax* vector(1,0,0)"; ); } I created my funkySetBoundaryDict where I a imposing a velocity profile at the inlet. The one above is the error I get. Any ideas about what I've done wrongly? Sorry for taking your time... Thx for your helps! Cheers Last edited by Minisasi; March 29, 2015 at 13:33. 

Tags 
boundary condition, inlet, non uniform, swak4foam 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
swak4foam  newbie29  OpenFOAM Installation  82  July 18, 2015 17:16 
groovyBC and funkySetFields married and got a kid named swak4Foam  gschaider  OpenFOAM  164  January 13, 2015 03:52 
swak4foam  callahance  OpenFOAM  28  August 4, 2013 11:40 
swak4Foam for faceZones  andrea.pasquali  OpenFOAM  3  August 30, 2011 11:24 
Water mist modelling capabilities of any software.  Iqbal  Main CFD Forum  4  January 17, 2011 02:15 