/*--------------------------------*- 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 omega = 1;                // oscillation frequency
			const scalar A = 9.66;                 // maximum oscillating speed
			const scalar time = this->db().time().value();   // Current simulation time
			const scalar H = 1;                     // Height or characteristic length
			const scalar tau = (A*time)/H;          // Non-dimensional time
			vector U(A * sin(omega * tau),0,0);   // Velocity vector with sinusoidal variation
			
			// 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;
    }
}

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