/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Version:  OpenFoam-9 (commit f8d11b031)
    \  /    A nd           | Upstream: A Wikki Brasil project
     \/     M anipulation  | Version:  v21.12
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application                   upstreamFoam;

startFrom                     latestTime;

startTime                     0;

stopAt                        endTime;

endTime                       300;

deltaT                        1e-5;

writeControl                  adjustableRunTime;

writeInterval                 50;

purgeWrite                    0;

writeFormat                   ascii;

writePrecision                8;

writeCompression              on;

timeFormat                    general;

timePrecision                 6;

runTimeModifiable             yes;

adjustTimeStep                yes;

maxDeltaT                     100;

timeStepControl               relaxLocalCo;
relaxLocalCoCoeffs
{
    relaxFactor     1.0;
    maxCo           1;
}

functions
{
    // outlet flow rate
    Qdot0
    {
        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
    writeControl    timeStep;
    writeInterval   1;
        log             true;
        writeFields     false;
        regionType      patch;
        name            outlet;
        scaleFactor     1;
        operation       sum;
        fields          (alphaPhi.oil alphaPhi.water phi);
    }

    // pressure at inlet (area-averaged) - useful to detect breakthrough
    pressureInlet
    {
        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
    writeControl    timeStep;
    writeInterval   1;
        log             true;
        writeFields     false;
        regionType      patch;
        name            inlet; // change if your inlet patch has a different name
        scaleFactor     1;
        operation       areaAverage;
        fields          (p_rgh);
    }

    // oil volumetric flow at outlet (instantaneous) - integrate in post-processing to get displaced oil volume
    Q_oil_outlet
    {
        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
    writeControl    timeStep;
    writeInterval   1;
        log             true;
        writeFields     false;
        regionType      patch;
        name            outlet; // same outlet patch used by Qdot0
        scaleFactor     1;
        operation       sum;
        fields          (alphaPhi.oil phi);
    }

    // injected volumetric flow at inlet (instantaneous) - integrate in post-processing to get injected volume
    Q_inj_inlet
    {
        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
    writeControl    timeStep;
    writeInterval   1;
        log             true;
        writeFields     false;
        regionType      patch;
        name            inlet; // change if your inlet patch has a different name
        scaleFactor     1;
        operation       sum;
        fields          (alphaPhi.water phi);
    }
}
//************************************************************************** //

