/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.7.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     sedFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         3000;

deltaT          1.e-3;

writeControl    adjustableRunTime;

writeInterval   10;

purgeWrite      0;

writeFormat     binary;

writePrecision  6;

writeCompression false;

timeFormat      general;

timePrecision   6;

runTimeModifiable on;

adjustTimeStep  yes;

maxCo           0.7;

maxAlphaCo      0.3;

maxDeltaT       0.0009;





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


functions
{
    // Mass flow rate calculation for solid velocity (Ua) using phi.a
    inMassFlow_a
    {
        type            surfaceRegion;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl    timeStep;
        writeInterval   1;
        log             true;
        writeFields     false;

        regionType      patch;
        name            inlet;

        operation       sum;
        fields
        (
            phi.a
        );
    }

    outMassFlow_a
    {
        type            surfaceRegion;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl    timeStep;
        writeInterval   1;
        log             true;
        writeFields     false;

        regionType      patch;
        name            outlet;

        operation       sum;
        fields
        (
            phi.a
        );
    }

    // Mass flow rate calculation for fluid velocity (Ub) using phi.b
    inMassFlow_b
    {
        type            surfaceRegion;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl    timeStep;
        writeInterval   1;
        log             true;
        writeFields     false;

        regionType      patch;
        name            inlet;

        operation       sum;
        fields
        (
            phi.b
        );
    }

    outMassFlow_b
    {
        type            surfaceRegion;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl    timeStep;
        writeInterval   1;
        log             true;
        writeFields     false;

        regionType      patch;
        name            outlet;

        operation       sum;
        fields
        (
            phi.b
        );
    }

    // Field averaging function object
    fieldAverage
    {
        type            fieldAverage;
        libs            ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl    outputTime;

        fields
        (
            U.a
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            U.b
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            pa
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p_rbgh
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            nut.b
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            k.b
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            omega.b
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }

    // Forces calculation
    forces_object
    {
        type forces;
        libs            ("libforces.so");
        writeControl    timeStep;
        writeInterval   1;

        patches ("cylinder");

        pName (pa p_rbgh);
        Uname (U.a U.b);

        rho rhoInf;
        rhoInf 1.0;  // Set to your reference density (e.g., fluid density)

        CofR (0 0 0);
    }

    // Force coefficients calculation
    forceCoeffs_object
    {
        type forceCoeffs;
        libs            ("libforces.so");

        patches (cylinder);

        pName (pa p_rbgh);
        Uname (U.a U.b);

        rho rhoInf;            // Reference density
        rhoInf 1;         // Set to your reference density (e.g., fluid density)

        CofR (0.0 0.0 0.0);

        liftDir (0 1 0);
        dragDir (1 0 0);
        pitchAxis (0 0 1);

        magUInf 1.0;
        lRef 1.0;
        Aref 2.0;

        writeControl timeStep;
        writeInterval 1;
        log true;
    }

    // Min/max calculation
    minmaxdomain
    {
        type fieldMinMax;
        libs            ("libfieldFunctionObjects.so");

        enabled true;
        mode component;

        writeControl timeStep;
        writeInterval 1;

        log true;

        fields 
        (
            pa
            p_rbgh
            U.a
            U.b
        );
    }


}















