sidex = 50.000000;
sidey = 50.000000;

numRows = 10.000000;
numCols = 6.000000;

rowSpace = 10.000000;
colSpace = 15.000000;

firstCentre = {-40.000000, -45.000000};
first_pt = {-41.000000, -43.267949};
second_pt = {-36.535898, -43.000000};
third_pt = {-39.000000, -46.732051};
fourth_pt = {-43.464102, -47.000000};
major_axis_pt1 = {-38.267949, -44.000000};
major_axis_pt2 = {-41.732051, -46.000000};
sidex = 50.000000;
sidey = 50.000000;
numRows = 10.000000;
numCols = 6.000000;
rowSpace = 10.000000;
colSpace = 15.000000;
firstCentre = {-40.000000, -45.000000};
first_pt = {-41.000000, -43.267949};
second_pt = {-36.535898, -43.000000};
third_pt = {-39.000000, -46.732051};
fourth_pt = {-43.464102, -47.000000};
major_axis_pt1 = {-38.267949, -44.000000};
major_axis_pt2 = {-41.732051, -46.000000};


// Characteristic length variables
cl1 = 10;
cl2 = 1;

// Create the rectangle
Point(1) = {-sidex, -sidey, 0, cl1}; // {x,y,z,mesh size}
Point(2) = { sidex, -sidey, 0, cl1};
Point(3) = { sidex,  sidey, 0, cl1};
Point(4) = {-sidex,  sidey, 0, cl1};

Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};

Line Loop(1) = {1, 2, 3, 4};

pointIndex = 5;
lineIndex  = 5;
loopIndex  = 2;
iRow = 1;
For ( 1 : numRows )
  iCol = 1;
  For ( 1 : numCols )

    xTrans = (iCol - 1) * colSpace;
    yTrans = (iRow - 1) * rowSpace;
    
    centre[] = {firstCentre(0) + xTrans, firstCentre(1) + yTrans};
    first_pt_trans[]  = {first_pt(0) + xTrans, first_pt(1) + yTrans};
    second_pt_trans[] = {second_pt(0) + xTrans, second_pt(1) + yTrans};
    third_pt_trans[]  = {third_pt(0) + xTrans, third_pt(1) + yTrans};
    fourth_pt_trans[] = {fourth_pt(0) + xTrans, fourth_pt(1) + yTrans};
    major_axis_pt1_trans[] = {major_axis_pt1(0) + xTrans, major_axis_pt1(1) + yTrans};
    major_axis_pt2_trans[] = {major_axis_pt2(0) + xTrans, major_axis_pt2(1) + yTrans};

    // Create points on hole circumference
    Point(pointIndex)   = {centre(0), centre(1), 0, cl2};     // Hole centre
    Point(pointIndex+1) = {first_pt_trans(0), first_pt_trans(1), 0, cl2};  
    Point(pointIndex+2) = {second_pt_trans(0), second_pt_trans(1), 0, cl2};
    Point(pointIndex+3) = {third_pt_trans(0), third_pt_trans(1), 0, cl2};  
    Point(pointIndex+4) = {fourth_pt_trans(0), fourth_pt_trans(1), 0, cl2};
    Point(pointIndex+5) = {major_axis_pt1_trans(0), major_axis_pt1_trans(1), 0, cl2};  // Major axis point
    Point(pointIndex+6) = {major_axis_pt2_trans(0), major_axis_pt2_trans(1), 0, cl2};  // Major axis point

    // Create arcs
    Ellipse(lineIndex)   = {pointIndex+1,pointIndex, pointIndex+5,pointIndex+2};
    Ellipse(lineIndex+1) = {pointIndex+2,pointIndex, pointIndex+5,pointIndex+3};
    Ellipse(lineIndex+2) = {pointIndex+3,pointIndex, pointIndex+6,pointIndex+4};
    Ellipse(lineIndex+3) = {pointIndex+4,pointIndex, pointIndex+6,pointIndex+1};

    Line Loop(loopIndex) = {lineIndex,lineIndex+1,lineIndex+2,lineIndex+3};

    pointIndex += 7;
    lineIndex  += 4;
    loopIndex  += 1;
    iCol += 1;
  EndFor
  iRow += 1;
EndFor

Plane Surface(1) = {1:loopIndex-1};
Recombine Surface {1};

Physical Line("LeftEdge") = {1, 4};
Physical Line("BottomEdge") = {1, 2};
Physical Line("TopEdge") = {3, 4};
Physical Line("RightEdge") = {2, 3};
Physical Line("AllEdges") = {1, 2, 3, 4};
Physical Surface("AllNodes") = {1};

Mesh.CharacteristicLengthFromCurvature = 1;
Mesh.SaveGroupsOfNodes = 1;