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

[swak4Foam] groovyBC boundary using values from another boundary

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

Like Tree3Likes
  • 1 Post By gschaider
  • 1 Post By gschaider
  • 1 Post By Yeru

Reply
 
LinkBack Thread Tools Display Modes
Old   June 18, 2012, 21:07
Default [swak4Foam] groovyBC boundary using values from another boundary
  #1
Member
 
jack
Join Date: Jul 2011
Posts: 52
Rep Power: 7
lg88 is on a distinguished road
Dear all
I have been studying the groovyBC boundary condition these days.But I am confused in understanding something.
The following is my inputing file for pressure p.
-------------------------------------------------------------------------------------------------------

dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{

SIDE
{
type groovyBC;
value uniform 0.1;
valueExpression "Pside";
variables "Pside@SIDE=p;";
}
OUT
{
type zeroGradient;
}
IN
{
type zeroGradient;
}
}
----------------------------------------------------------------------------------------------------------
Does it mean that I am using the state of the fields P on the same patches(in my case it is SIDE) from the previous time-step or iteration to evaluating the pressure expression in run-time?

According the original description from website http://openfoamwiki.net/index.php/Contrib_groovyBC
"groovyBC provides the ability to access fields from remote patches (other patches present within the current simulation). When evaluating the expression in run-time, the state of the fields on the remote patches from the previous time-step or iteration are utilised."

Have I understood it correctly?
Thank you for your suggestion!


lg88
lg88 is offline   Reply With Quote

Old   June 19, 2012, 15:06
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,926
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by lg88 View Post
Dear all
I have been studying the groovyBC boundary condition these days.But I am confused in understanding something.
The following is my inputing file for pressure p.
-------------------------------------------------------------------------------------------------------

dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{

SIDE
{
type groovyBC;
value uniform 0.1;
valueExpression "Pside";
variables "Pside@SIDE=p;";
}
OUT
{
type zeroGradient;
}
IN
{
type zeroGradient;
}
}
----------------------------------------------------------------------------------------------------------
Does it mean that I am using the state of the fields P on the same patches(in my case it is SIDE) from the previous time-step or iteration to evaluating the pressure expression in run-time?

According the original description from website http://openfoamwiki.net/index.php/Contrib_groovyBC
"groovyBC provides the ability to access fields from remote patches (other patches present within the current simulation). When evaluating the expression in run-time, the state of the fields on the remote patches from the previous time-step or iteration are utilised."

Have I understood it correctly?
Thank you for your suggestion!


lg88
It's a bit more complicated than that: if the solver does multiple iterations per timestep then for later iterations p will be the updated value. Your expression basically sets p uniformly to the average of what p currently is (which is technically the value of the last time).

Newer versions of groovyBC have the possiblity to access the p from the last time with "oldTime(p)".

Form the @ in your remote patch-access I deduce that you're using a non-swak4Foam version of groovyBC (the syntax there is different). "oldTime" won't work there anyway
Hamoon likes this.
gschaider is offline   Reply With Quote

Old   June 22, 2012, 09:50
Default
  #3
Member
 
jack
Join Date: Jul 2011
Posts: 52
Rep Power: 7
lg88 is on a distinguished road
Hi gschaider
I have installed swak4Foam in my computer for the purpose of using function 'oldTime'.I need the calculated value of the last time not the average value.So I have changed my inputing P file as follow:
----------------------------------------------------------------------------------------------------
dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{

SIDE
{
type groovyBC;
value uniform 0.1;
valueExpression "Pside";
variables "Pside{SIDE}=oldTime(p);";
}
OUT
{
type zeroGradient;
}
IN
{
type zeroGradient;
}
}

-----------------------------------------------------------------------------------------------------------------
But when I run my case,it came out some warnings as:
Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResultI.H at line 158
    The minimum value -2.83026e-12 and the maximum -8.53848e-14 differ. I will use the average -1.45782e-12
DICPCG:  Solving for P, Initial residual = 0.00118285, Final residual = 9.79314e-07, No Iterations 23
I guessed the solver had token the average value as the boundary condition from the warning.Do you know what is wrong with it?

Regards!

lg88
lg88 is offline   Reply With Quote

