CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Boundary Condition: "mixed" calculated and gradient (

lindstroem November 12, 2012 10:05

Boundary Condition: "mixed" calculated and gradient
Hi Foamers!

Is it possible to have a boundary condition that combines both, a "calculated" and a gradient (e.g. zero- or fixedGradient) BC?
What I would like to have is, that it "acts" like a calculated BC until a certain value (of a variable within the solver) is reached, and then switch to a gradient BC. And it should also be possible to switch back.

I had a look at the mixed BC as it looked as if it is quite close to what I want, but I do not understand how the "fraction" can be adjusted within the solver. I did not find any helpful explanations.

Thanks in advance for any advices!

chegdan November 12, 2012 10:25

Have a look at inletOutlet derived boundary condition. Changing the value fraction from 0 to 1 will do what you would like. And for reference...I would look at

good luck.

lindstroem November 12, 2012 11:46

Hi chegdan,

thanks for your help! I think I could work directly with the mixed-BC. But I don't get the functions of the BC in my solver.
First I include the Header, then loop through my boundaries until I find my desired patch. Now how can i actually call for example the valueFraction() from the mixedBC? Do I need the "refCast" first?

thanks again in advance

chegdan November 12, 2012 12:09

Just as a little tip, I would create a derived class from mixedBC the way inletOutlet is constructed. This way you don't need to mess with the templating and bang your head on the table. I did this about a month ago and it ended up to be really simple if I just made a derived class and derived BC.

lindstroem November 12, 2012 12:11

Allright :) I misunderstood your previous post..

Thanks for sharing your experience!


chegdan November 12, 2012 12:56

No problem, glad I could help.

lindstroem November 20, 2012 11:57

Hi again,

It's progressing :)

But one further question: If I want to use the refGradient for a mixedFvPatchScalarField, I need to prescribe a scalar. But how do I interpret this scalar because I would intuitively prescribe a vector..


chegdan November 20, 2012 12:08

The gradient in this BC is in the direction normal to the surface.

lindstroem November 20, 2012 12:11

So it can only be fixedValue or a zeroGradient, but not a gradient in any prescribed direction?

chegdan November 20, 2012 12:35

The only thing that I know of for changing direction is between normal and tangential direction changed via

and further posts in that thread.

If I think of anything on the subject...I'll post back.

lindstroem November 20, 2012 12:39

Ok, thanks again for the quick reply! I'll check if the direction mixed BC could somehow work..

Thanks Dan!

All times are GMT -4. The time now is 19:56.