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

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    INLET
    {

        type            codedFixedValue;
        value           uniform (0 0 0); //default value
        name            linearTBC_U; //name of new BC type
        code
        #{
            const fvPatch& inletPatch = this->patch();
            
            vectorField& vf = *this; 
            forAll(vf, i)
            { 
                scalar z = inletPatch.Cf()[i].y(); //inletPatch.Cf()[i].y();
                scalar uStar = 0.7486;
                scalar z0 = 0.1;
                scalar kappa = 0.4;
				scalar zg = 1.2;
                scalar Coriolis = 0.0000558;
				
				scalar z0_mod = z0*zg/(uStar/6/Coriolis);
				scalar Coriolis_mod = uStar/(6*zg);
				//scalar AOA = 9; //wind attack angle
				
				if(z <= zg)
				{
					vf[i].x() = uStar/kappa*(log((z+z0_mod)/z0_mod)+34.5*Coriolis_mod*z/uStar);
					//vf[i].y() = -1*cos(3.1416/180*AOA)*uStar/kappa*log((z+z0)/z0);
					//vf[i].z() = 0.0;
				}
				else
				{
					vf[i].x() = uStar/kappa*(log((zg+z0_mod)/z0_mod)+34.5*Coriolis_mod*zg/uStar);
					//vf[i].y() = -1*cos(3.1416/180*AOA)*uStar/kappa*log((zg+z0)/z0);
					//vf[i].z() = 0.0;
				}				
            }
        #};
    }
    OUTLET
    {
        type            zeroGradient;
    }
    TOP
    {
        type            symmetry;
    }
    BOTTOM
    {
        type            noSlip;
    }
    frontAndBackPlanes
    {
        type            empty;
    }
}


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