angle = 20;

Point(1) = {0, 0, 0, 1.0};
Point(2) = {10, 0, 0, 1.0};
Point(3) = {10, 10, 0, 1.0};
Point(4) = {0, 10, 0, 1.0};
Line (1) = {1, 2};
Line (2) = {2, 3};
Line (3) = {3, 4};
Line (4) = {4, 1};

Point(11) = {2, 5, 0, 1.0};
Point(21) = {5, 2, 0, 1.0};
Point(31) = {8, 5, 0, 1.0};
Point(41) = {5, 8, 0, 1.0};
Line (11) = {11, 21};
Line (21) = {21, 31};
Line (31) = {31, 41};
Line (41) = {41, 11};

// subdivide exterior surface

Line(44) = {41,3};
Line(45) = {31,2};
Line(46) = {21,1};
Line(47) = {11,4};
Line Loop(42) = {41,11,21,31};
Plane Surface(43) = {42};
Line Loop(48) = {3,-47,-41,44};
Plane Surface(49) = {48};
Line Loop(50) = {47,4,-46,-11};
Plane Surface(51) = {50};
Line Loop(52) = {46,1,-45,-21};
Plane Surface(53) = {52};
Line Loop(54) = {45,2,-44,-31};
Plane Surface(55) = {54};

// define transfinite/elliptic mesh constraints
Transfinite Line{1:4,11,21,31,41,44:47} = 10;
Elliptic Surface {49} = {11,41,3,4};
Elliptic Surface {51} = {1,21,11,4};
Elliptic Surface {53} = {21,1,2,31};
Elliptic Surface {55} = {31,2,3,41};
Elliptic Surface {43} = {11,21,31,41};

// use quads instead of triangles
Recombine Surface{49,51,53,55,43};

// rotate the center square
Rotate { {0.0,0,1},{5,5,0.0}, -Pi/4 + angle * Pi/180} { 
  Surface{43};
}
