- **OpenFOAM Community Contributions**
(*https://www.cfd-online.com/Forums/openfoam-community-contributions/*)

- - [swak4Foam] **assign non uniform velocity inflow boundary condition preferably by points?**
(*https://www.cfd-online.com/Forums/openfoam-community-contributions/108671-assign-non-uniform-velocity-inflow-boundary-condition-preferably-points.html*)

assign non uniform velocity inflow boundary condition preferably by points?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 |

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 |

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().x-1.5,2) + pow(pos().y-1.5,2) < pow(3,2)"` Code:
`20*pow(pos().z/40,0.2)` Michiel |

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)*(maxY-pos().y) : vector(0,0,0)"; } { target value; patchName rightWall; variables "maxY=max(pts().y);"; expression "vector(0,1,0)*(maxY-pos().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 |

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.9-12" :"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 |

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 |

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 |

groovybcHi 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,, |

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:
`/*---------------------------------------------------------------------------*\` Code:
`//*--------------------------------*- C++ -*----------------------------------*\` 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 |

Hi Minisasi, I am currently facing the identical problem as you didQuote:
I wonder if you have already figured out the way to solve this error? I've just seen your post which is the same as I did. If you have any futher update, please let me know. Looking forward to communicate with you! Best, Antelope |

Hi,
As I mentioned above, my problem was related to the installation of swak4foam. So check it out. this ( https://openfoamwiki.net/index.php/Installation/swak4Foam/Downloading ) is the link from which I download, and this ( https://openfoamwiki.net/index.php/Installation/swak4Foam ) the one from which I check my installation. Try to have a look at that. When you are done check also the way you are writing your equation in the funkySetBoundaryDict. Some times it is just a matter of very silly mistakes you cannot even think about! Good luck |

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