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] groovyBC and Eqn.setReference() (https://www.cfd-online.com/Forums/openfoam-community-contributions/89026-groovybc-eqn-setreference.html)

benk June 1, 2011 13:44

groovyBC and Eqn.setReference()
 
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?

gschaider June 1, 2011 14:28

Quote:

Originally Posted by benk (Post 310179)
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 (Post 310179)
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 June 1, 2011 14:30

Quote:

Originally Posted by gschaider (Post 310184)
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

benk June 2, 2011 08:49

Ok, thanks for the info. I'll look into your suggestions.


All times are GMT -4. The time now is 14:35.