CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] is it possible and correct to set a logical condition in variables of groovyBC? (https://www.cfd-online.com/Forums/openfoam-community-contributions/114785-possible-correct-set-logical-condition-variables-groovybc.html)

immortality March 17, 2013 19:21

is it possible and correct to set a logical condition in variables of groovyBC?
 
like "a=t1<=time()<t1+deltaT;"
And then use a in expressions?

gschaider March 18, 2013 06:49

Quote:

Originally Posted by immortality (Post 414568)
like "a=t1<=time()<t1+deltaT;"
And then use a in expressions?

Not sure. There might be a bug there in groovyBC. But your expression won't work anyway.

a) deltaT is a function (write deltaT())
b) checking ranges like this won't work you've got to split it into two comparisons "t1<=time() && time()<(t1+deltaT())". What you're doing only works in C++ itself and there it wouldn't give the result you're expecting: first you compare t1 and time() which is either true or false. C++ interprets these as either 1 or 0 and compares these numbers with t1+deltaT()

davidtran August 26, 2016 03:44

Hi Ehsan,

Did you solve your problem? Could you share your solution?

Thank you.

Quote:

Originally Posted by immortality (Post 414568)
like "a=t1<=time()<t1+deltaT;"
And then use a in expressions?


vasava September 15, 2016 03:00

I am trying something similar with help from these pages.

I will post if I get something going.

vasava September 15, 2016 05:28

I wanted to have a boundary condition that follows a function up to a time and then use a constant value:
f(x) = F+101325; when t<0.0012
and
f(x) = 101325; when t>0.0012

Here is what I used (and it worked):
Code:

    inlet
    {
        type            groovyBC;
        value          uniform 101325;
        variables        (
                        "tPositive=0.0012;"
                        "factor=(time()>tPositive) ? 0 : 1;"
                        "inPress=SOME FUNCTION;"
                        );
        valueExpression "(inPress*factor)+101325";"
    }

I have not seen any groovyBC where deltaT is used.

gschaider September 15, 2016 14:56

Quote:

Originally Posted by vasava (Post 617949)
I wanted to have a boundary condition that follows a function up to a time and then use a constant value:
f(x) = F+101325; when t<0.0012
and
f(x) = 101325; when t>0.0012

Here is what I used (and it worked):
Code:

    inlet
    {
        type            groovyBC;
        value          uniform 101325;
        variables    (
            "tPositive=0.0012;"
            "factor=(time()>tPositive) ? 0 : 1;"
            "inPress=SOME FUNCTION;"
            );
        valueExpression "(inPress*factor)+101325";"
    }

I have not seen any groovyBC where deltaT is used.

You usually don't need that. Boundary condition should model the physics. deltaT() is a property of the discretization. If you're using that in a physical expression you're in trouble (there are applications for that function. Usually involving integration)


All times are GMT -4. The time now is 08:48.