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

castellatedMesh true;
snap            true;
addLayers       true;

geometry
{
    uav.stl
    {
        type triSurfaceMesh;
        name uav;
    }

    refinementBoxNear
    {
        type box;
        min  (-1 -1 0);
        max  ( 2  1  1.8);
    }

    refinementBoxWake
    {
        type box;
        min  ( 0 -0.5 0); 
        max  ( 2  0.5  0.5); 
    }
}

castellatedMeshControls
{
    maxLocalCells    4000000;  
    maxGlobalCells   15000000; 
    minRefinementCells 5;
    maxLoadUnbalance 0.10;

    nCellsBetweenLevels 3;

    features
    (
        {
            file "uav.eMesh";
            level 5;
        }
    );

    refinementSurfaces
    {
        uav
        {
            level (6 7);
            patchInfo
            {
                type wall;
                inGroups (uavGroup);
            }
        }
    }

    resolveFeatureAngle 30;

    refinementRegions
    {
        refinementBoxNear
        {
            mode inside;
            levels ((1E15 3)); 
        }
        refinementBoxWake
        {
            mode inside;
            levels ((1E15 5));
        }
    }

    locationInMesh (5 0 3);
    allowFreeStandingZoneFaces true;
}

snapControls
{
    nSmoothPatch 3;
    tolerance 2.0;
    nSolveIter 100; 
    nRelaxIter 5;
    nFeatureSnapIter 10;
    implicitFeatureSnap false;
    explicitFeatureSnap true;
    multiRegionFeatureSnap false;
}

addLayersControls
{
    relativeSizes false; 

    layers
    {
        uav 
        {
            nSurfaceLayers 10;
        }
    }

    firstLayerThickness 1.8e-5; 
    expansionRatio 1.3;
    minThickness 1e-7;
    nGrow 0;
    featureAngle 60;
    slipFeatureAngle 30;
    nRelaxIter 3;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedialAxisAngle 90;
    nBufferCellsNoExtrude 0;
    nLayerIter 100; 
}

meshQualityControls
{
    #includeEtc "caseDicts/meshQualityDict"

    minFaceWeight 0.02;
    nSmoothScale 4;
    errorReduction 0.75;
}

writeFlags
(
    // scalarLevels
    // layerSets
    // layerFields
);

mergeTolerance 1e-6;

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