FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      adjointProperties;
}
/******************************************************************************/

// define cell zones using lists of standard topo-set sources
zones
{
}

// Dictionary for topo opt settings
topology
{
    execution off;
    alpha 1e+3; 

    type   porosityMethod;
    patchBufferCells 0;
    noBlockCells ();
    noGrowWalls ();
    optimizationFrequency 1; 
    porosityMethod
    {
          whichPorosityMethod       steepestDescent;
          hta                       1e+3;
    }  
}



solution
{
    writeAfterFirstIter yes;
    runTimeModification true;
    
    primal
    {
        execution on;
        solver primalIncompressible;
        convergenceCriterion 1e-6;
        maxIterations constant 30;
        initialConvergenceCriterion 1e-4;
        initialMaxIterations 1000;
    }
    
    adjoint
    {
        execution on;
        primal primal; // name of the primal sub-dictionary above
        convergenceCriterion 1e-6;
        maxIterations constant 30;
        initialConvergenceCriterion 1e-4;
        initialMaxIterations 1000;
        maskType none;
                
        objectives
        {
            fdrag
            {
                type forceErrorCorrection;

                weight constant 1;

                forceDirection (1 0 0);
                
                //can be used for all objectives - all patches included by default
                objectivePatches
                {
                    exactNamed
                    (
                    );
                    partialNamed
                    (
                        wing
                    );
                }
            }
            
            /*
            flift
            {
                type force;

                weight constant 1;

                forceDirection (0 1 0);
                
                //can be used for all objectives - all patches included by default
                objectivePatches
                {
                    exactNamed
                    (
                    );
                    partialNamed
                    (
                        wing
                    );
                }
            }
            */
        }
        
        // adjoint solver settings
        fvSolution
        {
            SIMPLE
            {
                adjoint_nNonOrthogonalCorrectors 0;
                paRefCell 0;
                paRefValue 0;
            }
            
            solvers
            {
                pa
                {
                    solver          GAMG;
                    agglomerator    faceAreaPair;
                    mergeLevels     1;
                    cacheAgglomeration true;
                    nCellsInCoarsestLevel 200;
                    tolerance       1e-07;
                    relTol          0.001;
                    smoother        GaussSeidel;
                    nPreSweeps      0;
                    nPostSweeps     2;
                    nFinestSweeps   2;
                }
                Ua
                {
                    solver          smoothSolver;
                    smoother        GaussSeidel;
                    tolerance       1e-06;
                    relTol          0.1;
                }
            }

            relaxationFactors
            {
                fields
                {
                    "pa.*" 0.7;
                }
                equations
                {
                    "Ua.*" 0.3;
                }
            }
        }
        // adjoint fvSchemes settings
        fvSchemes
        {
            divSchemes
            {
                div(-phi,Ua)  Gauss upwind;
            }
            gradSchemes
            {
                UaTranspose Gauss linear;
            }
        }
    }
}



// default boundary conditions for adjoint fields
adjointBoundaryConditions
{
    wall
    {
        pa {type adjointPressure;}
        Ua {type adjointVelocity; value uniform (0 0 0);}
    }

    outlet
    {
        pa {type adjointPressure; value uniform 0;}
        Ua {type adjointVelocity; value uniform (0 0 0);}

    }

    inlet
    {
        pa {type adjointPressure;}
        Ua {type adjointVelocity; value uniform (0 0 0);}

    }

    patch
    {
        pa {type adjointPressure; value uniform 0;}
        Ua {type adjointVelocity; value uniform (0 0 0);}
    }
}

