CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

is it possible and correct to set a logical condition in variables of groovyBC?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   March 17, 2013, 20:21
Default is it possible and correct to set a logical condition in variables of groovyBC?
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,209
Rep Power: 18
immortality is on a distinguished road
like "a=t1<=time()<t1+deltaT;"
And then use a in expressions?
immortality is offline   Reply With Quote

Old   March 18, 2013, 07:49
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
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()
__________________
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
gschaider is offline   Reply With Quote

Old   August 26, 2016, 03:44
Default
  #3
New Member
 
DavidTran
Join Date: Aug 2016
Posts: 9
Rep Power: 2
davidtran is on a distinguished road
Hi Ehsan,

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

Thank you.

Quote:
Originally Posted by immortality View Post
like "a=t1<=time()<t1+deltaT;"
And then use a in expressions?
davidtran is offline   Reply With Quote

Old   September 15, 2016, 03:00
Default
  #4
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 633
Rep Power: 14
vasava will become famous soon enough
I am trying something similar with help from these pages.

I will post if I get something going.

Last edited by vasava; September 15, 2016 at 03:04. Reason: add
vasava is online now   Reply With Quote

Old   September 15, 2016, 05:28
Default
  #5
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 633
Rep Power: 14
vasava will become famous soon enough
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.
vasava is online now   Reply With Quote

Old   September 15, 2016, 14:56
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by vasava View Post
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)
__________________
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
gschaider is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:53.