CFD Online URL
[Sponsors]
Home > Forums > OpenFOAM

groovyBC: using gradientExpression instead of valueExpression

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 29, 2011, 12:03
Question groovyBC: using gradientExpression instead of valueExpression
  #1
New Member
 
Gregory N de Boer
Join Date: Dec 2011
Posts: 12
Rep Power: 4
gregdB is on a distinguished road
Hello,

I am attempting to emulate a BC using groovyBC. I require pure Neumann BC's and so I believe I should employ gradientExpression rather than valueExpression? By simply changing fractionExpression simply to "0" does this mean I do not need to specify valueExpression given what is mentioned here about the use of valueExpression and value?

http://openfoamwiki.net/index.php/Co...s_in_the_patch

As in I specify the gradient at the boundary and let the value be solved for (initialised with uniform 0 or whatever).

Any help would be very much appreciated.

Cheers,
Greg
gregdB is offline   Reply With Quote

Old   December 29, 2011, 13:28
Default
  #2
Senior Member
 
Nima Sam
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,083
Blog Entries: 1
Rep Power: 14
nimasam is on a distinguished road
Send a message via Yahoo to nimasam
whats wrong using standard BC like fixedGradient or zeroGradient?
nimasam is offline   Reply With Quote

Old   December 29, 2011, 15:23
Default
  #3
New Member
 
Gregory N de Boer
Join Date: Dec 2011
Posts: 12
Rep Power: 4
gregdB is on a distinguished road
I require near-periodicity, that is very similar to a cyclic BC but with a specified pressure difference across the domain.
gregdB is offline   Reply With Quote

Old   December 29, 2011, 17:06
Default
  #4
Senior Member
 
Nima Sam
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,083
Blog Entries: 1
Rep Power: 14
nimasam is on a distinguished road
Send a message via Yahoo to nimasam
did you see fan boundary condition it is a like cyclic with the difference pressure
nimasam is offline   Reply With Quote

Old   December 29, 2011, 18:42
Default
  #5
New Member
 
Gregory N de Boer
Join Date: Dec 2011
Posts: 12
Rep Power: 4
gregdB is on a distinguished road
It seems to me that the cyclic fan applies the pressure difference across a patch given what I've read here:

http://www.tfd.chalmers.se/~hani/kur...ningReport.pdf

I require the pressure difference from inlet to outlet across the domain not at a specific location. The flow in my problem is driven by a moving wall where the pressure and velocity profiles are specified at inlet or outlet as a result of periodicity and a pressure difference. Can I achieve this with cyclic fan BC's at both inlet and outlet?
gregdB is offline   Reply With Quote

Old   December 29, 2011, 19:22
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,889
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gregdB View Post
Hello,

I am attempting to emulate a BC using groovyBC. I require pure Neumann BC's and so I believe I should employ gradientExpression rather than valueExpression? By simply changing fractionExpression simply to "0" does this mean I do not need to specify valueExpression given what is mentioned here about the use of valueExpression and value?

http://openfoamwiki.net/index.php/Co...s_in_the_patch

As in I specify the gradient at the boundary and let the value be solved for (initialised with uniform 0 or whatever).

Any help would be very much appreciated.

Cheers,
Greg
You're right. Setting fractionExpression to 0 makes groovyBC use only the gradientExpression (basically groovyBC is a wrapper around the standard mixed BC)

The business with value vs valueExpression was a bit confusing in the section you mentioned due to a misformatting. Basically value is only used as a standin in certain situations where for technical reasons valueExpression can't be used
gschaider is online now   Reply With Quote

Old   December 29, 2011, 21:52
Default
  #7
New Member
 
Gregory N de Boer
Join Date: Dec 2011
Posts: 12
Rep Power: 4
gregdB is on a distinguished road
Excellent, thanks.

Does this mean that when using gradientExpression the variable specified by value is the gradient for the 1st iteration or the actual value for the 1st iteration? I require zero here in either case so probably best to leave out value unless I get an fpe?
gregdB is offline   Reply With Quote

Old   December 30, 2011, 03:13
Default
  #8
Senior Member
 
Join Date: Nov 2009
Location: Michigan
Posts: 135
Rep Power: 7
doubtsincfd is on a distinguished road
when you specify a fan boundary condition, you have to specify the neighbor patch for each of the patch you have declared as fan. Eg:
inlet
{
type cyclic;
nFaces 240;
startFace 62080;
matchTolerance 0.0001;
neighbourPatch outlet;
}
outlet
{
type cyclic;
nFaces 240;
startFace 62320;
matchTolerance 0.0001;
neighbourPatch inlet;
}
It will then apply whatever pressure drop you mention between inlet and outlet. i.e Poutlet-Pinlet = specified value. So I believe fan BC should serve your purpose even though the two patches are separated by a distance.
doubtsincfd is offline   Reply With Quote

