/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  13
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 1.0;

rHub            0.02;   // Radius of the rotor hub
rRotorTip       0.05;   // Radius of the rotor blade tips
rMid            0.06;   // Radius of the midpoint between rotor and stator
rStatorTip      0.07;   // Radius of the stator blade tips
rVessel         0.1;    // Radius of the outer vessel wall

halfDepth       0.005;  // Half-depth of the 2-D slab

nCellsRootTip   12;     // Number of cells radially along the blades
nCellsMid       4;      // Number of cells radially across the mid section (/2)
nCellsBladeBlade 12;    // Number of cells tangentially between blades (/2)

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

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

    code
    #{
        const pointField points0
        ({
            point(-$rVessel,    0, -$halfDepth),
            point(-$rVessel,    0, -$halfDepth),
            point(-$rStatorTip, 0, -$halfDepth),
            point(-$rMid,       0, -$halfDepth),
            point(-$rRotorTip,  0, -$halfDepth),
            point(-$rHub,       0, -$halfDepth),
            point(-$rHub,       0, -$halfDepth),
        });

        pointField points;
        for (label i = 0; i < 8; i++)
        {
            points.append(transform(Rz(degToRad(i*45)), points0));
        }
        points.append(points + vector(0, 0, 2*$halfDepth));

        os  << points;
    #};
};

bladeBlock ($nCellsBladeBlade $nCellsRootTip 1) simpleGrading (1 1 1);
midBlock ($nCellsBladeBlade $nCellsMid 1) simpleGrading (1 1 1);

blocks
(
    hex (0 8 9 2 56 64 65 58) stator $bladeBlock
    hex (2 9 10 3 58 65 66 59) stator $midBlock
    hex (3 10 11 4 59 66 67 60) rotor $midBlock
    hex (4 11 12 5 60 67 68 61) rotor $bladeBlock

    hex (7 14 16 9 63 70 72 65) stator $bladeBlock
    hex (9 16 17 10 65 72 73 66) stator $midBlock
    hex (10 17 18 11 66 73 74 67) rotor $midBlock
    hex (11 18 20 12 67 74 76 68) rotor $bladeBlock

    hex (14 22 23 16 70 78 79 72) stator $bladeBlock
    hex (16 23 24 17 72 79 80 73) stator $midBlock
    hex (17 24 25 18 73 80 81 74) rotor $midBlock
    hex (18 25 26 19 74 81 82 75) rotor $bladeBlock

    hex (21 28 30 23 77 84 86 79) stator $bladeBlock
    hex (23 30 31 24 79 86 87 80) stator $midBlock
    hex (24 31 32 25 80 87 88 81) rotor $midBlock
    hex (25 32 34 26 81 88 90 82) rotor $bladeBlock

    hex (28 36 37 30 84 92 93 86) stator $bladeBlock
    hex (30 37 38 31 86 93 94 87) stator $midBlock
    hex (31 38 39 32 87 94 95 88) rotor $midBlock
    hex (32 39 40 33 88 95 96 89) rotor $bladeBlock

    hex (35 42 44 37 91 98 100 93) stator $bladeBlock
    hex (37 44 45 38 93 100 101 94) stator $midBlock
    hex (38 45 46 39 94 101 102 95) rotor $midBlock
    hex (39 46 48 40 95 102 104 96) rotor $bladeBlock

    hex (42 50 51 44 98 106 107 100) stator $bladeBlock
    hex (44 51 52 45 100 107 108 101) stator $midBlock
    hex (45 52 53 46 101 108 109 102) rotor $midBlock
    hex (46 53 54 47 102 109 110 103) rotor $bladeBlock

    hex (49 0 2 51 105 56 58 107) stator $bladeBlock
    hex (51 2 3 52 107 58 59 108) stator $midBlock
    hex (52 3 4 53 108 59 60 109) rotor $midBlock
    hex (53 4 6 54 109 60 62 110) rotor $bladeBlock
);

arc 45 (0 0 1);

