/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  14
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      functions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Guide 20 monitors (written by add_monitors.py)
// Planes x = 35 mm (upstream), 60 mm (inside the bed), 85 mm (downstream).

// Volumetric flow rates on the patches [m3/s]: inlet negative, outlet positive.
#includeFunc patchFlowRate(name=inletFlowRate, patch=inlet)
#includeFunc patchFlowRate(name=outletFlowRate, patch=outlet)

// Area-averaged kinematic pressure on the inlet [m2/s2] (outlet is fixed at 0).
#includeFunc patchAverage(name=inletPressure, patch=inlet, p)

// Face values of p: surfaceFieldValue reads volume fields only on boundary faces.
pFace
{
    type            surfaceInterpolate;
    libs            ("libfieldFunctionObjects.so");
    field           p;
    result          pf;
    executeControl  timeStep;
    writeControl    writeTime;
}

pUp
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    writeFields     false;
    writeArea       yes;
    writeNumberOfFaces yes;
    faceZone
    {
        type        plane;
        point       (0.035 0.005 0.001);
        normal      (1 0 0);
    }
    operation       areaAverage;
    fields          (pf);
}

pDown
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    writeFields     false;
    writeArea       yes;
    writeNumberOfFaces yes;
    faceZone
    {
        type        plane;
        point       (0.085 0.005 0.001);
        normal      (1 0 0);
    }
    operation       areaAverage;
    fields          (pf);
}

qUp
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    writeFields     false;
    writeArea       yes;
    writeNumberOfFaces yes;
    faceZone
    {
        type        plane;
        point       (0.035 0.005 0.001);
        normal      (1 0 0);
    }
    operation       orientedSum;
    fields          (phi);
}

qBed
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    writeFields     false;
    writeArea       yes;
    writeNumberOfFaces yes;
    faceZone
    {
        type        plane;
        point       (0.06 0.005 0.001);
        normal      (1 0 0);
    }
    operation       orientedSum;
    fields          (phi);
}

qDown
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    writeFields     false;
    writeArea       yes;
    writeNumberOfFaces yes;
    faceZone
    {
        type        plane;
        point       (0.085 0.005 0.001);
        normal      (1 0 0);
    }
    operation       orientedSum;
    fields          (phi);
}

// Axial profile of p and U on the channel axis and two transverse velocity profiles.
#includeFunc graphUniform(name=centreline, start=(0 0.005 0.001), end=(0.12 0.005 0.001), nPoints=241, axis=x, p, U)
#includeFunc graphUniform(name=profileDuct, start=(0.02 0 0.001), end=(0.02 0.01 0.001), nPoints=101, axis=y, U)
#includeFunc graphUniform(name=profileBed, start=(0.06 0 0.001), end=(0.06 0.01 0.001), nPoints=101, axis=y, U)

// Initial residuals at every time step.
#includeFunc residuals(p, U)

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