/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM Extend Project: Open Source CFD        |
|  \\    /   O peration     | Version:  v1906                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale   1;

// Domain
axisLevel               0.0;  // x-coord of axis (right boundary of domain)
bottomLevel             -1.0; // y-coord of bottom of domain
topLevel                1.0;  // y-coord of top of domain
farFieldWall            -0.572; // x-coord of far field wall
wedgeAngle              5.0;  // Wedge angle in degrees
// Size of block moving with sphere (no cell deformation), in sphere radii
// above and below centre of sphere
upperSphereBlock        5.0;
lowerSphereBlock        5.0;
sphereLayerThickness    2.0; // Total layer thickness in sphere radii

// Sphere
sphereRadius            0.028;
sphereCentreHeight      0.147; // y-coord of sphere centre

pi                      #calc "Foam::constant::mathematical::pi";

// Calculated positions
sphereRadiusPosition    #calc "-1.0*(1.0 + $sphereLayerThickness)*$sphereRadius"; //"-1.0* $sphereRadius";
AMIBlockPosition        #calc "2.0*$sphereRadiusPosition  + $sphereRadius";
// Centre plane is z=0, so use half of wedge angle to calculate pos and neg
// z-positions
halfAngleRad            #calc "0.5*$wedgeAngle*$pi/180.0";
tanAlpha                #calc "tan($halfAngleRad)";
// Multiply by -1 because tan give negative value
firstBlockPosDepth      #calc "-1.0*$tanAlpha*$sphereRadiusPosition";
firstBlockNegDepth      #calc "-1.0*$firstBlockPosDepth";
AMIBlockPosDepth        #calc "-1.0*$tanAlpha*$AMIBlockPosition";
AMIBlockNegDepth        #calc "-1.0*$AMIBlockPosDepth";
farFieldPosDepth        #calc "-1.0*$tanAlpha*$farFieldWall";
farFieldNegDepth        #calc "-1.0*$farFieldPosDepth";

bottomBlockTopHeight    #calc "$sphereCentreHeight - $lowerSphereBlock*$sphereRadius";
topBlockBottomHeight    #calc "$sphereCentreHeight + $upperSphereBlock*$sphereRadius";

topSphere               #calc "$sphereCentreHeight + $sphereRadius";
bottomSphere            #calc "$sphereCentreHeight - $sphereRadius";
topSphereLayer          #calc "$sphereCentreHeight + (1.0 + $sphereLayerThickness)*$sphereRadius";
bottomSphereLayer       #calc "$sphereCentreHeight - (1.0 + $sphereLayerThickness)*$sphereRadius";

// Layer block below sphere
innerBottomLayerX       #calc "-1.0*cos(45.0*$pi/180.0)*$sphereRadius";
innerBottomLayerY       #calc "$sphereCentreHeight - cos(45.0*$pi/180.0)*$sphereRadius";
innerBottomLayerZPos    #calc "-1.0*$tanAlpha*$innerBottomLayerX";
innerBottomLayerZNeg    #calc "-1.0*$innerBottomLayerZPos";

innerBottomArcX1        #calc "-1.0*sin(22.5*$pi/180.0)*$sphereRadius";
innerBottomArcY1        #calc "$sphereCentreHeight - cos(22.5*$pi/180.0)*$sphereRadius";
innerBottomArcZ1Pos     #calc "$innerBottomArcX1*$tanAlpha";
innerBottomArcZ1Neg     #calc "-1.0*$innerBottomArcZ1Pos";

outerBottomArcX1        #calc "-1.0*sin(22.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)";
outerBottomArcY1        #calc #{ $sphereCentreHeight - cos(22.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness) #};
outerBottomArcZ1Pos     #calc "$outerBottomArcX1*$tanAlpha";
outerBottomArcZ1Neg     #calc "-1.0*$outerBottomArcZ1Pos";

outerBottomLayerX       #calc "-1.0*cos(45.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerBottomLayerY       #calc "$sphereCentreHeight - cos(45.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerBottomLayerZPos    #calc "-1.0*$tanAlpha*$outerBottomLayerX";
outerBottomLayerZNeg    #calc "-1.0*$outerBottomLayerZPos";

// Layer block above sphere
innerTopLayerX          #calc "cos(135.0*$pi/180.0)*$sphereRadius";
innerTopLayerY          #calc "$sphereCentreHeight - cos(135.0*$pi/180.0)*$sphereRadius";
innerTopLayerZPos       #calc "-1.0*$tanAlpha*$innerBottomLayerX";
innerTopLayerZNeg       #calc "-1.0*$innerBottomLayerZPos";

