/*--------------------------------*- C++ -*----------------------------------*\
  The background mesh snappyHexMesh carves the geometry out of. Copy this into
  <case>/system/, replace the two marked corners, run blockMesh.
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale   1;          // the STLs are in metres (patches.json says so), so no rescale

// The background box. Nothing can guess it: for an internal flow it is the surface
// bounds grown by a cell or two, for an external one it is a wind-tunnel decision.
//   surfaceCheck constant/triSurface/walls.stl | grep -i 'bounding box'
//   python3 domain_probe.py <case> --suggest
// Keep every face of the geometry strictly inside it, and prefer a box whose faces
// do NOT land exactly on a flat wall of the geometry: a surface coincident with a
// background cell face is the one case snap has no side to choose from.
boxMin  (CHANGE_ME CHANGE_ME CHANGE_ME);
boxMax  (CHANGE_ME CHANGE_ME CHANGE_ME);

// The background cell size. Cubes: snappy halves a cell per refinement level in all
// three directions at once, so a background cell with an aspect ratio carries it into
// every refined cell under it and into the layer on top of that.
dx      0.005;      // metres; refinement level 1 gives 0.0025 at the wall, 2 gives 0.00125

x0 #eval "$[(vector)boxMin].x()";
y0 #eval "$[(vector)boxMin].y()";
z0 #eval "$[(vector)boxMin].z()";
x1 #eval "$[(vector)boxMax].x()";
y1 #eval "$[(vector)boxMax].y()";
z1 #eval "$[(vector)boxMax].z()";

vertices
(
    ($x0 $y0 $z0)
    ($x1 $y0 $z0)
    ($x1 $y1 $z0)
    ($x0 $y1 $z0)
    ($x0 $y0 $z1)
    ($x1 $y0 $z1)
    ($x1 $y1 $z1)
    ($x0 $y1 $z1)
);

blocks
(
    hex (0 1 2 3 4 5 6 7)
    (
        #eval "round(($x1 - $x0)/$dx)"
        #eval "round(($y1 - $y0)/$dx)"
        #eval "round(($z1 - $z0)/$dx)"
    )
    simpleGrading (1 1 1)
);

edges ();

// One patch for the whole background. For an internal flow every face of it is
// carved away and snappy drops the empty patch; for an external flow this is where
// the farfield conditions go, and it is worth splitting into six named patches then.
boundary
(
    background
    {
        type patch;
        faces
        (
            (0 3 2 1) (4 5 6 7) (0 1 5 4) (3 7 6 2) (0 4 7 3) (1 2 6 5)
        );
    }
);

mergePatchPairs ();

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