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

castellatedMesh true;
snap            true;
addLayers       true;

mergeTolerance  1e-6;

geometry
{
    inlet.stl
    {
        type triSurfaceMesh;
        name inlet_surface;
    }
};

castellatedMeshControls
{
    maxLocalCells       20000000;
    maxGlobalCells      20000000;
    minRefinementCells  10;
    nCellsBetweenLevels 3;

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

    resolveFeatureAngle 30;

    refinementSurfaces
    {
        inlet_surface
        {
            level (5 5);
            faceZone inlet_zone;
            cellZone inlet_cellZone;
            cellZoneInside inside; 

            patchInfo
            {
                type patch;
            }
        }
    }

    refinementRegions {}

    locationInMesh (1.5 1.5 1.25);

    allowFreeStandingZoneFaces true;
}

snapControls
{
    nSmoothPatch        3;
    tolerance           1.0;
    nSolveIter          100;
    nRelaxIter          8;
    nFeatureSnapIter    20;
    
    implicitFeatureSnap false; 
    explicitFeatureSnap true;
    multiRegionFeatureSnap false;
 
    projectFirst        true;
}

addLayersControls
{
    relativeSizes       true;
    layers
    {
        "inlet_surface"
        {
            nSurfaceLayers 5; 
        }
    }
    
    expansionRatio      1.2; 
    finalLayerThickness 0.6;
    minThickness        1e-4;
    nBufferCellsNoExtrude 0;   
    nLayerIter           50;   
    nRelaxIter           5; 

    nGrow               0;
    featureAngle        60;
    nSmoothSurfaceNormals 1;
    nSmoothNormals      3;
    nSmoothThickness    10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedianAxisAngle  90;
    errorReduction      0.75;
}

meshQualityControls
{
    maxNonOrtho         75;
    maxBoundarySkewness 20;
    maxInternalSkewness 4;
    maxConcave          80;
    minVol              1e-13;
    minTetQuality       1e-30; 
    minArea             -1;
    minFaceWeight       0.01;
    minVolRatio         0.01;
    minTwist            -1;
    minTriangleTwist    -1;
    minDeterminant      0.001;
    minFaceFlatness     -1;

    errorReduction      0.75;
    nSmoothScale        4;
    nSmoothAlpha        2;
}

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