/*--------------------------------*- 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
    #{
        const scalar time = this->db().time().value();  // Current simulation time
        vector U;                 // Velocity vector to be applied
        
        if (time == 0)
        {
            U = vector(0, 0, 0);
        }
		else if (time > 4.0 && time < 5.0)
        {
            U = vector(9.66, 0, 0);  // Constant velocity 
        }
		else
        {
            U = vector(0, 0, 0);  // Zero velocity 
		}
		// Apply the calculated velocity to each face of the boundary patch
        forAll(this->patch().Cf(), faceI)
        {
            operator[](faceI) = U;
        }
    #};
    }
    bottom
    {
        type            noSlip;
    }
    leftAndright
    {
        type            noSlip;
    }
    frontAndBack
    {
        type            empty;
    }
}

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