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

//      X0                                             X1   X2      X3
//
//  Y2  8-----------------------------------------------9----10-----11
//      |                                               |    |       |
//      |                                               |    |       |
//      |                                               |    |       |
//      |                                               |    |       |
//      |                      III                      | IV |   V   |
//      |                                               |    |       |
//      |                                               |    |       |
//      |                                               |    |       |
//      |                                               |    |       |
//  Y1  4-----------------------------------------------5----6-------7
//      |                                               |    |       |
//      |                       I                       |    |  II   |
//      |                                               |    |       |
//  Y0  0-----------------------------------------------1    2-------3
//
//

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

// User input

convertToMeters 1;

// x origin and deltas
x0      0;     // water inlet
dx1     2.04;  // weir
dx2     0.024; // weir end
dx3     0.336; // outlet

// y origin and delta
y0      0;    // bottom wall
dy1     0.06; // weir height
dy2     0.42; // atmosphere

// z origin and delta
z0      0;
z1      0.1;

// Cell size
dx      0.02; // deltaX
toe_fx  0.8;  // factor for toe

dy      0.02; // deltaY
toe_fy  0.6;  // factor for toe

// Number of cells
nz      1;

// Grading
gx      2;
gy      2;

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

// Derived parameters

// calculate block x coordinates starting from left side
x1    #calc "$x0 + $dx1";
x2    #calc "$x1 + $dx2";
x3    #calc "$x2 + $dx3";

// calculate block y coordinates starting from tank bottom
y1    #calc "$y0 + $dy1";
y2    #calc "$y1 + $dy2";

// calculate cells in x direction for each block
nxI    #calc "int($dx1 /($toe_fx*$dx))";
nxII   #calc "int($dx3 /$dx)";
nxIII  $nxI;
nxIV   #calc "int($dx2 /$dx)";
nxV    $nxII;

// calculate cells in y direction for each block
nyI    #calc "int($dy1 /($toe_fy*$dy))";
nyII   $nyI;
nyIII  #calc "int($dy2 /$dy)";
nyIV   $nyIII;
nyV    $nyIII;

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

vertices
(
    ($x0 $y0 $z0) // pt 0
    ($x1 $y0 $z0) // pt 1
    ($x2 $y0 $z0) // pt 2
    ($x3 $y0 $z0) // pt 3
    ($x0 $y1 $z0) // pt 4
    ($x1 $y1 $z0) // pt 5
    ($x2 $y1 $z0) // pt 6
    ($x3 $y1 $z0) // pt 7
    ($x0 $y2 $z0) // pt 8
    ($x1 $y2 $z0) // pt 9
    ($x2 $y2 $z0) // pt 10
    ($x3 $y2 $z0) // pt 11

    ($x0 $y0 $z1) // pt 12
    ($x1 $y0 $z1) // pt 13
    ($x2 $y0 $z1) // pt 14
    ($x3 $y0 $z1) // pt 15
    ($x0 $y1 $z1) // pt 16
    ($x1 $y1 $z1) // pt 17
    ($x2 $y1 $z1) // pt 18
    ($x3 $y1 $z1) // pt 19
    ($x0 $y2 $z1) // pt 20
    ($x1 $y2 $z1) // pt 21
    ($x2 $y2 $z1) // pt 22
    ($x3 $y2 $z1) // pt 23
);

blocks
(
    // Section I
    hex (0  1  5  4  12 13 17 16) ($nxI   $nyI   $nz) simpleGrading ($gx 1   1)
    // Section II
    hex (2  3  7  6  14 15 19 18) ($nxII  $nyII  $nz) simpleGrading (1   1   1)
    // Section III
    hex (4  5  9  8  16 17 21 20) ($nxIII $nyIII $nz) simpleGrading ($gx $gy 1)
    // Section IV
    hex (5  6  10 9  17 18 22 21) ($nxIV  $nyIV  $nz) simpleGrading (1   $gy 1)
    // Section V
    hex (6  7  11 10 18 19 23 22) ($nxV   $nyV   $nz) simpleGrading (1   $gy 1)
);

boundary
(
    leftOutlet
    {
        type patch;
        faces
        (
            (0  12 16 4 )
            (4  16 20 8 )
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 15 19 7 )
            (7 19 23 11)
        );
    }
    atmosphere
    {
        type patch;
        faces
        (
            (8  20 21 9 )
            (9  21 22 10)
            (10 22 23 11)
        );
    }
    walls
    {
        type wall;
        faces
        (
            (0  12 13 1 )
            (1  13 17 5 )
            (5  17 18 6 )
            (6  18 14 2 )
            (2  14 15 3 )
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0  4  5  1 )
            (12 13 17 16)
            (4  8  9  5 )
            (16 17 21 20)
            (5  9  10 6 )
            (17 18 22 21)
            (2  6  7  3 )
            (14 15 19 18)
            (6  10 11 7 )
            (18 19 23 22)
        );
    }
);

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