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] settings a gradient on boundary using groovyBC (https://www.cfd-online.com/Forums/openfoam-community-contributions/94262-settings-gradient-boundary-using-groovybc.html)

gfilip November 10, 2011 09:36

settings a gradient on boundary using groovyBC
 
Hello,

I am experimenting with groovyBC and can successfully use the valueExpression on a patch. When I try to set a gradientExpression for pressure, such as:
Code:

 
inlet
    {
        type            groovyBC;
        //valueExpression              "100";
        gradientExpression      "100";

    }

and then calculate the normal gradient of pressure on the inlet, I get non-constant values much different than 100. When using the gradientExpression I also obtain a 0 pressure on the inlet boundary. I also tried using:
gradientExpression "vector(100,0,0)&normal()" but that gives the same result.

This is a simple 2D case with an oscillatingFixedValue velocity inlet ran using pisoFoam.

Am I interpreting the gradientExpression patch parameter wrong?

akidess November 10, 2011 11:11

From the documentation:
Code:

* fractionExpression
  Determines whether the face is Dirichlet (1) or Neumann (0). Defaults to 1

You can probably see the problem. Fix fractionExpression and all will be good.

gfilip November 10, 2011 11:14

Hi Anton,

I have in fact tested the fractionExpression as well, but setting it to 0 did not help.

gschaider November 10, 2011 19:37

Quote:

Originally Posted by gfilip (Post 331578)
Hello,

I am experimenting with groovyBC and can successfully use the valueExpression on a patch. When I try to set a gradientExpression for pressure, such as:
Code:

 
inlet
    {
        type            groovyBC;
        //valueExpression              "100";
        gradientExpression      "100";

    }

and then calculate the normal gradient of pressure on the inlet, I get non-constant values much different than 100. When using the gradientExpression I also obtain a 0 pressure on the inlet boundary. I also tried using:
gradientExpression "vector(100,0,0)&normal()" but that gives the same result.

This is a simple 2D case with an oscillatingFixedValue velocity inlet ran using pisoFoam.

Am I interpreting the gradientExpression patch parameter wrong?

I'm just wondering whether I'm misinterpreting your posting. "I get non-constant values much different than 100" Do you mean "I calculated the gradient using the value in the next cell and the delta coefficient and it was much different from 100". In that case there is a problem. Or did you mean "'value' on the patch is different from 100". That is to be expected because you're only setting the gradient on the patch (basically the relative change to the next cell) NOT the value with a Neuman condition

tfuwa May 3, 2012 10:05

Hi All,

I would like to set up a gradient B.C., ∂p/∂x = cos (2*pi*t) .

Is there a way to do this with groovyBC or openfoam official tools?

Cheers.

gschaider May 3, 2012 11:24

Quote:

Originally Posted by tfuwa (Post 359105)
Hi All,

I would like to set up a gradient B.C., ∂p/∂x = cos (2*pi*t) .

Is there a way to do this with groovyBC or openfoam official tools?

In groovyBC this would be something like this:
valueExpression "0"; // this doesn't matter
fractionExpression "0"; // no value, all gradient
gradientExpression "sin(2*pi*time())";

Official tools: you can do something similar with some C++-programming with the codedMixed-BC I guess

tfuwa May 4, 2012 09:41

Thanks Bernhard! It works perfect.


All times are GMT -4. The time now is 07:37.