/*--------------------------------*- 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      optimisationDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

optimisationManager steadyOptimisation;

primalSolvers
{
    op1
    {
        active                 true;
        type                   incompressible;
        solver                 simple;
        solutionControls
        {
            nIters 300;
            consistent true;
            residualControl
            {
                "p.*"       1.e-6;
                "U.*"       1.e-6;
            }
        }
    }
}

adjointManagers
{
    adjManager1
    {
        primalSolver             op1;
        adjointSolvers
        {
            as1
            {
                // choose adjoint solver
                //----------------------
                active                 true;
                type                   incompressible;
                solver                 adjointSimple;
                isConstraint           true;
                // manage objectives
                //------------------
                objectives
                {
                    type  incompressible;
                    objectiveNames
                    {
                        losses
                        {
                            weight          1.; 
                            type            PtLosses;
                            patches         ("inlet.*" "outlet.*");
                            normalise       true;
                            target          0.778;
                            normFactor      0.778;
                        }
                    }
                }
                // ATC treatment
                //--------------
                ATCModel
                {
                    ATCModel        standard;
                }
                // solution control
                //------------------
                solutionControls
                {
                    nIters 300;
                    consistent true;
                    residualControl
                    {
                        "pa.*"       1.e-6;
                        "Ua.*"       1.e-6;
                    }
                }
            }
            uniformity
            {
                // choose adjoint solver
                //----------------------
                active                 true;
                type                   incompressible;
                solver                 adjointSimple;
                // manage objectives
                //------------------
                objectives
                {
                    type  incompressible;
                    objectiveNames
                    {
                        uniformity
                        {
                            weight            1.; 
                            type              uniformityPatch;
                            patches           (outlet1 outlet2);
                            normalise         true;
                        }
                    }
                }
                // ATC treatment
                //--------------
                ATCModel
                {
                    ATCModel        standard;
                }
                // solution control
                //------------------
                solutionControls
                {
                    nIters 300;
                    consistent true;
                    residualControl
                    {
                        "pa.*"       1.e-6;
                        "Ua.*"       1.e-6;
                    }
                }
            }
            vol
            {
                // choose adjoint solver
                //----------------------
                active                 true;
                type                   null;
                isConstraint           true;
                // manage objectives
                //------------------
                objectives
                {
                    type  geometric;
                    objectiveNames
                    {
                        vol
                        {
                            weight          1.; 
                            type            topOVolume;
                            percentage      0.1;
                        }
                    }
                }
            }
            mass
            {
                // choose adjoint solver
                //----------------------
                active                 true;
                type                   incompressible;
                solver                 adjointSimple;
                isConstraint           true;
                // manage objectives
                //------------------
                objectives
                {
                    type  incompressible;
                    objectiveNames
                    {
                        mass
                        {
                            weight            1.; 
                            type              flowRatePartition;
                            inletPatches      (inlet);
                            outletPatches     (outlet1 outlet2);
                            targetFractions   (0.5 0.5);
                            normalise         true;
                            target            1.e-5;
                        }
                    }
                }
                // ATC treatment
                //--------------
                ATCModel
                {
                    ATCModel        standard;
                }
                // solution control
                //------------------
                solutionControls
                {
                    nIters 300;
                    consistent true;
                    residualControl
                    {
                        "pa.*"       1.e-6;
                        "Ua.*"       1.e-6;
                    }
                }
            }
        }
    }
}

optimisation
{
    designVariables
    {
        type topO;
        sensitivityType topO;
        regularisation
        {
            regularise     true;
            growFromWalls  true;
          //meanRadiusMult 10;
            radius         0.0380789;
            function       tanh;
            b              20;
        }
        betaMaxType        Darcy;
        DarcyCoeffs
        {
            inletPatches (inlet);
        }
        maxInitChange      0.2;
    }
    updateMethod
    {
        method ISQP;
        targetConstraintReduction 0.2;
        preconditioner ShermanMorrison;
    }
}

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