/*--------------------------------*- C++ -*----------------------------------*\
  ==  == ====== ====   ====    |
                    \\     ||  | Multiphase Code Repository by HZDR
  ======   //   ||  || ===//   | Website: https://doi.org/10.14278/rodare.767
  ||  ||  //    ||  // || \\   | License: GPL-3.0-or-later
  ==  == ====== ====   ==  ==  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// User input

convertToMeters 1;

diameter        0.02;
length          0.5;

bottomElevation 0;

// Inner block properties
squareDiagonalLength 0.01;
arcAngle             20;

// Number of cells for one outer block
azimuthalCells  5;
radialCells     12;
axialCells      8;

// Cell grading
radialGrading   0.5;
axialGrading    1;

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

vertices #codeStream
{
    codeInclude
    #{
        #include "pointField.H"
        #include "transformField.H"
    #};

    code
    #{
        const pointField initPoints
        ({
            point
            (
                $squareDiagonalLength*0.5*cos(degToRad(45)),
                $squareDiagonalLength*0.5*sin(degToRad(45)),
                $bottomElevation
            ),
            point
            (
                $diameter*0.5*cos(degToRad(45)),
                $diameter*0.5*sin(degToRad(45)),
                $bottomElevation
            ),
        });

        pointField points;

        // Rotate points around z-axis and append
        for (label i = 0; i < 4; i++)
        {
            points.append(transform(Rz(degToRad(i*90)), initPoints));
        }

        // Duplicate z points
        points.append(points + vector(0, 0, $bottomElevation + $length));

        os  << points;
    #};
};

blocks
(
    // block0
    hex (0  2  4  6  8  10 12 14)
    ($azimuthalCells $azimuthalCells $axialCells)
    simpleGrading (1   1 $axialGrading)

    // block1
    hex (0  1  3  2  8  9  11 10)
    ($radialCells $azimuthalCells $axialCells)
    simpleGrading ($radialGrading 1 $axialGrading)

    // block2
    hex (2  3  5  4  10 11 13 12)
    ($radialCells $azimuthalCells $axialCells)
    simpleGrading ($radialGrading 1 $axialGrading)

    // block3
    hex (4  5  7  6  12 13 15 14)
    ($radialCells $azimuthalCells $axialCells)
    simpleGrading ($radialGrading 1 $axialGrading)

    // block4
    hex (6  7  1  0  14 15 9  8)
    ($radialCells $azimuthalCells $axialCells)
    simpleGrading ($radialGrading 1 $axialGrading)
);

edges
(
    //Inner square arcs
    arc 0  2  $arcAngle (0 0 1)
    arc 6  0  $arcAngle (0 0 1)
    arc 4  6  $arcAngle (0 0 1)
    arc 2  4  $arcAngle (0 0 1)

    arc 8  10 $arcAngle (0 0 1)
    arc 14 8  $arcAngle (0 0 1)
    arc 12 14 $arcAngle (0 0 1)
    arc 10 12 $arcAngle (0 0 1)

    //Outer circle arcs
    arc 1  3  90        (0 0 1)
    arc 7  1  90        (0 0 1)
    arc 5  7  90        (0 0 1)
    arc 3  5  90        (0 0 1)

    arc 9  11 90        (0 0 1)
    arc 15 9  90        (0 0 1)
    arc 13 15 90        (0 0 1)
    arc 11 13 90        (0 0 1)
);

boundary
(
    inlet
    {
        type    patch;
        faces
        (
            (2  0  6  4 )
            (2  3  1  0 )
            (0  1  7  6 )
            (6  7  5  4 )
            (4  5  3  2 )
        );
    }

    outlet
    {
        type    patch;
        faces
        (
            (10 8  14 12)
            (10 11 9  8 )
            (8  9  15 14)
            (14 15 13 12)
            (12 13 11 10)
        );
    }

    walls
    {
        type    wall;
        faces
        (
            (1  3  11 9 )
            (3  5  13 11)
            (5  7  15 13)
            (7  1  9  15)
        );
    }
);

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