innerTopArcX1           #calc "-1.0*sin(157.5*$pi/180.0)*$sphereRadius";
innerTopArcY1           #calc "$sphereCentreHeight - cos(157.5*$pi/180.0)*$sphereRadius";
innerTopArcZ1Pos        #calc "$innerTopArcX1*$tanAlpha";
innerTopArcZ1Neg        #calc "-1.0*$innerTopArcZ1Pos";

outerTopArcX1           #calc "-1.0*sin(157.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)";
outerTopArcY1           #calc "$sphereCentreHeight - cos(157.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)";
outerTopArcZ1Pos        #calc "$outerTopArcX1*$tanAlpha";
outerTopArcZ1Neg        #calc "-1.0*$outerTopArcZ1Pos";

outerTopLayerX          #calc "cos(135.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerTopLayerY          #calc "$sphereCentreHeight - cos(135.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerTopLayerZPos       #calc "-1.0*$tanAlpha*$outerTopLayerX";
outerTopLayerZNeg       #calc "-1.0*$outerTopLayerZPos";

// Layer block left of sphere
innerLeftArcX           #calc "-1.0*$sphereRadius";
innerLeftArcY           #calc "$sphereCentreHeight";
innerLeftArcZPos        #calc "-1.0*$tanAlpha*$innerLeftArcX";
innerLeftArcZNeg        #calc "-1.0*$innerLeftArcZPos";

outerLeftArcX           #calc "-1.0*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerLeftArcZPos        #calc "-1.0*$tanAlpha*$outerLeftArcX";
outerLeftArcZNeg        #calc "-1.0*$outerLeftArcZPos";



vertices
(
    // Lower moving block
    ($axisLevel            $bottomLevel 0) //  0
    ($axisLevel            $bottomBlockTopHeight 0) // 1
    ($AMIBlockPosition $bottomLevel $AMIBlockPosDepth) //  2
    ($AMIBlockPosition $bottomLevel $AMIBlockNegDepth) //  3
    ($AMIBlockPosition $bottomBlockTopHeight $AMIBlockNegDepth) //  4
    ($AMIBlockPosition $bottomBlockTopHeight $AMIBlockPosDepth) //  5

    // Upper moving block
    ($AMIBlockPosition $topBlockBottomHeight $AMIBlockPosDepth) //  6
    ($AMIBlockPosition $topBlockBottomHeight $AMIBlockNegDepth) //  7
    ($axisLevel            $topBlockBottomHeight 0) //  8
    ($AMIBlockPosition     $topLevel $AMIBlockPosDepth) //  9
    ($AMIBlockPosition     $topLevel $AMIBlockNegDepth) //  10
    ($axisLevel            $topLevel 0) // 11

    // Farfield block
    ($farFieldWall $bottomLevel $farFieldPosDepth) // 12
    ($AMIBlockPosition $bottomLevel $AMIBlockPosDepth) // 13
    ($AMIBlockPosition $topLevel $AMIBlockPosDepth) // 14
    ($farFieldWall $topLevel $farFieldPosDepth) // 15

    ($farFieldWall $bottomLevel $farFieldNegDepth) // 16
    ($AMIBlockPosition $bottomLevel $AMIBlockNegDepth) // 17
    ($AMIBlockPosition $topLevel $AMIBlockNegDepth) // 18
    ($farFieldWall $topLevel $farFieldNegDepth) // 19

    //  Sphere block
    ($axisLevel $bottomSphere 0) // 20
    ($innerBottomLayerX $innerBottomLayerY $innerBottomLayerZPos) // 21
    ($innerBottomLayerX $innerBottomLayerY $innerBottomLayerZNeg) // 22
    ($axisLevel $bottomSphereLayer 0) // 23
    ($outerBottomLayerX $outerBottomLayerY $outerBottomLayerZPos) // 24
    ($outerBottomLayerX $outerBottomLayerY $outerBottomLayerZNeg) // 25

    ($axisLevel $topSphere 0) // 26
    ($axisLevel $topSphereLayer 0) // 27
    ($innerTopLayerX $innerTopLayerY $innerTopLayerZNeg) // 28
    ($outerTopLayerX $outerTopLayerY $outerTopLayerZNeg) // 29
    ($innerTopLayerX $innerTopLayerY $innerTopLayerZPos) // 30
    ($outerTopLayerX $outerTopLayerY $outerTopLayerZPos) // 31
);

edgeNumber 1; // 0.707;

layerGrading 0.5;
invLayerGrading #calc "1.0/$layerGrading";
blockGrading 0.3;
invBlockGrading #calc "1.0/$blockGrading";

