Code: Select all
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};
< /code>
Dies funktioniert einwandfrei. In der Python -API kann ich jedoch nicht die Funktion gmsh.model.mesh.setperiodic ()
Dies ist mein Skript: < /p>
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()
< /code>
Wie kann ich eine periodische Zeile mit der GMSH -Python -API erstellen? Vorzugsweise ohne eine Affinetransform von einer Zeile zur anderen herauszufinden, obwohl ich das bei Bedarf tun kann.