Old   December 30, 2011, 07:38
Default
  #9
New Member
 
Gregory N de Boer
Join Date: Dec 2011
Posts: 12
Rep Power: 4
gregdB is on a distinguished road
Thanks for the reply, unfortunately I need more control over the solution than the cyclic fan BC seems to provide. Probably should have mentioned that I am looking into a Fluid Structure Interaction problem where eventually I will be scaling velocities at inlet and outlet according to strain (deformation). Effectively I need access to the nodal values of velocity and pressure at inlet and outlet so that I can apply my CFD BC's. This is the reason for my enquiries into groovyBC.
gregdB is offline   Reply With Quote

Old   January 1, 2012, 18:08
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,889
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gregdB View Post
Thanks for the reply, unfortunately I need more control over the solution than the cyclic fan BC seems to provide. Probably should have mentioned that I am looking into a Fluid Structure Interaction problem where eventually I will be scaling velocities at inlet and outlet according to strain (deformation). Effectively I need access to the nodal values of velocity and pressure at inlet and outlet so that I can apply my CFD BC's. This is the reason for my enquiries into groovyBC.
Whether groovyBC might help you with your problem depends on where the "source" of the deformation comes from (patch on another mesh for instance) and whether that deformation is uniform. The problem that you might have is that groovyBC supports getting values from other patches (even from other meshes), but you can only use a uniform value on the "target" patch (for instance: the average displacement on the "other" patch). The reason why a general mapping from one patch to another isn't implemented is not so much that the mapping is difficult to do, but to find out (or let the user specify) whether a mapping is appropriate at all
gschaider is online now   Reply With Quote

Old   September 13, 2013, 05:01
Default
  #11
Member
 
Join Date: Jun 2011
Posts: 59
Rep Power: 5
maalan is on a distinguished road
Quote:
You're right. Setting fractionExpression to 0 makes groovyBC use only the gradientExpression (basically groovyBC is a wrapper around the standard mixed BC)

The business with value vs valueExpression was a bit confusing in the section you mentioned due to a misformatting. Basically value is only used as a standin in certain situations where for technical reasons valueExpression can't be used
Hi, Bernhard!

I had a look into the Examples/groovybc folder looking for an example of gradientExpression but I did not find anything that helps... the point is I would like to set the next BC:

"normal()&grad(J)=-h&k", being h and k vectors.

Up to the moment I tried unsuccessfully:
Code:
    type                groovyBC;
    variables           "gradJ=grad(J);";
    gradientExpression  "normal()&gradJ+h&k";
    value               uniform 0;
    fractionExpression  "0";
What do you think?? Thanks in advance!
Best!

Last edited by maalan; September 17, 2013 at 06:28.
maalan is offline   Reply With Quote

Old   September 16, 2013, 16:11
Default
  #12
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,889
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by maalan View Post
Hi, Bernhard!

I had a look into the Examples/groovybc folder looking for an example of gradientExpression but I did not find anything that helps... the point is I would like to set the next BC:

"normal()&grad(T)=-h&k", being h and k vectors.

Up to the moment I tried unsuccessfully:
Code:
    type                groovyBC;
    variables           "gradJ=grad(J);";
    gradientExpression  "normal()&gradJ+h&k";
    value               uniform 0;
    fractionExpression  "0";
What do you think?? Thanks in advance!
Best!
What do you mean with "unsuccessfully": the gradients are not set the way you expect them to or the simulation does not behave the way you think it should? Best way to distinguish these two cases is to look at the first timestep that is written to disc. There the BC should have additional values: refGradient would be the result of your expression etc.

Hold on: "grad(J)". That works? Anyway. The thing you want (gradient of J in normal direction) would be done better with "snGrad(J)"
__________________
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 online now   Reply With Quote

Old   September 17, 2013, 04:18
Default
  #13
Member
 
Join Date: Jun 2011
Posts: 59
Rep Power: 5
maalan is on a distinguished road
Quote:
What do you mean with "unsuccessfully": the gradients are not set the way you expect them to or the simulation does not behave the way you think it should? Best way to distinguish these two cases is to look at the first timestep that is written to disc. There the BC should have additional values: refGradient would be the result of your expression etc.
Hi again and thanks for your reply!! I mean with unsuccessfully I don't get the result that I should... Well, I had a look to the refGradient part in my first written time step and it's not right... So, could you tell how to set this BC with groovyBC ("snGrad(T)=-h&k")??

