/*--------------------------------*- C++ -*----------------------------------*\
  Ahmed body drag optimisation with DAFoam - cloudHPC tutorial
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      snappyHexMeshDict;
}
castellatedMesh true;
snap            true;
addLayers       true;

geometry
{
    body.stl
    {
        type triSurfaceMesh;
        name body;
        // two STL solids -> two patches: only bodyRear is deformed
        regions { bodyFront { name bodyFront; } bodyRear { name bodyRear; } }
    }
    nearBody { type searchableBox; min (-0.15 0.0 0.0); max (1.60 0.35 0.50); }
    wake     { type searchableBox; min (-0.40 0.0 0.0); max (3.00 0.60 0.75); }
}

castellatedMeshControls
{
    features ( { file "body.eMesh"; level 5; } );
    refinementSurfaces { body { level (4 4); patchInfo { type wall; } } }
    refinementRegions
    {
        nearBody { mode inside; levels ((1e15 3)); }
        wake     { mode inside; levels ((1e15 2)); }
    }
    locationInMesh (3.0 0.9 1.0);
    maxLocalCells 20000000;
    maxGlobalCells 50000000;
    minRefinementCells 0;
    nCellsBetweenLevels 3;
    resolveFeatureAngle 30;
    allowFreeStandingZoneFaces true;
    maxLoadUnbalance 0.10;
}

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

addLayersControls
{
    relativeSizes true;
    layers { "body.*" { nSurfaceLayers 3; } }
    expansionRatio 1.3;
    finalLayerThickness 0.4;
    minThickness 0.05;
    nGrow 0;
    featureAngle 130;
    slipFeatureAngle 80;
    nRelaxIter 5;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedialAxisAngle 90;
    nBufferCellsNoExtrude 0;
    nLayerIter 50;
    nRelaxedIter 20;
}

meshQualityControls
{
    maxNonOrtho 60;
    maxBoundarySkewness 4;
    maxInternalSkewness 4;
    maxConcave 80;
    minVol 1e-13;
    minTetQuality 1e-15;
    minArea -1;
    minTwist 0.03;
    minDeterminant 0.01;
    minFaceWeight 0.05;
    minVolRatio 0.01;
    minTriangleTwist -1;
    nSmoothScale 4;
    errorReduction 0.75;
    relaxed { maxNonOrtho 65; }
}

mergeTolerance 1e-6;
