CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   directionMixed b.c (

sersunzo April 14, 2009 01:04

directionMixed b.c
Hi everybody,

I try to figure out the use of directionMixed b.c.

I want a b.c. with the normal velocity =0 and the tangential velocity zeroGradient.
The way I understood the directionMixed is something like this

type directionMixed;
refValue uniform (0 0 0);
refGradient uniform (0 0 0);
valueFraction 1;
value uniform (0 0 0);

the refValue=uniform (0 0 0) means that I want a 0 normal velocity
the refGradient=uniform (0 0 0) means that I want a 0 gradient normal velocity
the valueFraction=1 means that the way I mix the two previous b.c (in my case only the first apply, if it were valueFraction=0 would be only the second)
The value=uniform (0 0 0) specify what to do with the gradient of the tangential component, no mixing this time only the gradient.

Thus I have three points
1) Is it correct my understanding?
2) There is a mistake somewhere, because the solver complains about the valueFraction 1; "Expected a '(' while reading VectorSpace<Form, Cmpt, nCmpt>, found on line 51 the label 1" Line 51 is valueFraction 1. But I do not understand what it is happening;why is it expected a '(' valueFraction is not a scalar?
3) There is another way for forcing a 0 normal velocity plus a zeroGradient tangential velocity?

Thanks in advance

remi April 15, 2009 11:43

same problem!
Hello sersunzo!

I am actually facing the exact same problem, with the very same answer from the compiler...
In addition to the questions you just asked, could someone please tell if the refValue can be accessed and changed during runtime?

Thank you very much in advance!

remi April 16, 2009 15:28

Hi everybody!

I just realized, after many tries, that the acceptable syntax for valueFraction in directionMixed b.c seems to be a symmetric tensor, ie six components between brackets.
The question following this discovery is: why is it so, and what do the component stand for?
My goal is to have a fixedValue bc on the normal component of velocity, and a zeroGradient on the tangential component.
Thanks for any hint one may have!

By the way, happy easter to all!

sersunzo April 17, 2009 13:44

Hi remi,

I believe that the following syntax would give a 0 normal velocity with 0 gradient in the tangential direction

type directionMixed;
refValue uniform (0 0 0);
refGradient uniform (0 0 0);
valueFraction (0 0 0 1 1 1);
value uniform (0 0 0);

This is just an empirical observation. I still did not get the answers to my previous questions.


remi April 17, 2009 14:17

Thank you Alessio!

I managed to get the desired behaviour (fixedValue for normal component, zero gradient for the rest) by putting valueFraction=(1 0 0 0 0 0).
Very empirical as well....
Struggling to modify the refValue during runtime, the syntax is opaque to me!

Good luck for your simulation!


sersunzo April 17, 2009 18:09

with your settings I get exactly the opposite. The tangential velocity is zero, the normal is not zero (and I suppose grad=0).
In my case the normal velocity is Vx. I do not know if it makes any difference tough...


remi April 21, 2009 10:16

modify refValue for directionMixed?
Thank you Alessio for the fast answer!
however, there is a problem to modify the boundary value of Ux velocity on runtime.
When doing U.boundaryField()[inletPatchID][faceI].component(0)= new value, you can check on the output file that the "value" part of directionMixed has been changed.
Nevertheless, it's got no impact at all on the value Ueqn is gonna solve for...

And i tried something like:

directionMixedFvPatchField& buffer=
refCast<directionMixedFvPatchField>(U.boundaryFiel d()[inletPatchID]);

scalarField& Ux = buffer.refValue().component(0);

but it doesn't compile....

good luck for you and thanks for your help!

remi April 24, 2009 10:43

modifying refValue for directionMixed
Hello all!

Finally the correct syntax to access the refValue of a directionMixed bc during runtime is through casting, by the following piece of code:

directionMixedFvPatchVectorField& buffer= refCast<directionMixedFvPatchVectorField>(U.bounda ryField()[f_in]);
vectorField& U_refValue = buffer.refValue();

then it seem to take a loop over the patch face to modify the values:

forAll (directionMixedPatchID, faceI)
{U_refValue[faceI]= whatever vector;}


wbetz September 9, 2009 07:56


if you want to set a fixed value for normal velocity and a fixed gradient in the tangential direction, the tensor of valueFraction is the outer product of the unit vector normal to the boundary with itself.

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