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

application     interFoam;

startFrom       latestTime;
startTime       0;

stopAt          endTime;
// Hydraulic jump: allow ~5-10 flow-through times to reach statistical steady state
// Domain length = 8 m, U_avg ~ 1-2 m/s => T_flow ~ 4-8 s => run to 20 s
endTime         100;

// interFoam adjusts deltaT to maintain maxCo and maxAlphaCo
deltaT          0.001;          // Initial time step [s]; will be adjusted

writeControl    adjustableRunTime;
writeInterval   0.5;            // Write every 0.1 s of simulation time

purgeWrite      0;              // Keep all time directories (set to 5 to save disk)

writeFormat     binary;         // Faster I/O than ascii; use ascii for debugging
writePrecision  6;
writeCompression off;

timeFormat      general;
timePrecision   6;

runTimeModifiable yes;

// Adaptive time-stepping — critical for interFoam free surface stability
adjustTimeStep  on;
maxCo           0.5;            // Courant number limit for flow
maxAlphaCo      0.5;            // Courant number limit for alpha (VOF)
maxDeltaT       0.01;           // Cap on time step size [s]

// ── Function objects ──────────────────────────────────────────────────────

//functions
//{
    //// Monitor inlet/outlet flow rates and pressure to track hydraulic jump
    //fieldAverage1
    //{
        //type            fieldAverage;
        //libs            (fieldFunctionObjects);
        //writeControl    writeTime;
        //timeStart       10;         // Average only after initial transient
        //fields
        //(
            //U
            //{
                //mean        on;
                //prime2Mean  off;
                //base        time;
            //}
            //alpha.water
            //{
                //mean        on;
                //prime2Mean  off;
                //base        time;
            //}
        //);
    //}

    //// Surface-integrated forces on the weir
    //weirForces
    //{
        //type            forces;
        //libs            (forces);
        //writeControl    timeStep;
        //writeInterval   10;
        //patches         (weir);
        //rho             rhoInf;
        //rhoInf          1000;
        //CofR            (6.05 0 0.05);  // Weir midpoint
    //}

    //// Residuals output for convergence monitoring
    //solverInfo
    //{
        //type            solverInfo;
        //libs            (utilityFunctionObjects);
        //fields          (U p_rgh alpha.water k omega);
        //writeControl    timeStep;
        //writeInterval   1;
    //}
//}

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