CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   swak4foam capabilities (http://www.cfd-online.com/Forums/openfoam-solving/108671-swak4foam-capabilities.html)

 pepe.aero October 30, 2012 03:36

swak4foam capabilities

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?

Regards,

Andrea

 pepe.aero November 5, 2012 13:44

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.

Best regards,

Andrea

 michielm November 6, 2012 04:09

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)"`
So for your example I would think something like this could work:
Code:

`20*pow(pos().z/40,0.2)`
Cheers,

Michiel

 pepe.aero November 6, 2012 05:39

Quote:
 Originally Posted by michielm (Post 390491) 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)"` So for your example I would think something like this could work: Code: `20*pow(pos().z/40,0.2)` Cheers, Michiel
Hi Michielm,

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!

Yours sincerely,

Andrea

 pepe.aero November 6, 2012 10:10

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

 gschaider November 14, 2012 18:22

Quote:
 Originally Posted by pepe.aero (Post 390587) 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
Catching up on the MessageBoard-stuff. Not quite sure: you need a boundary condition right? Then for a first try groovyBC would be the easiest.

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

 Minisasi March 27, 2015 12:03

Quote:
 Originally Posted by pepe.aero (Post 390520) Hi Michielm, 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().ythres1 && pos().x
Hello,
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.

 Hashme March 27, 2015 20:21

groovybc

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

 Minisasi March 29, 2015 12:18

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.0-f5222ca19ce6 Exec  : funkySetBoundaryField -time 0 Date  : Mar 29 2015 Time  : 12:13:28 Host  : "giuli_work" PID    : 4575 Case  : /home/giuli/OpenFOAM/giuli-2.3.0/run/a008_pisoEC/case_SBF nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Disallowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // swakVersion: 0.3.1 (Release date: 2014-07-11) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 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/giuli-2.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\$```
And this is my dictionary file
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)";     ); }```
Hello, I am new to these utilities (as you can see), and I need some help.
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?