x0 = 0;
xBf = 0.2;
z0 = 0;
zBf = 2;
xWf = -2;
zWf = 1;
y0 = x0;
yf = xBf;
lc = 0.1;

NxW = 20; // # elements in x dir in water
NzW = 10;
NxB = 4; // # elements in x dir in beam
NzB = 20;
Ny = NxB;

Point(1) = {x0, z0, y0, lc};
Point(2) = {xBf, z0, y0, lc};
Point(3) = {xBf, zWf, y0, lc};
Point(4) = {xBf, zBf, y0, lc};
Point(5) = {x0, zBf, y0, lc};
Point(6) = {x0, zWf, y0, lc};
Point(7) = {xWf, zWf, y0, lc};
Point(8) = {xWf, z0, y0, lc};

Point(11) = {x0, z0, yf, lc};
Point(12) = {xBf, z0, yf, lc};
Point(13) = {xBf, zWf, yf, lc};
Point(14) = {xBf, zBf, yf, lc};
Point(15) = {x0, zBf, yf, lc};
Point(16) = {x0, zWf, yf, lc};
Point(17) = {xWf, zWf, yf, lc};
Point(18) = {xWf, z0, yf, lc};

Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 5};
Line(5) = {5, 6};
Line(6) = {6, 7};
Line(7) = {7, 8};
Line(8) = {8, 1};
Line(9) = {6, 1};
Line(10) = {3, 6};
Line(11) = {11, 12};
Line(12) = {12, 13};
Line(13) = {13, 14};
Line(14) = {14, 15};
Line(15) = {15, 16};
Line(16) = {16, 17};
Line(17) = {17, 18};
Line(18) = {18, 11};
Line(19) = {16, 11};
Line(20) = {13, 16};
Line(21) = {7, 17};
Line(22) = {8, 18};
Line(23) = {6, 16};
Line(24) = {1, 11};
Line(25) = {2, 12};
Line(26) = {3, 13};
Line(27) = {5, 15};
Line(28) = {4, 14};

Line Loop(12) = {7, 8, -9, 6};
Plane Surface(12) = {12};
Line Loop(14) = {9, 1, 2, 10};
Plane Surface(14) = {14};
Line Loop(16) = {5, -10, 3, 4};
Plane Surface(16) = {16};
Line Loop(30) = {17, 18, -19, 16};
Plane Surface(30) = {30};
Line Loop(32) = {15, -20, 13, 14};
Plane Surface(32) = {32};
Line Loop(34) = {19, 11, 12, 20};
Plane Surface(34) = {34};
Line Loop(36) = {7, 22, -17, -21};
Plane Surface(36) = {36};
Line Loop(38) = {6, 21, -16, -23};
Plane Surface(38) = {38};
Line Loop(40) = {22, 18, -24, -8};
Plane Surface(40) = {40};
Line Loop(42) = {5, 23, -15, -27};
Plane Surface(42) = {42};
Line Loop(44) = {12, -26, -2, 25};
Plane Surface(44) = {44};
Line Loop(46) = {13, -28, -3, 26};
Plane Surface(46) = {46};
Line Loop(48) = {14, -27, -4, 28};
Plane Surface(48) = {48};
Line Loop(50) = {11, -25, -1, 24};
Plane Surface(50) = {50};
Line Loop(52) = {20, -23, -10, 26};
Plane Surface(52) = {52};
Line Loop(54) = {9, 24, -19, -23};
Plane Surface(54) = {54};

Surface Loop(56) = {30, 36, 12, 40, 38, 54};
Volume(56) = {56};
Surface Loop(59) = {42, 16, 46, 32, 48, 52};
Volume(59) = {59};
Surface Loop(61) = {54, 44, 34, 50, 14, 52};
Volume(61) = {61};

Physical Surface(12) = {12};
Physical Surface(14) = {14};
Physical Surface(16) = {16};
Physical Surface(30) = {30};
Physical Surface(32) = {32};
Physical Surface(34) = {34};
Physical Surface(36) = {36};
Physical Surface(38) = {38}; // free surface
Physical Surface(40) = {40};
Physical Surface(42) = {42};
Physical Surface(44) = {44};
Physical Surface(46) = {46};
Physical Surface(48) = {48};
Physical Surface(50) = {50}; // beam bottom
Physical Surface(52) = {52};
Physical Surface(54) = {54}; // interface

Physical Volume(56) = {56};
Physical Volume(59) = {59};
Physical Volume(61) = {61};

Physical Surface(62) = {36, 38, 12, 30, 40, 50, 34, 16, 42, 48, 46, 32, 44, 14}; // total external surface
Physical Volume(63) = {56, 61, 59}; // total volume


Transfinite Line{1, 4, 10} = NxB + 1;
Transfinite Line{2, 7, 9} = NzW + 1;
Transfinite Line{3, 5} = NzB - NzW + 1;
Transfinite Line{6, 8} = NxW + 1;

Transfinite Line{11, 14, 20} = NxB + 1;
Transfinite Line{12, 17, 19} = NzW + 1;
Transfinite Line{13, 15} = NzB - NzW + 1;
Transfinite Line{16, 18} = NxW + 1;

Transfinite Line{21, 22, 23, 24, 25, 26, 27, 28} = Ny + 1;

Transfinite Surface{12, 14, 16, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54};
Transfinite Volume{56, 59, 61};
Recombine Volume{56, 59, 61};
