CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   New BC: problems with asking velocity vector (https://www.cfd-online.com/Forums/openfoam-programming-development/131113-new-bc-problems-asking-velocity-vector.html)

james91 March 9, 2014 11:02

New BC: problems with asking velocity vector
 
Dear foamers

I am making a new boundary condition that depends on the direction of the velocity vector U (if you is going in the positive Y direction, the inlet velocity should be U1 and if it it is going in the negative Y direction, velocity should be U2).
It compiles but gives wrong results ( I think it is because the asked U value is not the velocity vector of the cell just above the boundary?)


Code:

void Foam::myInletOutletWithNormalVel::updateCoeffs() //
{
    if (updated())
    {
        return;
    }

    const fvPatchVectorField& Up =
        patch().lookupPatchField<volVectorField, vector>(UName_);    //searches value of U
 
    scalarField normal = Up.component(1);     
    scalarField valueFraction =(1-pos((normal)));         

  vectorField::operator=(valueFraction*U1_ + (1.0 - valueFraction)*U2_); //
 
    fixedValueFvPatchVectorField::updateCoeffs();

}

Could someone with some more C++ experience help me out and say what I am doing wrong :)?

Thank you!!!


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