/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       volScalarField;
    location    "0";
    object      epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -3 0 0 0 0];

internalField   uniform 0.5;

boundaryField
{
    inlet
    {
        type            codedFixedValue;
        value           uniform 0.1; //default value
        name            linearTBC1; //name of new BC type
        code
        #{
            const fvPatch& inletPatch = this->patch();
            
            scalarField& vf = *this; 
            forAll(vf, i)
            { 
                scalar z = inletPatch.Cf()[i].y();
                scalar uStar = 0.511;
                scalar z0 = 2.25e-4;
                scalar kappa = 0.4;
                scalar C1 = -0.17;
                scalar C2 = 1.62;

                //scalar C1 = 0;
                //scalar C2 = 1;
                //scalar uref = 10;
                //scalar zref = 0.1;
                //scalar uStar = kappa*uref/log((zref + z0)/z0); 

                vf[i] = pow3(uStar)/(kappa*(z + z0))
                       *sqrt(C1*log((z + z0)/z0) + C2);
            }
        #};
    }

    top
    {
        type            zeroGradient;
    }
    

    bottom
    {
        type            epsilonWallFunction;
        value           $internalField;
        //type            atmEpsilonWallFunction;
        //z0              uniform 2.25e-4;
        //Cmu             0.028;
        //kappa           0.42;
        //lowReCorrection false;
        //value    uniform 0.1;
    }
    

    outlet
    {
        type            zeroGradient;
    }

    sides
    {
        type            zeroGradient;
    }
}


// ************************************************************************* //
