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

#include        "./parameterMaster"

application     pimpleFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         $endTimeMaster;

deltaT          0.05;

writeControl    timeStep;

writeInterval   2000;  // 2000;

purgeWrite      2;

writeFormat     ascii;

writePrecision  12;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

maxCo           0.9;

libs
(
    "<yourPath>/libflyingActuatorDisk.so"
    "atmosphericModels"
);


functions
{

    funcStartTime         $funcStartTimeMaster;
    funcStopTime          $endTimeMaster;

    // #includeFunc fieldAverage(U, p, prime2Mean = yes)

    vorticity1
    {
        // Mandatory entries (unmodifiable)
        type        vorticity;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           U;
        result          vorticityField;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    div1
    {
        // Mandatory entries (unmodifiable)
        type        div;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           U;
        result          divU;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval $surfaceSamplingIntervalMaster;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    
    div2
    {
        // Mandatory entries (unmodifiable)
        type        div;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           phi;
        result          divphi;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval $surfaceSamplingIntervalMaster;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    
    Q1
    {
        // Mandatory entries
        type            Q;
        libs            (fieldFunctionObjects);

        // Optional (inherited) entries
        field           U;
        result          QField;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    turbulenceFields1
    {
        // Mandatory entries
        type            turbulenceFields;
        libs            (fieldFunctionObjects);

        // Optional (inherited) entries
        field           k;
        result          kSGS;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    yPlus1
    {
        // Mandatory entries (unmodifiable)
        type            yPlus;
        libs            (fieldFunctionObjects);

        // Optional (inherited) entries
        writePrecision  8;
        writeToFile     true;
        useUserTime     true;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  onEnd;
        executeInterval $writeInterval;
        writeControl    onEnd;
        writeInterval   $writeInterval;
    }

    uMAGSqr1
    {
        // Mandatory entries (unmodifiable)
        type        magSqr;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           U;
        result          uMAGSqr;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    writeCellVolumes
    {
        // Mandatory entries (unmodifiable)
        type        writeCellVolumes;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        result          vol;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval $writeInterval;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    multiply1
    {
        // Mandatory entries (unmodifiable)
        type        multiply;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        fields          (U uMAGSqr);
        result          uTimesUMAGSqr;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

/*
    pow2
    {
        // Mandatory entries (unmodifiable)
        type        pow;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           fmm;
        n               1.333;   //4/3;
        scale           1.0;
        offset          0.0;
	    checkDimensions false;
        result          fmm_43;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }
*/

    multiply2
    {
        // Mandatory entries (unmodifiable)
        type        multiply;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        fields          (U p);
        result          uTimesP;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    pow3
    {
        // Mandatory entries (unmodifiable)
        type        pow;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           fmm;
        n               -1.0;
        scale           1.0;
        offset          0.0;
	    checkDimensions false;
        result          fmmInverse;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

    multiply3
    {
        // Mandatory entries (unmodifiable)
        type        multiply;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        fields          (flm fmmInverse);
        result          csSqr;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }

/*    
    grad1
    {
        // Mandatory entries (unmodifiable)
        type        grad;
        libs        (fieldFunctionObjects);

        // Optional (inherited) entries
        field           U;
        result          gradU;
        region          region0;
        enabled         true;
        log             true;
        timeStart       $funcStartTime;
        timeEnd         $funcStopTime;
        executeControl  timeStep;
        executeInterval 1;
        writeControl    timeStep;
        writeInterval   $writeInterval;
    }
*/

    fieldAverage1
    {
        type              fieldAverage;
        libs              (fieldFunctionObjects);
        timeStart         $funcStartTime;
        timeEnd           $funcStopTime;
        //writeControl    //writeTime;
        writeControl      timeStep;
        writeInterval     $writeInterval;

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

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

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

            vorticityField
            {
                mean        on;
                prime2Mean  off;
                base        time;
            }

            QField
            {
                mean        on;
                prime2Mean  off;
                base        time;
            }

            force.disk_12
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

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

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


            turbulenceProperties:k
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }


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

/*
            gradU
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
*/

        );
    }




    planesForAvg
    {
        // Where to load it from
        functionObjectLibs ( "libsampling.so" );

        type            surfaces;
        timeStart       $surfaceSamplingStartMaster;
        timeEnd         $endTimeMaster;

        // Name of the directory for probe data
        writeControl    timeStep;
        writeInterval   $surfaceSamplingIntervalMaster;

        surfaceFormat   vtk;

        formatOptions
        {
            vtk
            {
                legacy    true;
            }
        }
        // Fields to be probed
        fields (
            p
            U
            vorticityField
            nut
           );

        surfaces
        (
            yPlaneForAvg0D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (1205.0 0.0 0.0);
                    normalVector    (0.0 1.0 0.0);
                }
                interpolate  true;
            }


            xPlaneForAvgm2D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (1805.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }

            xPlaneForAvgm1D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (2105.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }


            xPlaneForAvg2D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (3005.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }

            xPlaneForAvg5D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (3905.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }


            xPlaneForAvg8D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (4805.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }

            xPlaneForAvg11D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (5705.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }

        );
    }

    probesInflow
    {
        // Where to load it from
        functionObjectLibs ( "libsampling.so" );

        type            probes;
        timeStart       $funcStartTimeMaster;
        timeEnd         $endTimeMaster;

        // Name of the directory for probe data
        name            probesInflow;
        writeControl    timeStep;
        writeInterval   1;


        // Fields to be probed
        fields (
            p 
            U
            nut 
           );

        probeLocations
        (
            (1805   -150   30)
            (1805   -100   30)
            (1805    -50   30)
            (1805      0   30)
            (1805     50   30)
            (1805    100   30)
            (1805    150   30)

            (1805   -150   80)
            (1805   -100   80)
            (1805    -50   80)
            (1805      0   80)
            (1805     50   80)
            (1805    100   80)
            (1805    150   80)

            (1805   -150  130)
            (1805   -100  130)
            (1805    -50  130)
            (1805      0  130)
            (1805     50  130)
            (1805    100  130)
            (1805    150  130)

            (1805   -150  180)
            (1805   -100  180)
            (1805    -50  180)
            (1805      0  180)
            (1805     50  180)
            (1805    100  180)
            (1805    150  180)

            (1805   -150  230)
            (1805   -100  230)
            (1805    -50  230)
            (1805      0  230)
            (1805     50  230)
            (1805    100  230)
            (1805    150  230)

            (1805   -150   280)
            (1805   -100   280)
            (1805    -50   280)
            (1805      0   280)
            (1805     50   280)
            (1805    100   280)
            (1805    150   280)

            (1805   -150  330)
            (1805   -100  330)
            (1805    -50  330)
            (1805      0  330)
            (1805     50  330)
            (1805    100  330)
            (1805    150  330)
            
        );
    }


}



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