/*--------------------------------*- 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  45;

obstacleBottom    0.8;
obstacleThickness 0.005;

// Factor - size of mid square
f  0.5;
fe 0.42;

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

// Number of cells
radialCells   10;
axialTopCells 60;
axialMidCells 1;
axialBotCells 80;

// Cell grading
radialGrading    1;
axialTopGrading  1;
axialBotGrading  1;

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

// Derived parameters

xi  #calc "$x0 + ($radius*$f)";
yi  #calc "$y0 + ($radius*$f)";
xe  #calc "$x0 + ($radius*$fe)";
ye  #calc "$y0 + ($radius*$fe)";
xx  #calc "$x0 + ($radius*cos(degToRad($angle)))";
yy  #calc "$y0 + ($radius*sin(degToRad($angle)))";     // arc points blocks 0, 2
xa  #calc "$x0 + ($radius*cos(degToRad($angle*0.5)))";
ya  #calc "$y0 + ($radius*sin(degToRad($angle*0.5)))"; // arc points block 1
xb  #calc "$x0 + ($radius*cos(degToRad($angle*1.5)))";
yb  #calc "$y0 + ($radius*sin(degToRad($angle*1.5)))";
zmb #calc "$z0 + $obstacleBottom";
zmt #calc "$zmb + $obstacleThickness";
zl  #calc "$z0 + $length";
r   $radius;
xeN #neg $xe;
xiN #neg $xi;
xaN #neg $xa;
xbN #neg $xb;
xxN #neg $xx;
rN  #neg $r;

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

vertices
(
    //Plane A (Bottom):
    ( $xi    0    $z0) // pt 0
    ( $xe   $ye   $z0) // pt 1
    (  0    $yi   $z0) // pt 2
    ( $xeN  $ye   $z0) // pt 3
    ( $xiN   0    $z0) // pt 4
    (  0     0    $z0) // pt 5
    (  $r    0    $z0) // pt 6
    ( $xx   $yy   $z0) // pt 7
    (  0    $r    $z0) // pt 8
    ( $xxN  $yy   $z0) // pt 9
    (  $rN   0    $z0) // pt 10

    //Plane B (Mid bottom):
    ( $xi    0    $zmb) // pt 11
    ( $xe   $ye   $zmb) // pt 12
    (  0    $yi   $zmb) // pt 13
    ( $xeN  $ye   $zmb) // pt 14
    ( $xiN   0    $zmb) // pt 15
    (  0     0    $zmb) // pt 16
    (  $r    0    $zmb) // pt 17
    ( $xx   $yy   $zmb) // pt 18
    (  0    $r    $zmb) // pt 19
    ( $xxN  $yy   $zmb) // pt 20
    ( $rN    0    $zmb) // pt 21

    //Plane C (Mid top):
    ( $xi    0    $zmt) // pt 22
    ( $xe   $ye   $zmt) // pt 23
    (  0    $yi   $zmt) // pt 24
    ( $xeN  $ye   $zmt) // pt 25
    ( $xiN   0    $zmt) // pt 26
    (  0     0    $zmt) // pt 27
    (  $r    0    $zmt) // pt 28
    ( $xx   $yy   $zmt) // pt 29
    (  0    $r    $zmt) // pt 30
    ( $xxN  $yy   $zmt) // pt 31
    (  $rN   0    $zmt) // pt 32

    //Plane D (Top):
    ( $xi    0    $zl) // pt 33
    ( $xe   $ye   $zl) // pt 34
    (  0    $yi   $zl) // pt 35
    ( $xeN  $ye   $zl) // pt 36
    ( $xiN   0    $zl) // pt 37
    (  0     0    $zl) // pt 38
    (  $r    0    $zl) // pt 39
    ( $xx   $yy   $zl) // pt 40
    (  0    $r    $zl) // pt 41
    ( $xxN  $yy   $zl) // pt 42
    (  $rN   0    $zl) // pt 43
);

blocks
(
    //Blocks between plane A and plane B:
    // block0 - positive x inner O-grid block
    hex ( 0  1  2  5 11 12 13 16)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // block1 - negative x inner O-grid block
    hex ( 5  2  3  4 16 13 14 15)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // block2 - positive x outer O-grid block
    hex ( 0  6  7  1 11 17 18 12)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // block3 - positive y outer right O-grid block
    hex ( 1  7  8  2 12 18 19 13)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // block4 - positive y outer left O-grid block
    hex ( 2  8  9  3 13 19 20 14)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)
    // block5 - negative x outer O-grid block
    hex ( 4  3  9 10 15 14 20 21)
    ($radialCells $radialCells $axialBotCells)
    simpleGrading (1 1 $axialBotGrading)

    //Blocks between plane B and plane C:
    // block0 - positive x inner O-grid block
    hex (16 11 12 13 27 22 23 24)
    ($radialCells $radialCells $axialMidCells)
    simpleGrading (1 1 1)
    // block1 - positive x outer O-grid block
    hex (11 17 18 12 22 28 29 23)
    ($radialCells $radialCells $axialMidCells)
    simpleGrading (1 1 1)
    // block2 - positive y outer O-grid block
    hex (13 12 18 19 24 23 29 30)
    ($radialCells $radialCells $axialMidCells)
    simpleGrading (1 1 1)

    //Blocks between plane C and plane D:
    // block0 - positive x inner O-grid block
    hex (27 22 23 24 38 33 34 35)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
    // block1 - negative x inner O-grid block
    hex (26 27 24 25 37 38 35 36)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
    // block2 - positive x outer O-grid block
    hex (22 28 29 23 33 39 40 34)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
    // block3 - positive y outer right O-grid block
    hex (24 23 29 30 35 34 40 41)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
    // block4 - positive y outer left O-grid block
    hex (25 24 30 31 36 35 41 42)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
    // block5 - negative x outer O-grid block
    hex (32 26 25 31 43 37 36 42)
    ($radialCells $radialCells $axialTopCells)
    simpleGrading (1 1 $axialTopGrading)
);

edges
(
    //Plane A:
    arc 6 7    ( $xa  $ya $z0)
    arc 7 8    ( $xb  $yb $z0)
    arc 8 9    ( $xbN $yb $z0)
    arc 9 10   ( $xaN $ya $z0)

    //Plane B:
    arc 17 18  ( $xa  $ya $zmb)
    arc 18 19  ( $xb  $yb $zmb)
    arc 19 20  ( $xbN $yb $zmb)
    arc 20 21  ( $xaN $ya $zmb)

    //Plane C:
    arc 28 29  ( $xa  $ya $zmt)
    arc 29 30  ( $xb  $yb $zmt)
    arc 30 31  ( $xbN $yb $zmt)
    arc 31 32  ( $xaN $ya $zmt)

    //Plane D:
    arc 39 40  ( $xa  $ya $zl)
    arc 40 41  ( $xb  $yb $zl)
    arc 41 42  ( $xbN $yb $zl)
    arc 42 43  ( $xaN $ya $zl)
);

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

    outlet
    {
    type        patch;
    faces
    (
        (38 33 34 35)
        (37 38 35 36)
        (33 39 40 34)
        (35 34 40 41)
        (36 35 41 42)
        (43 37 36 42)
    );
    }

    symmetry
    {
    type        symmetryPlane;
    faces
    (
    // Bottom block
        ( 5  0 11 16)
        ( 0  6 17 11)
        (10  4 15 21)
        ( 4  5 16 15)
    // Mid block
        (16 11 22 27)
        (11 17 28 22)
    // Top block
        (27 22 33 38)
        (22 28 39 33)
        (32 26 37 43)
        (26 27 38 37)
    );
    }

    walls
    {
    type        wall;
    faces
    (
    // Bottom block
        ( 6  7 18 17)
        ( 7  8 19 18)
        ( 8  9 20 19)
        ( 9 10 21 20)
    //  Mid block
        (17 18 29 28)
        (18 19 30 29)
        (19 13 24 30)
        (13 16 27 24)
    // Top block
        (28 29 40 39)
        (29 30 41 40)
        (30 31 42 41)
        (31 32 43 42)
    // Obstacle bottom
        (15 16 13 14)
        (14 13 19 20)
        (21 15 14 20)
    // Obstacle top
        (26 27 24 25)
        (25 24 30 31)
        (32 26 25 31)
    );
    }
);

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