blocks
(
    hex (16 17 18 19 12 13 14 15) farField (25 100 1) simplegrading (1 1 1)

    hex (3 0 1 4 2 0 1 5) bottomBlock (10 50 1) simplegrading ($edgeNumber 1 1)

    hex (7 8 11 10 6 8 11 9) topBlock (10 35 1) simplegrading ($edgeNumber 1 1)

    hex (25 23 20 22 24 23 20 21)
    centralBlock (10 20 1)
    edgeGrading
    (
        1 1 1 1
        $layerGrading $layerGrading $layerGrading $layerGrading
        1 1 1 1
    ) // bottom layer

    hex (25 22 28 29 24 21 30 31)
    centralBlock (20 20 1)
    edgeGrading
    (
        $layerGrading $layerGrading $layerGrading $layerGrading
        1 1 1 1
        1 1 1 1
    ) // middle layer

    hex (28 26 27 29 30 26 27 31)
    centralBlock (10 20 1)
    edgeGrading
    (
        1 1 1 1
        $invLayerGrading $invLayerGrading $invLayerGrading $invLayerGrading
        1 1 1 1
    ) // top layer

    hex (4 1 23 25 5 1 23 24)
    centralBlock (10 10 1)
    edgeGrading
    (
        $edgeNumber 1 1 $edgeNumber
        $blockGrading $edgeNumber $edgeNumber $blockGrading
        1 $edgeNumber $edgeNumber 1
    ) // bottom

    hex (4 25 29 7 5 24 31 6)
    centralBlock (10 20 1)
    edgeGrading
    (
        $blockGrading $blockGrading $blockGrading $blockGrading
        1 1 1 1
        1 1 1 1
    ) // middle

    hex (29 27 8 7 31 27 8 6)
    centralBlock (10 10 1)
    edgeGrading
    (
        1 $edgeNumber $edgeNumber 1
        $invBlockGrading $invBlockGrading $invBlockGrading $invBlockGrading
        1 1 1 1
    ) // top
);

edges
(
    // Layer block below sphere
    arc 20 22 ($innerBottomArcX1 $innerBottomArcY1 $innerBottomArcZ1Pos)
    arc 20 21 ($innerBottomArcX1 $innerBottomArcY1 $innerBottomArcZ1Neg)
    arc 23 25 ($outerBottomArcX1 $outerBottomArcY1 $outerBottomArcZ1Pos)
    arc 23 24 ($outerBottomArcX1 $outerBottomArcY1 $outerBottomArcZ1Neg)

    // Layer block above sphere
    arc 26 28 ($innerTopArcX1 $innerTopArcY1 $innerTopArcZ1Pos)
    arc 26 30 ($innerTopArcX1 $innerTopArcY1 $innerTopArcZ1Neg)
    arc 27 29 ($outerTopArcX1 $outerTopArcY1 $outerTopArcZ1Pos)
    arc 27 31 ($outerTopArcX1 $outerTopArcY1 $outerTopArcZ1Neg)

    // Layer block left of sphere
    arc 22 28 ($innerLeftArcX $innerLeftArcY $innerLeftArcZNeg)
    arc 21 30 ($innerLeftArcX $innerLeftArcY $innerLeftArcZPos)
    arc 24 31 ($outerLeftArcX $innerLeftArcY $outerLeftArcZPos)
    arc 25 29 ($outerLeftArcX $innerLeftArcY $outerLeftArcZNeg)
);

boundary
(
    front
    {
        type wedge;
        faces
        (
            (0 1 5 2)
            (5 1 23 24)
            (23 20 21 24)
            (24 21 30 31)
            (5 24 31 6)
            (31 27 8 6)
            (6 8 11 9)
            (31 30 26 27)
            (12 13 14 15)
        );
    }
    back
    {
        type wedge;
        faces
        (
            (0 3 4 1)
            (1 4 25 23)
            (4 7 29 25)
            (23 25 22 20)
            (25 29 28 22)
            (29 7 8 27)
            (28 29 27 26)
            (7 10 11 8)
            (16 17 18 19)
        );
    }
    innerAMI
    {
        type cyclicAMI;
        neighbourPatch outerAMI;
        faces
        (
            (4 5 6 7)
            (6 9 10 7)
            (2 5 4 3)
        );
        transform noOrdering;
    }
    outerAMI
    {
        type cyclicAMI;
        neighbourPatch innerAMI;
        faces
        (
            (14 13 17 18)
        );
        transform noOrdering;
    }
    top
    {
        type wall;
        faces
        (
            (15 14 18 19)
            (9 11 11 10)
        );
    }
    bottom
    {
        type wall;
        faces
        (
            (12 16 17 13)
            (0 2 3 0)
        );
    }
    farFieldWall
    {
        type wall;
        faces
        (
            (12 15 19 16)
        );
    }
    sphere
    {
        type wall;
        faces
        (
            (20 22 21 20)
            (21 22 28 30)
            (30 26 26 28)
        );
    }
);

mergePatchPairs
(
);


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