/*--------------------------------*- 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;
    location    "system";
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

factor  1.5;

// Cells
thetaCells  #calc "int(floor($factor*12))";     // multiple of 6

diskCells   #calc "int(floor($factor*6))";
spgCells    1;
bldCells    #calc "int(floor($diskCells*0.8))"; // 0.5 for uniform
mrfCells    $diskCells;                         // same as disk for uniform
vslCells    #calc "int(floor($diskCells*2))";   // 2 for uniform

zCells      #calc "int(floor($factor*164))";

// Tank
D        0.48;
H        1.724;
R        #calc "0.5*$D";

// Rushton radius
r        #calc "0.4*$R";

//Shaft
rshft    #calc "0.132*$r";

//Sparger
rspg     #calc "0.526*$r";

// Blades
rbld     #calc "0.496*$r";       // from center to the blade
rdisk    #calc "0.75*$r";        // disk radius
rzone    #calc "1.5*$r";         // radius of rotating zone

// 45 degs
rsqrt2   #calc "1.0 / sqrt(2.0)";
rshft45  #calc "$rsqrt2*$rshft";
rspg45   #calc "$rsqrt2*$rspg";
rbld45   #calc "$rsqrt2*$rbld";
rdisk45  #calc "$rsqrt2*$rdisk";
r45      #calc "$rsqrt2*$r";
rzone45  #calc "$rsqrt2*$rzone";
R45      #calc "$rsqrt2*$R";

convertToMeters 1;

vertices
(
    (0        0        0)       //0
    ($rshft   0        0)       //1
    ($rspg    0        0)       //2
    ($rbld    0        0)       //3
    ($rdisk   0        0)       //4
    ($r       0        0)       //5
    ($rzone   0        0)       //6
    ($R       0        0)       //7
    (0        $rshft   0)       //8
    ($rshft45 $rshft45 0)       //9
    (0        $rspg    0)       //10
    ($rspg45  $rspg45  0)       //11
    (0        $rbld    0)       //12
    ($rbld45  $rbld45  0)       //13
    (0        $rdisk   0)       //14
    ($rdisk45 $rdisk45 0)       //15
    (0        $r       0)       //16
    ($r45     $r45     0)       //17
    (0        $rzone   0)       //18
    ($rzone45 $rzone45 0)       //19
    (0        $R       0)       //20
    ($R45     $R45     0)       //21

    (0        0        $H)      //22
    ($rshft   0        $H)      //23
    ($rspg    0        $H)      //24
    ($rbld    0        $H)      //25
    ($rdisk   0        $H)      //26
    ($r       0        $H)      //27
    ($rzone   0        $H)      //28
    ($R       0        $H)      //29
    (0        $rshft   $H)      //30
    ($rshft45 $rshft45 $H)      //31
    (0        $rspg    $H)      //32
    ($rspg45  $rspg45  $H)      //33
    (0        $rbld    $H)      //34
    ($rbld45  $rbld45  $H)      //35
    (0        $rdisk   $H)      //36
    ($rdisk45 $rdisk45 $H)      //37
    (0        $r       $H)      //38
    ($r45     $r45     $H)      //39
    (0        $rzone   $H)      //40
    ($rzone45 $rzone45 $H)      //41
    (0        $R       $H)      //42
    ($R45     $R45     $H)      //43
);

// Grading
zGrd    ((0.10 0.10 1) (0.36 0.53 1) (0.54 0.37 1));
r1Grd   ((0.3 0.45 2) (0.4 0.2 1) (0.3 0.35 0.5));
r2Grd   ((0.25 0.25 3) (0.25 0.25 0.33) (0.25 0.25 3) (0.25 0.25 0.33));

rotatingGrd  simpleGrading (1 1 $zGrd);
bladeGrd     simpleGrading ($r1Grd 1 $zGrd);
baffleGrd    simpleGrading ($r2Grd 1 $zGrd);

blocks
(
    hex (1 3 13 9 23 25 35 31)    ($diskCells $thetaCells $zCells) $rotatingGrd
    hex (9 13 12 8 31 35 34 30)   ($diskCells $thetaCells $zCells) $rotatingGrd

    hex (3 2 11 13 25 24 33 35)   ($spgCells $thetaCells $zCells) $rotatingGrd
    hex (13 11 10 12 35 33 32 34) ($spgCells $thetaCells $zCells) $rotatingGrd

    hex (2 4 15 11 24 26 37 33)   ($bldCells $thetaCells $zCells) $rotatingGrd
    hex (11 15 14 10 33 37 36 32) ($bldCells $thetaCells $zCells) $rotatingGrd

    hex (4 5 17 15 26 27 39 37)   ($bldCells $thetaCells $zCells) $rotatingGrd
    hex (15 17 16 14 37 39 38 36) ($bldCells $thetaCells $zCells) $rotatingGrd

    hex (5 6 19 17 27 28 41 39)   ($mrfCells $thetaCells $zCells) $bladeGrd
    hex (17 19 18 16 39 41 40 38) ($mrfCells $thetaCells $zCells) $bladeGrd

    hex (6 7 21 19 28 29 43 41)   ($vslCells $thetaCells $zCells) $baffleGrd
    hex (19 21 20 18 41 43 42 40) ($vslCells $thetaCells $zCells) $baffleGrd
);

curve 45 (0 0 1);

edges
(
    // Shaft
    arc 1  9  $curve
    arc 9  8  $curve
    arc 23 31 $curve
    arc 31 30 $curve

    //Sparger
    arc 2  11 $curve
    arc 11 10 $curve
    arc 24 33 $curve
    arc 33 32 $curve

    // Stirrer
    arc 3  13 $curve
    arc 13 12 $curve
    arc 25 35 $curve
    arc 35 34 $curve

    arc 4  15 $curve
    arc 15 14 $curve
    arc 26 37 $curve
    arc 37 36 $curve

    arc 5  17 $curve
    arc 17 16 $curve
    arc 27 39 $curve
    arc 39 38 $curve

    arc 6  19 $curve
    arc 19 18 $curve
    arc 28 41 $curve
    arc 41 40 $curve

    // Outer wall
    arc 7  21 $curve
    arc 21 20 $curve
    arc 29 43 $curve
    arc 43 42 $curve
);

defaultPatch
{
    name tank;
    type wall;
}

boundary
(
    outlet
    {
        type patch;
        faces
        (
          (23 25 35 31)
          (31 35 34 30)

          (25 24 33 35)
          (35 33 32 34)

          (24 26 37 33)
          (33 37 36 32)

          (26 27 39 37)
          (37 39 38 36)

          (27 28 41 39)
          (39 41 40 38)

          (28 29 43 41)
          (41 43 42 40)
        );
    }

    shaft
    {
        type wall;
        faces
        (
            (1  9  31 23)
            (9  8  30 31)
        );
    }

    symmetry
    {
        type patch;
        faces
        (
            (12 8  30 34)
            (10 12 34 32)
            (14 10 32 36)
            (16 14 36 38)
            (18 16 38 40)
            (20 18 40 42)
        );
    }
);

mergePatchPairs
(
);

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