/*--------------------------------*- C++ -*----------------------------------*\
  Guide 12 - functions file for ONE prepared case (here A_reference, D = 0.01)
  The FoamFile header is required: without it OpenFOAM 14 ignores the file.
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      functions;
}

// Passive dimensionless tracer (keep the D value of the case!)
#includeFunc scalarTransport(C, diffusivity=constant, D = 0.01)

// Inventory I(t) = integral of C over the domain [m3] and extreme values
#includeFunc volIntegrate(C)
#includeFunc cellMin(C)
#includeFunc cellMax(C)

// Advective tracer flow sum(phi*C) [m3/s]: negative at the inlet, positive at the outlet
CflowInlet
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    log             yes;
    writeFields     false;
    patch           inlet;
    operation       sum;
    weightField     phi;
    fields          (C);
}

CflowOutlet
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    log             yes;
    writeFields     false;
    patch           outlet;
    operation       sum;
    weightField     phi;
    fields          (C);
}

// Flow-weighted (cup-mixing) outlet concentration sum(phi*C)/sum(phi)
CbulkOutlet
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    writeInterval   1;
    log             yes;
    writeFields     false;
    patch           outlet;
    operation       average;
    weightField     phi;
    fields          (C);
}

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