/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1912                                 |
|   \\  /    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
        {
            consistent yes;
            nIters 1000;
            residualControl
            {
                "p.*"       1.e-5;
                "U.*"       1.e-5;
            }
            averaging
            {
                average     true;
                startIter   500;
            }
        }
    }
}

adjointManagers
{
    adjManager1
    {
        primalSolver             op1;
        adjointSolvers
        {
            adjS1
            {
                // choose adjoint solver
                //----------------------
                active                 true;
                type                   incompressible;
                solver                 adjointSimple;

                // manage objectives
                //------------------
                objectives
                {
                    type incompressible;
                    objectiveNames
                    {
                        drag
                        {
                            weight     1.;
                            type       force;
                            patches    ("motorBike.*");
                            direction  (1 0 0);
                            Aref       0.75;
                            rhoInf     1;
                            UInf       20;
                        }
                    }
                }
                // ATC treatment
                //--------------
                ATCModel
                {
                    ATCModel          standard;
                    extraConvection   0;
                    nSmooth           1;
                    zeroATCPatchTypes (wall patch);
                    maskType          pointCells;
                }
                // solution control
                //------------------
                solutionControls
                {
                    consistent yes;
                    nIters 1000;
                    residualControl
                    {
                        "pa.*"       1.e-5;
                        "Ua.*"       1.e-5;
                    }
                }
            }
        }
    }
}


optimisation
{
    optimisationType
    {
        type             shapeOptimisation;
        writeEachMesh    true;
    }
    sensitivities
    {
        type     volumetricBSplinesFI;
        patches  (motorBikeGroup);
    }
    updateMethod
    {
        method conjugateGradient;
        lineSearch
        {
            type    ArmijoConditions;
        }
        //eta 1; //optional
    }
    meshMovement
    {
        type                   volumetricBSplines;
        maxAllowedDisplacement 2.e-3;
    }
}

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