Thanks in advance!!
Best!
maalan is offline   Reply With Quote

Old   September 17, 2013, 06:26
Default
  #14
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,889
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by maalan View Post
Hi again and thanks for your reply!! I mean with unsuccessfully I don't get the result that I should... Well, I had a look to the refGradient part in my first written time step and it's not right... So, could you tell how to set this BC with groovyBC ("snGrad(T)=-h&k")??

Thanks in advance!!
Best!
In OpenFOAM on patches "gradient" always means "gradient in the direction of the surface normal" not "gradient in general cartesian coordinates". So an expression "-h&k" should be sufficient (sign may be wrong)
__________________
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 online now   Reply With Quote

Old   September 20, 2013, 07:08
Default
  #15
New Member
 
kob
Join Date: Nov 2011
Posts: 28
Rep Power: 5
bryant_k is on a distinguished road
Hello everyone
I need set a boundary condition similar to maalan's:
Code:
"normal()&grad(J)=-h&k", being h and k vectors.

Up to the moment I tried unsuccessfully:
Code:
    type                groovyBC;
    variables           "gradJ=grad(J);";
    gradientExpression  "normal()&gradJ+h&k";
    value               uniform 0;
    fractionExpression  "0";
It is a outlet boundary condition for ephi:
Code:
d(ephi)/dn=(U^M)&n
where ephi is a volScalarField,U means velocity,M is a constant volVectorFiled, and n is the normal vector.

I set it as:
Code:
Outlet
{
type                groovyBC;
gradientExpression  "gradephi";
variables           "gradephi=(U^M)&normal();";
value               uniform 0;
fractionExpression  "0";
}
But the calculation became divergence after some step times.

I think the problem lies at this boundary condition because when I change the boundary condition to :
Code:
outlet
{
type   zeroGradient;
}
everything goes well.

I am not sure can I set the boundary using GroovyBC since U is a variable I need solve.

Thank you for your suggestion!

regards!

bryant
bryant_k is offline   Reply With Quote

Old   September 20, 2013, 09:03
Default
  #16
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,889
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bryant_k View Post
Hello everyone
I need set a boundary condition similar to maalan's:
Code:
"normal()&grad(J)=-h&k", being h and k vectors.

Up to the moment I tried unsuccessfully:
Code:
    type                groovyBC;
    variables           "gradJ=grad(J);";
    gradientExpression  "normal()&gradJ+h&k";
    value               uniform 0;
    fractionExpression  "0";
It is a outlet boundary condition for ephi:
Code:
d(ephi)/dn=(U^M)&n
where ephi is a volScalarField,U means velocity,M is a constant volVectorFiled, and n is the normal vector.

I set it as:
Code:
Outlet
{
type                groovyBC;
gradientExpression  "gradephi";
variables           "gradephi=(U^M)&normal();";
value               uniform 0;
fractionExpression  "0";
}
But the calculation became divergence after some step times.

I think the problem lies at this boundary condition because when I change the boundary condition to :
Code:
outlet
{
type   zeroGradient;
}
everything goes well.

I am not sure can I set the boundary using GroovyBC since U is a variable I need solve.

Thank you for your suggestion!

regards!

bryant
Well. groovyBC only enables you to set BCs. Whether they are stable is not its responsibility. Especially gradients are tricky. Because if you have high gradients then the solution might "overshoot" what makes physical sense. The trick then is usually to switch to fixedValue (the standard heat transfer-BCs in OpenFOAM do that all the time). I discussed the problem of the overshoot with somebody else a couple of weeks ago on the Forum so I'm not going to go into that again
__________________
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 online now   Reply With Quote

Reply

Tags
groovybc, openfoam

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
GroovyBC problem in the defining inlet velocity iampolaris OpenFOAM Running, Solving & CFD 7 October 18, 2014 10:25
settings a gradient on boundary using groovyBC gfilip OpenFOAM Running, Solving & CFD 6 May 4, 2012 10:41
groovyBC and Eqn.setReference() benk OpenFOAM 3 June 2, 2011 09:49
Wall heat transfer using groovyBC (XiFoam solver) usergk OpenFOAM 7 February 4, 2011 14:36
Non-normal inflow with groovyBC bjr OpenFOAM 9 January 17, 2011 11:35


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