edges
(
    arc 0 8 $arc
    arc 7 14 $arc
    arc 14 22 $arc
    arc 21 28 $arc
    arc 28 36 $arc
    arc 35 42 $arc
    arc 42 50 $arc
    arc 49 0 $arc
    arc 56 64 $arc
    arc 63 70 $arc
    arc 70 78 $arc
    arc 77 84 $arc
    arc 84 92 $arc
    arc 91 98 $arc
    arc 98 106 $arc
    arc 105 56 $arc

    arc 2 9 $arc
    arc 9 16 $arc
    arc 16 23 $arc
    arc 23 30 $arc
    arc 30 37 $arc
    arc 37 44 $arc
    arc 44 51 $arc
    arc 51 2 $arc
    arc 58 65 $arc
    arc 65 72 $arc
    arc 72 79 $arc
    arc 79 86 $arc
    arc 86 93 $arc
    arc 93 100 $arc
    arc 100 107 $arc
    arc 107 58 $arc

    arc 3 10 $arc
    arc 10 17 $arc
    arc 17 24 $arc
    arc 24 31 $arc
    arc 31 38 $arc
    arc 38 45 $arc
    arc 45 52 $arc
    arc 52 3 $arc
    arc 59 66 $arc
    arc 66 73 $arc
    arc 73 80 $arc
    arc 80 87 $arc
    arc 87 94 $arc
    arc 94 101 $arc
    arc 101 108 $arc
    arc 108 59 $arc

    arc 4 11 $arc
    arc 11 18 $arc
    arc 18 25 $arc
    arc 25 32 $arc
    arc 32 39 $arc
    arc 39 46 $arc
    arc 46 53 $arc
    arc 53 4 $arc
    arc 60 67 $arc
    arc 67 74 $arc
    arc 74 81 $arc
    arc 81 88 $arc
    arc 88 95 $arc
    arc 95 102 $arc
    arc 102 109 $arc
    arc 109 60 $arc

    arc 5 12 $arc
    arc 12 20 $arc
    arc 19 26 $arc
    arc 26 34 $arc
    arc 33 40 $arc
    arc 40 48 $arc
    arc 47 54 $arc
    arc 54 6 $arc
    arc 61 68 $arc
    arc 68 76 $arc
    arc 75 82 $arc
    arc 82 90 $arc
    arc 89 96 $arc
    arc 96 104 $arc
    arc 103 110 $arc
    arc 110 62 $arc
);

defaultPatch
{
    name walls;
    type wall;
}

boundary
(
    rotor
    {
        type wall;
        faces
        (
            (5 61 68 12)
            (12 68 76 20)
            (19 75 82 26)
            (26 82 90 34)
            (33 89 96 40)
            (40 96 104 48)
            (47 103 110 54)
            (54 110 62 6)

            (4 60 62 6)
            (18 74 76 20)
            (32 88 90 34)
            (46 102 104 48)
            (4 5 61 60)
            (18 19 75 74)
            (32 33 89 88)
            (46 47 103 102)
        );
    }
    stator
    {
        type wall;
        faces
        (
            (0 8 64 56)
            (7 14 70 63)
            (14 22 78 70)
            (21 28 84 77)
            (28 36 92 84)
            (35 42 98 91)
            (42 50 106 98)
            (49 0 56 105)

            (8 64 65 9)
            (22 78 79 23)
            (36 92 93 37)
            (50 106 107 51)
            (7 9 65 63)
            (21 23 79 77)
            (35 37 93 91)
            (49 51 107 105)
        );
    }
    front
    {
        type empty;
        faces
        (
            (56 58 65 64)
            (63 65 72 70)
            (70 72 79 78)
            (77 79 86 84)
            (84 86 93 92)
            (91 93 100 98)
            (98 100 107 106)
            (105 107 58 56)

            (58 59 66 65)
            (65 66 73 72)
            (72 73 80 79)
            (79 80 87 86)
            (86 87 94 93)
            (93 94 101 100)
            (100 101 108 107)
            (107 108 59 58)

            (59 60 67 66)
            (66 67 74 73)
            (73 74 81 80)
            (80 81 88 87)
            (87 88 95 94)
            (94 95 102 101)
            (101 102 109 108)
            (108 109 60 59)

            (60 61 68 67)
            (67 68 76 74)
            (74 75 82 81)
            (81 82 90 88)
            (88 89 96 95)
            (95 96 104 102)
            (102 103 110 109)
            (109 110 62 60)
        );
    }
    back
    {
        type empty;
        faces
        (
            (0 2 9 8)
            (7 9 16 14)
            (14 16 23 22)
            (21 23 30 28)
            (28 30 37 36)
            (35 37 44 42)
            (42 44 51 50)
            (49 51 2 0)

            (2 3 10 9)
            (9 10 17 16)
            (16 17 24 23)
            (23 24 31 30)
            (30 31 38 37)
            (37 38 45 44)
            (44 45 52 51)
            (51 52 3 2)

            (3 4 11 10)
            (10 11 18 17)
            (17 18 25 24)
            (24 25 32 31)
            (31 32 39 38)
            (38 39 46 45)
            (45 46 53 52)
            (52 53 4 3)

            (4 5 12 11)
            (11 12 20 18)
            (18 19 26 25)
            (25 26 34 32)
            (32 33 40 39)
            (39 40 48 46)
            (46 47 54 53)
            (53 54 6 4)
        );
    }
);


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