CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   componentMixed BC in the motionU file (

sasanghomi March 1, 2014 17:30

componentMixed BC in the motionU file
Hi Foamers ,

I want to know about this BC in the motionU file:
type componentMixed;
refValue uniform (0 0 0);
valueFraction uniform (1 0 1);

How does it work? I know it is a combination of Neuman and Dirichlet BCs. Actually I want to know the meaning of refValue uniform (0 0 0); and valueFraction uniform (1 0 1); exactly !!
Could anyone explain it mathematically ?

I appreciate your help.
Thanks and best regards

sasanghomi March 3, 2014 07:54

Any ideas? :(

wyldckat March 3, 2014 08:20

Greetings Sasan,
  1. Which OpenFOAM version are you referring to?
  2. Which tutorial case?
Best regards,

sasanghomi March 3, 2014 10:09

1 Attachment(s)
Hi Dear Bruno,

Thanks for your reply.I am using OP 1.6-ext and about tutorial case , I should say Prof.Jasak has attached a test case about engine simulation in this thread :
honestly, I need to know this BC in the motionU file in the zero (0) directory. Also I attached this test case here. Please help me to gain a lot of information about this BC.

I appreciate your help,
Thanks and best regards.

wyldckat March 3, 2014 14:41

Hi Sasan,

When in doubt, look at the source code. Here's what I've done:
  1. Went into the folder for the main source code libraries:

    cd $FOAM_SRC
  2. Searched for the boundary condition in question:

    find . -iname "*componentMixed*"
  3. The first one seems the most likely, namely the files at:

  4. The class description in the ".H" file, says this:


        ComponentMixedPointPatchVectorField. The boundary condition is a mix
        of a fixedValue and a zeroGradient boundary condition, where a
        fixedValue/zeroGradient mix may be different for each direction.

        I am still not sure how to do the fixedValue-fixedGradient
        combination.  HJ, date deleted

  5. Looking at the ".C" file, it's a buit tricky to figure out what-is-what:
    1. The method that has the description "Evaluate patch field" is the one responsible for the actual boundary condition field calculations. The specific code is this one:

          vectorField values =
            cmptMultiply(refValue_, valueFraction_)
            + cmptMultiply(internalValues, vector::one - valueFraction_);

      For your example:

      refValue uniform (0 0 0);
      valueFraction uniform (1 0 1);

      It does this:

      (0 0 0)*(1 0 1) + U * ((1 1 1) - (1 0 1)) =
      (0 0 0) + U * (0 1 0) =
      (0 Uy 0)

    2. The method that has the description "Set boundary condition to matrix", seems to do a manipulation to the equation matrix, by hacking into the mesh points for the patch which was assigned this boundary condition, by setting a constraint for each point on the patch. This requires us to look for what the class "MatrixType<vector>::ConstraintType" actually does.
  6. Another find command:

    find . -iname "*MatrixType*"
    Gets me nothing... Ooops, that's because "MatrixType" is a object name place-holder, given that this is a template class. OK, let's do a broader search, this time searching inside certain files:

    find . -name "*.[CH]" -type f | xargs grep -sl "ConstraintType"
  7. Looks like the file:

    is a good candidate. But it's not it. It should be:

  8. Ouch... this isn't good:

    template<class Type>
    class BlockConstraint;
    typedef BlockConstraint<Type> ConstraintType;

    Now I gotta go look for where "BlockConstraint" is properly defined...
  9. Another search with find, leads me to these files:

    What we're looking for is this constructor:

            //- Construct from components
                const label row,
                const Type value,
                const Type& fixedCmpts = pTraits<Type>::one

    The meaning of each variable:

            //- Matrix row ID
            label rowID_;

            //- Fixed value
            Type value_;

            //- Fixed components (0-1) 1 = fixed, 0 = free
            Type fixedComponents_;

  10. All of this searching because of #5.b:

            // create a constraint
            typename MatrixType<vector>::ConstraintType bc

I hope you've understood all of that, because my brain just went:

I don't want to look at C++ for the rest of the day.
Anyway, I believe that the answer is given on #4.a.

Best regards,

sasanghomi March 3, 2014 17:15

Dear Bruno,

I really appreciated your help. I don't know how to thank you, honestly.
Thank you very much for your attention. :)

Best regards,

All times are GMT -4. The time now is 16:22.