/*--------------------------------*- 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       pointVectorField;
    object      pointDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 0 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    fvSurfaceStructure
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        name            dynamicMeshDisplacementBC;
        
        code
        #{
            label patchID = this->patch().index();
            const volScalarField& vF  = this->db().objectRegistry::lookupObject<volScalarField> ("faWVolScalarField");
            
            // interpolate mesh movement to points (vertices)
            primitivePatchInterpolation patchInterpolator(vF.mesh().boundaryMesh()[patchID]);
            scalarField faceValues  = vF.boundaryField()[patchID];
            scalarField pointValues = patchInterpolator.faceToPointInterpolate(faceValues);
            
            // Explicitly reset the interpolated value for points that are also part of the
            // boundary patches
            const labelList& bP = vF.mesh().boundaryMesh()[patchID].boundaryPoints();

            forAll(bP, pointIndex)
            {
                pointValues[bP[pointIndex]] = 0;
            }
            
            operator==(pointValues * vector(0,0,1));    //NOTE: Hard-coded to deform in Z direction!
        #};
            
        codeInclude
        #{
            #include "fvCFD.H"
            #include "primitivePatchInterpolation.H"
        #};

        codeOptions
        #{
            -I$(LIB_SRC)/finiteVolume/lnInclude \
            -I$(LIB_SRC)/meshTools/lnInclude \
            -I$(LIB_SRC)/OpenFOAM/lnInclude
        #};
    }
    
    // no displacement for all other patches
    ".*"
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    
    "fvSymmetryPlane.*"
    {
        type            symmetryPlane;
    }    
    "fvCyclic.*"
    {
        type            cyclic;
    }
}


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