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

groovyBC and Eqn.setReference()

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

Like Tree1Likes
  • 1 Post By benk

Reply
 
LinkBack Thread Tools Display Modes
Old   June 1, 2011, 13:44
Default groovyBC and Eqn.setReference()
  #1
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 10
benk is on a distinguished road
Hi, I've been experimenting with groovyBC and I'm trying to duplicate the fixedGradient boundary condition except in my simple test case I also need to be able to set a reference value.

In my example, I'm solving a simple 1D equation:
Code:
fvm:ddt(a, T) - fvm::laplacian(k, T) - Q
(essentially just a diffusion pde with a source term).

My boundary conditions on the left and right walls (this is just 1D) are both fixedGradient which means that I need to set a reference value, which I would normally do by:

Code:
TEqn.setReference(0, someReferenceValue)
This seems to work with fixedGradient boundary conditions, but I can't duplicate the result when I'm using groovyBC.

When using groovyBC, the TEqn.setReference(0, refValue) seems to get ignored. I've noticed that groovyBC has it's own refValue and a refGradient. But when I specify the refValue in my groovyBC code, the fractionExpression automatically gets changed to "1" whereas I need it to be "0".

This is probably the intended behavior, but is there a way to set a referenceValue and use a gradient based boundary condition (ie. fractionExpression "0") at the same time with groovyBC?
mm.abdollahzadeh likes this.
benk is offline   Reply With Quote

Old   June 1, 2011, 14:28
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by benk View Post
Hi, I've been experimenting with groovyBC and I'm trying to duplicate the fixedGradient boundary condition except in my simple test case I also need to be able to set a reference value.

In my example, I'm solving a simple 1D equation:
Code:
fvm:ddt(a, T) - fvm::laplacian(k, T) - Q
(essentially just a diffusion pde with a source term).

My boundary conditions on the left and right walls (this is just 1D) are both fixedGradient which means that I need to set a reference value, which I would normally do by:

Code:
TEqn.setReference(0, someReferenceValue)
This seems to work with fixedGradient boundary conditions, but I can't duplicate the result when I'm using groovyBC.

When using groovyBC, the TEqn.setReference(0, refValue) seems to get ignored. I've noticed that groovyBC has it's own refValue and a refGradient. But when I specify the refValue in my groovyBC code, the fractionExpression automatically gets changed to "1" whereas I need it to be "0".
This is the expected behaviour (because most people will want a Dirichlet-BC):
http://openfoamwiki.net/index.php/Co...s_in_the_patch
Why don't you set the fraction expression to "0"?

Quote:
Originally Posted by benk View Post
This is probably the intended behavior, but is there a way to set a referenceValue and use a gradient based boundary condition (ie. fractionExpression "0") at the same time with groovyBC?
I'm not sure whether this will work with groovyBC. The problem is that it is based on the built in BC "mixed" and I think even with a valueFraction "uniform 0" setReference doesn't consider the BC to be pure Neumann (which in fact it is).

Only solution I can think of is to use TEqn.setValues to fix tjhe value in a cell (but that would do it no matter what the BCs are) or to write a BC groovyGradientBC that is based on fixedGradient instead of mixed (see the groovyTotalPressure-BC in swak4Foam for an example).

OR there is another solution if your gradient value is static but non-uniform: set the BC to fixedGradient. Then use groovySetBoundaryField to set the value of the gradient and calculate without groovyBC
gschaider is offline   Reply With Quote

Old   June 1, 2011, 14:30
Default
  #3
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gschaider View Post
OR there is another solution if your gradient value is static but non-uniform: set the BC to fixedGradient. Then use groovySetBoundaryField to set the value of the gradient and calculate without groovyBC
Sorry. As I always say: "I only write that stuff. This doesn't mean that I know how to use it correctly" the name of the utility is funkySetBoundaryField
gschaider is offline   Reply With Quote

Old   June 2, 2011, 08:49
Default
  #4
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 10
benk is on a distinguished road
Ok, thanks for the info. I'll look into your suggestions.
benk 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 14:30.