Old   June 22, 2012, 15:06
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,926
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by lg88 View Post
Hi gschaider
I have installed swak4Foam in my computer for the purpose of using function 'oldTime'.I need the calculated value of the last time not the average value.So I have changed my inputing P file as follow:
----------------------------------------------------------------------------------------------------
dimensions [0 2 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{

SIDE
{
type groovyBC;
value uniform 0.1;
valueExpression "Pside";
variables "Pside{SIDE}=oldTime(p);";
}
OUT
{
type zeroGradient;
}
IN
{
type zeroGradient;
}
}

-----------------------------------------------------------------------------------------------------------------
But when I run my case,it came out some warnings as:
Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResultI.H at line 158
    The minimum value -2.83026e-12 and the maximum -8.53848e-14 differ. I will use the average -1.45782e-12
DICPCG:  Solving for P, Initial residual = 0.00118285, Final residual = 9.79314e-07, No Iterations 23
I guessed the solver had token the average value as the boundary condition from the warning.Do you know what is wrong with it?
Just write
Code:
        variables       "Pside=oldTime(p);";
the values are always averaged if you us the "remote" notation for variables. Even if "remote" is the same patch
yanxiang likes this.
gschaider is offline   Reply With Quote

Old   September 1, 2014, 11:26
Default shredder BC instead of coupling
  #5
New Member
 
Dominik Pöltl
Join Date: Jul 2013
Location: Hamburg
Posts: 15
Rep Power: 5
Yeru is on a distinguished road
Dear Jack, dear Bernhard,

I have the same warning when running scalarTransportFoam on my case.
Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value 0.470189 and the maximum 0.592711 differ. I will use the average 0.527611
My case is a simple simulation of a rectangular channel after a delta-shaped SuperFocus mixer. Since the nozzles of fluid A and B alternate, my initial condition is a nice alternating pattern A-B-A-B-A

The fluid moves steadily in negative z direction.
The upper inlet patch is coupled to the lower one via groovyBC
Code:
    cycEl_front
    {
        type        groovyBC;
        fractionExpression    1;
        variables    "T_back{cycEl_back}=T;    grad_back{cycEl_back}=snGrad(T);";
        valueExpression    "T_back";
        gradientExpression    "grad_back";
    }
Even changing it to "oldTime(T)" still yields the solver warnings.
The results are like a shredder boundary condition:
Instead of a coupling, that reproduces the values at the outlet, I get this:


Neither my supervisor nor me can think of any simpler yet adequate other BCs.
Any advice?
Yeru is offline   Reply With Quote

Old   September 1, 2014, 12:08
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,926
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Yeru View Post
Dear Jack, dear Bernhard,

I have the same warning when running scalarTransportFoam on my case.
Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value 0.470189 and the maximum 0.592711 differ. I will use the average 0.527611
My case is a simple simulation of a rectangular channel after a delta-shaped SuperFocus mixer. Since the nozzles of fluid A and B alternate, my initial condition is a nice alternating pattern A-B-A-B-A

The fluid moves steadily in negative z direction.
The upper inlet patch is coupled to the lower one via groovyBC
Code:
    cycEl_front
    {
        type        groovyBC;
        fractionExpression    1;
        variables    "T_back{cycEl_back}=T;    grad_back{cycEl_back}=snGrad(T);";
        valueExpression    "T_back";
        gradientExpression    "grad_back";
    }
Even changing it to "oldTime(T)" still yields the solver warnings.
The results are like a shredder boundary condition:
Instead of a coupling, that reproduces the values at the outlet, I get this:


Neither my supervisor nor me can think of any simpler yet adequate other BCs.
Any advice?
I have discussed this multiple times here: "remote" variables can only be uniform. But what would be appropriate for your example would be a "mapped"-boundary. See the pitzDailyMapped in the tutorials and n swak in Examples/tests/ the mapping examples (although they do more than what you might need)
__________________
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   April 22, 2016, 04:48
Default The sign "-" in groovyBC
  #7
New Member
 
jamamoto takasi
Join Date: Jul 2015
Posts: 11
Rep Power: 3
Jamamoto takasi is on a distinguished road
I have confused, When I use groovyBC to set the input of the velocity, such as this
Code:
inlet
{
	type 		groovyBC;
        variables "Ustar= 0.005;E=9.8;kappa=0.41;nu=1e-6;para=-(Ustar/kappa)*log(E*Ustar*pos().y/nu)*normal();";        
	valueExpression "para";
        value           uniform (0.02 0 0);
    
}
The problem here is the sign "-" before para. Its physical meaning ?

When I do not use it, the velocity will be in the opposite direction, ie the velocity input from outlet .

Thanks,

best regards,


takasi
Jamamoto takasi is offline   Reply With Quote

Old   April 24, 2016, 15:30
Default
  #8
New Member
 
Dominik Pöltl
Join Date: Jul 2013
Location: Hamburg
Posts: 15
Rep Power: 5
Yeru is on a distinguished road
Quote:
Originally Posted by Jamamoto takasi View Post
[...]
Code:
inlet
{
    type         groovyBC;
        [...] para=-(Ustar/kappa)*log(E*Ustar*pos().y/nu)*normal();";    
}
[...]
Dear Takasi,
short answer: try
Code:
para=(-1)*(Ustar/kappa)*log(E*Ustar*pos().y/nu)*normal();
long answer: openFoam regards the minus sign as a binary operator (e.g. "a - b") so that it cannot stand on its own. The unary minus sign (e.g. "-c") can thereby be used by multiplying a term with -1.

I hope, this solves your problem!
Greetings,
Yeru
Jamamoto takasi likes this.
Yeru is offline   Reply With Quote

Old   May 2, 2016, 14:48
Default
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,926
Rep Power: 41
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Yeru View Post
Dear Takasi,
short answer: try
Code:
para=(-1)*(Ustar/kappa)*log(E*Ustar*pos().y/nu)*normal();
long answer: openFoam regards the minus sign as a binary operator (e.g. "a - b") so that it cannot stand on its own. The unary minus sign (e.g. "-c") can thereby be used by multiplying a term with -1.

I hope, this solves your problem!
Greetings,
Yeru
Strange. groovyBC should know how to handle a unary minus
__________________
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

Tags
groovybc

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Nozzle-Expander Design karmavatar CFX 20 March 20, 2016 09:44
About groovyBC to set distributed fixedGradient values for each cell boundary patch nwpukaka OpenFOAM 6 August 12, 2014 06:34
GETVAR Error in Multiband Monte Carlo Radiation Simulation with Directional Source silvan CFX 3 June 16, 2014 09:49
Radiation interface hinca CFX 15 January 26, 2014 18:11
domain imbalance for enrgy equation happy CFX 14 September 6, 2012 01:54


All times are GMT -4. The time now is 06:36.