/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  plus                                  |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       pointScalarField;
    location    "0";
    object      pointMotionU;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField   uniform 0;

boundaryField
{
    roof
    {
        type            uniformFixedValue;
        uniformValue    constant 0;
    }

    outlet
    {
        type            uniformFixedValue;
        uniformValue    constant 0;
    }

    "(bottom.*)"
    {
        // type            uniformFixedValue;
        // uniformValue    constant -3.947e-8;
        name        descendingLiquidVelocity;
        type        codedFixedValue;
      
        codeInclude
        #{
            #include "fvCFD.H"
        #};

        codeOptions
        #{
            -I$(LIB_SRC)/finiteVolume/lnInclude \
            -I$(LIB_SRC)/meshTools/lnInclude
        #};

        code
        #{
            const scalar rho_V = 128.1975*16.0429e-3;
            const scalar rho_L =  2.6205e4*16.0429e-3;
            // Access to the inlet patch velocity
            const pointMesh& mesh = patch().boundaryMesh().mesh(); // Reading the mesh from the volVectorField
            const volVectorField& U = mesh.thisDb().objectRegistry::lookupObject<volVectorField>("U");
            label interface_1 = mesh.boundary().findPatchID("bottom_1");
            const fvPatchField<Vector<double>>& U_in = U.boundaryField()[interface_1];
            const vector v_in = max(U_in);
            const scalar v_L = - v_in.y() * rho_V/rho_L; 
            Info << "Label 1" << interface_1 << endl;
            Info << "v_L = " << v_L << endl;
            operator==(v_L);
            
        #};
        value    $internalField;
    }


    tank_wall
    {
        type            slip;
    }

    valve_wall
    {
        type            uniformFixedValue;
        uniformValue    constant 0;
    }

    "(wedge.*)"
    {
        type            wedge;
    }

}

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