|
[Sponsors] |
September 10, 2020, 07:43 |
New expression version of Function1
|
#1 | |
New Member
Joe
Join Date: Oct 2016
Posts: 15
Rep Power: 10 |
Hi all...
I'm looking to set a boundary condition on an inlet patch as to specify alpha.water = 1 below a certain z position (interFoam). Using the expression version of Function 1 as per the OpenFoam documentation I tried the following: alpha.water Quote:
Does anyone perhaps know the correct syntax for using pos()? Last edited by OOTB; September 10, 2020 at 09:03. Reason: added quote tags |
||
September 10, 2020, 08:53 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
In which OpenFOAM version can one apply this syntax? Is it implemented in the ESI version? In any case, I guess you cannot use the pos() function out of the box, because you need a reference to an object. You even did not specify the error message so it is a bit hard to give valuable feedback.
Nevertheless, as you showed the condition you set (please use code tags - update your post), it seems to be somehow similar to the codedMixed boundary condition. If I am right, you need an object first. An example: Code:
inlet { type uniformFixedValue; uniformValue { type expression; expression #{ // Actual time --> t is an object of type scalar const scalar t = *this->db().time().runTime(); #}; } Code:
inlet { type uniformFixedValue; uniformValue { type expression; expression #{ (pos().z < 38.2) ? 1 : 0 // << ; missing #}; }
__________________
Keep foaming, Tobias Holzmann |
|
September 10, 2020, 09:20 |
|
#3 | |
New Member
Joe
Join Date: Oct 2016
Posts: 15
Rep Power: 10 |
Hi Tobi, thanks for the reply.
I'm using OpenFoam v2006. They have an example here (attached a clip) https://www.openfoam.com/releases/openfoam-v2006/pre-processing.php The error code is generated when running setFields and is as follows: Quote:
|
||
September 11, 2020, 11:11 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
The documentation : https://www.openfoam.com/documentati...on-syntax.html In swak4foam I think you could have '.z', but for the OpenFOAM expressions you need '.z()' for the component. This makes it looks more like C++ code, and also makes the parser more deterministic. For a similar reason we have 'pi()', which looks like a function call, but actually maps to a constant value. For things like 'degToRad()' you can have both versions, as a constant or a function. Eg, Code:
45 * degToRad() degToRad(45) |
||
September 11, 2020, 11:16 |
|
#5 | ||
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
Quote:
|
|||
September 13, 2020, 07:46 |
|
#6 |
New Member
Joe
Join Date: Oct 2016
Posts: 15
Rep Power: 10 |
Thank you Mark.. it worked! Its much appreciated.
|
|
September 14, 2020, 09:21 |
|
#7 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 143
Rep Power: 20 |
Hi,
just for sake of completeness: You could achive same much simpler by just using fixedValue BC and initialize with setFields (as done e.g in the DTCHull tutorial). Or initialization with setWaves tool would even allow to set alpha values indipendent of the cell coordinates, giving you "correct" vof values between 0 and 1 for partially filled cells. Best, Jan |
|
September 14, 2020, 10:14 |
|
#8 |
New Member
Joe
Join Date: Oct 2016
Posts: 15
Rep Power: 10 |
Thank you Jan,
I want to set different fixed levels on the inlet and outlet patches.. I'm not sure how to do it with setFields. regards |
|
September 14, 2020, 10:25 |
|
#9 |
Senior Member
Jan
Join Date: Jul 2009
Location: Hamburg
Posts: 143
Rep Power: 20 |
you can define separate boxes, including only inlet or outlet. Values for the patches are set within the boxToFace block. However, no idea how to ensure consistent initialization within the domain. But I think you have same problem when using the uniformFixedValue BC in combination with expression.
Best, Jan |
|
Tags |
function1 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM.com versus OpenFOAM.org: Which version to use? | wyldckat | OpenFOAM | 19 | March 25, 2023 08:50 |
CEL expression in CFX pre | Jane92 | Main CFD Forum | 1 | June 3, 2016 03:48 |
libz.so.1: no version information available | dmaz | OpenFOAM Running, Solving & CFD | 3 | January 4, 2015 17:54 |
[Matlab] - Add toolbox to version R2012b. | darkluix88 | Lounge | 2 | October 23, 2014 11:23 |
CGNS lib and Fortran compiler | manaliac | Main CFD Forum | 2 | November 29, 2010 07:25 |