Using the Gmsh Python api with OpenCASCADE, I'm trying to create a periodic mesh, such that the left boundary matches the right one and the top matches the bottom. A .geo file works fine, but gmsh.model.mesh.setPeriodic() does not seem to work in the Gmsh Python api. When specifying a .geo file, I just use Periodic Line {1} = {-3}; as follows: SetFactory("OpenCASCADE"); // Define points (different meshSizes to check periodicity) Point(1) = {0, 0, 0, 0.005}; Point(2) = {1, 0, 0, 0.05}; Point(3) = {1, 1, 0, 0.2}; Point(4) = {0, 1, 0, 0.2}; // Define lines Line(1) = {1, 2}; Line(2) = {2, 3}; Line(3) = {3, 4}; Line(4) = {4, 1}; // Define line loop, turn into surface Line Loop(1) = {1, 2, 3, 4}; Plane Surface(1) = {1}; // Define periodic boundaries Periodic Line {1} = {-3}; Periodic Line {2} = {-4}; This works fine. However, in the Python api, I cannot get the function gmsh.model.mesh.setPeriodic() to work the same way. It gives an error that 'affineTransform' must be specified (which should not be necessary for a periodic line), but even if I try to specify the affineTransform as an identity matrix or actually as a translation from top to bottom or left to right, it still does not work. This is my script: import gmsh gmsh.initialize() gmsh.model.add("example") # Define points (different meshSizes to check periodicity) points = [ gmsh.model.occ.addPoint(0, 0, 0, 0.005), gmsh.model.occ.addPoint(1, 0, 0, 0.05), gmsh.model.occ.addPoint(1, 1, 0, 0.2), gmsh.model.occ.addPoint(0, 1, 0, 0.2), ] # Define lines lines = [ gmsh.model.occ.addLine(points[0], points[1]), gmsh.model.occ.addLine(points[1], points[2]), gmsh.model.occ.addLine(points[2], points[3]), gmsh.model.occ.addLine(points[3], points[0]) ] # Create line loop, turn into a surface line_loop = gmsh.model.occ.addCurveLoop(lines) plane_surface = gmsh.model.occ.addPlaneSurface([line_loop]) # Set the periodic boundary conditions gmsh.model.mesh.setPeriodic(1, lines[0:1], [-lines[2]]) gmsh.model.mesh.setPeriodic(1, lines[1:2], [-lines[3]]) # Generate mesh of dim 2 gmsh.model.mesh.generate(2) # Write mesh to file gmsh.write(r"example.msh") # Launch the GUI to see the results: gmsh.fltk.run() # Finalize Gmsh gmsh.finalize() How can I create a periodic line using the gmsh Python api? Preferably without having to figure out an affineTransform from one line to another, although if necessary I can do that. Continue reading...