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

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

internalField   uniform (0 0 0);

boundaryField
{
    top
    {
        type            codedFixedValue;
		value           uniform (0 0 0);           // Initial value
		name            codedPathBC;               // Custom name for the boundary condition
		
		code
     #{
			// accessing temperature variable 
            const volScalarField& T = this->db().lookupObject<volScalarField>("T");
            const scalar TAvg = gAverage(T);      // Volume-averaged temperature
            vectorField U(this->patch().size());

            if (TAvg < 315)
            {
                U = vector(9.66, 0, 0);
            }
            else
            {
                U = vector(2, 0, 0);
            }

            operator==(U);
        #};
    }
    bottom
    {
        type            noSlip;
    }
    leftAndright
    {
        type            noSlip;
    }
    frontAndBack
    {
        type            empty;
    }
}

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