Periodische Linie in GMSH Python API: Affinetransform benötigt?Python

Python-Programme
Anonymous
 Periodische Linie in GMSH Python API: Affinetransform benötigt?

Post by Anonymous »

Verwendung der GMSH -Python -API mit OpenCascade versuche ich, ein periodisches Netz zu erstellen, so dass die linke Grenze mit der rechten und der Oberseite dem Boden entspricht. A .Geo-Datei funktioniert einwandfrei, aber GMSH.Model.mesh.setPeriodic () scheint in der GMSH-Python-API nicht zu funktionieren. wie folgt: < /p>

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 () 
auf die gleiche Weise arbeiten. Es gibt einen Fehler, dass 'Affinetransform' angegeben werden muss (was für eine periodische Zeile nicht erforderlich sein sollte), aber selbst wenn ich versuche, die Affinetransform als Identitätsmatrix oder tatsächlich als Übersetzung von oben nach unten oder links nach rechts anzugeben, funktioniert es immer noch nicht.
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.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post