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

#include        "./parameterMaster"

application     pimpleFoam;

//startFrom       startTime;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         $endTimeMaster;

deltaT          0.013778915147324;

writeControl    timeStep;

writeInterval   $writeIntervalMaster;

purgeWrite      $purgeWriteMaster;

writeFormat     binary;

writePrecision  12;

writeCompression uncompressed;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

adjustTimeStep  false;

maxCo           0.9;

libs
(
    "<yourPath>/libsurgingTurbinesFoam.so"
);

functions
{ 
    
    funcStartTime         $funcStartMaster;
    funcStopTime          $endTimeMaster;
    interval              $intervalMaster;

    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 $writeInterval;
        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 $writeInterval;
        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;
    }


    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
        fields          Ux;
        result          gradUx;
        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.turbineUp
            {
                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;
            }
            */


        );
    }



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

        type        probes;
        timeStart       $probingStartMaster;
        timeEnd         $probingEndMaster;

        // Name of the directory for probe data
        name        probes;
        writeControl    timeStep;
        writeInterval   $probingIntervalMaster;


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

        probeLocations
        (
            #include "probingLocations_NREL"
        );
    }




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

        type        probes;
        timeStart       $probingStartMaster;
        timeEnd         $probingEndMaster;

        // Name of the directory for probe data
        name        probesHubHeight;
        writeControl    timeStep;
        writeInterval   $probingIntervalMaster;


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

        probeLocations
        (
            #include "probingLocationsStreamHub_NREL"
        );
    }



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

        type            probes;
        timeStart       $probingStartMaster;
        timeEnd         $probingEndMaster;

        // Name of the directory for probe data
        name            probesTip;
        writeControl    timeStep;
        writeInterval   $probingIntervalMaster;


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

        probeLocations
        (
            #include "probingLocationsStreamTip_NREL"
        );
    }


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

        type            probes;
        timeStart       $probingStartMaster;
        timeEnd         $probingEndMaster;

        // Name of the directory for probe data
        name            probesTip;
        writeControl    timeStep;
        writeInterval   $probingIntervalMaster;


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

        probeLocations
        (
            #include "probingLocationsStreamMiddle_NREL"
        );
    }



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

        type            probes;
        timeStart       $probingInflowStartMaster;
        timeEnd         $probingInflowEndMaster;

        // Name of the directory for probe data
        name            probesTip;
        writeControl    timeStep;
        writeInterval   $probingInflowIntervalMaster;


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

        probeLocations
        (
            #include "probingLocationsInflow_NREL"
        );
    }




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

        type            surfaces;
        timeStart       $surfaceStartMaster;
        timeEnd         $surfaceEndMaster;

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

        surfaceFormat   vtk;

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

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

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


            xPlane_m1D
            {
                type        cuttingPlane;
                planeType   pointAndNormal;
                pointAndNormalDict
                {
                    point           (-126.0 0.0 0.0);
                    normalVector    (1.0 0.0 0.0);
                }
                interpolate  true;
            }

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


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


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


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

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


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

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

        );
    }


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

        type            surfaces;
        timeStart       $yPlaneForAvgStartMaster;
        timeEnd         $yPlaneForAvgEndMaster;

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

        surfaceFormat   vtk;

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

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

        );
    }




//    checkingPressure
//    {
//        // Where to load it from
//        functionObjectLibs ( "libsampling.so" );
//
//        type            surfaces;
//        timeStart       $checkPressureStartMaster;
//        timeEnd         $checkPressureEndMaster;
//
//        // Name of the directory for probe data
//        writeControl    timeStep;
//        writeInterval   $checkPressureIntervalMaster;
//
//        surfaceFormat   vtk;
//
//        formatOptions
//        {
//            vtk
//            {
//                legacy    true;
//            }
//        }
//        // Fields to be probed
//        fields (
//            p
//            U
//           );
//
//        surfaces
//        (
//            yPlanePressure
//            {
//                type        cuttingPlane;
//                planeType   pointAndNormal;
//                pointAndNormalDict
//                {
//                    point           (0.0 0.0 0.0);
//                    normalVector    (0.0 1.0 0.0);
//                }
//                interpolate  true;
//            }
//
//        );
//    }

    #include "phaseLockSurfaceSampling"


    //#includeFunc scalarTransport
}


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