/*--------------------------------*- C++ -*----------------------------------*\
  ==  == ====== ====   ====    |
                    \\     ||  | Multiphase Cases Repository by HZDR
  ======   //   ||  || ===//   | Website: https://doi.org/10.14278/rodare.811
  ||  ||  //    ||  // || \\   | License: Creative Commons Attribution 4.0
  ==  == ====== ====   ==  ==  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// User input

convertToMeters 1;

radius 0.0265;
length 1.405;
angle  1.0;

obstacleBottom    0.8;
obstacleThickness 0.005;
obstacleRadius    0.0191;

// Axis origin
x0  0.0;
y0  0.0;
z0 -0.8025;

// Number of cells
radialCells    40;
radialMidCells 29;
axialTopCells  120;
axialMidCells  2;
axialBotCells  160;

// Cell grading
axialTopGrading  3.506627599;
axialBotGrading  0.2849055563;

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

// Derived parameters

xx  #calc "$x0 + ($radius*cos(degToRad($angle*0.5)))";
xo  #calc "$x0 + ($obstacleRadius*cos(degToRad($angle*0.5)))";
yp  #calc "$y0 + ($radius*sin(degToRad($angle*0.5)))";
yop #calc "$y0 + ($obstacleRadius*sin(degToRad($angle*0.5)))";
ym  #neg  $yp;
yom #neg  $yop;
zmb #calc "$z0 + $obstacleBottom";
zmt #calc "$zmb + $obstacleThickness";
zl  #calc "$z0 + $length";

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

vertices
(
    ($x0 $y0  $z0 ) // pt 0
    ($xx $ym  $z0 ) // pt 1
    ($xx $yp  $z0 ) // pt 2
    ($x0 $y0  $z0 ) // pt 3
    ($x0 $y0  $zmb) // pt 4
    ($xx $ym  $zmb) // pt 5
    ($xx $yp  $zmb) // pt 6
    ($x0 $y0  $zmb) // pt 7
    ($xo $yom $zmb) // pt 8
    ($xo $yop $zmb) // pt 9
    ($xo $yom $zmt) // pt 10
    ($xo $yop $zmt) // pt 11
    ($x0 $y0  $zmt) // pt 12
    ($xx $ym  $zmt) // pt 13
    ($xx $yp  $zmt) // pt 14
    ($x0 $y0  $zmt) // pt 15
    ($x0 $y0  $zl ) // pt 16
    ($xx $ym  $zl ) // pt 17
    ($xx $yp  $zl ) // pt 18
    ($x0 $y0  $zl ) // pt 19
);

blocks
(
    // Bottom block
    hex (0  1  2  3  4  5  6  7 )
    ($radialCells 1 $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // Middle block
    hex (4  8  9  7  12 10 11 15)
    ($radialMidCells 1 $axialMidCells)
    simpleGrading (1 1 1)
    // Top block
    hex (12 13 14 15 16 17 18 19)
    ($radialCells 1 $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
);

boundary
(

    inlet
    {
        type patch;
        faces
        (
            (0  3  2  1 )
        );
    }

    outlet
    {
        type patch;
        faces
        (
            (16 17 18 19)
        );
    }

    walls
    {
        type wall;
        faces
        (
            (1  2  6  5 )
            (8  9  11 10)
            (13 14 18 17)
        );
    }

    front
    {
        type wedge;
        faces
        (
            (0  1  5  4 )
            (4  8  10 12)
            (12 13 17 16)
        );
    }

    back
    {
        type wedge;
        faces
        (
            (2  3  7  6 )
            (7  15 11 9 )
            (15 19 18 14)
        );
    }

    axis
    {
        type empty;
        faces
        (
            (0  4  7  3 )
            (4  12 15 7 )
            (12 16 19 15)
        );
    }

    source1
    {
        type wall;
        faces
        (
            (4  7  9  8 )
        );
    }

    target1
    {
        type wall;
        faces
        (
            (7  4  5  6 )
        );
    }

    source2
    {
        type wall;
        faces
        (
            (15 12 10 11)
        );
    }

    target2
    {
        type wall;
        faces
        (
            (12 15 14 13)
        );
    }

);

mergePatchPairs
(
    (source1 target1)
    (source2 target2)
);

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