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

application     interFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         30;

deltaT          0.001;

writeControl    adjustableRunTime;

writeInterval   1;

purgeWrite      0;

writeFormat     binary;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo           0.5;
maxAlphaCo      0.1;

maxDeltaT       1;

functions
{

water_in_domain
{
    type            volFieldValue;
    libs ("libfieldFunctionObjects.so");
    enabled         true;

    //writeControl     outputTime;
    writeControl   timeStep;
    writeInterval  1;

    log             true;

    writeFields     false;

    select      all;

    operation       volIntegrate;

    fields
    (
        alpha.water
    );
}

gamma
{
    name gamma;
    type coded;
    libs            ("libutilityFunctionObjects.so");
    writeControl    writeTime;
    executeControl  writeTime;

    code
    #{
    #};

    codeExecute
    #{
        const volVectorField& U
        (
            mesh().lookupObject<volVectorField>("U")
        );

        volScalarField strainRate
        (
            IOobject
            (
                "strainRate",
                mesh().time().timeName(),
                mesh(),
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            sqrt(2.0)*mag(symm(fvc::grad(U)))
        );

       strainRate.write();
    #};
}

flowRate_outlet
{
    type            surfaceFieldValue;
    libs            ("libfieldFunctionObjects.so");
    writeControl    timeStep;
    log             true;
    writeFields     false;
    regionType      patch;
    name            outlet;
    operation       sum;

    fields
    (
        phi
    );
}

}

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