Line{} In Surface {} from .geo - EQUVALENT ?? in .py gmsh.model.mesh.embed not having the same performance
Dear prof. Geuzaine,
I'm trying to lavarge direct Py scripting to produce mesh. I found a difficulty understanding what is .py equivalent for .geo command Line{} In Surface {};.
Could you help me understanding how to achieve the same command in Python?
I've tried >> gmsh.model.mesh.embed(1, [10], 2, 1) but following error keeps popping up "Exception: 1D mesh cannot be divided by 2" on the step >> gmsh.model.mesh.generate().
.geo script
lc=1.00;
//Points
Point(1) = {0,0,0, lc};
Point(2) = {20,0,0, lc/2};
Point(3) = {40,0,0, lc};
Point(4) = {40,15,0, lc};
Point(5) = {0,15,0, lc};
Point(6) = {20.1,0.45,0, lc/2};
Point(7) = {19.9,0.89,0, lc/2};
Point(8) = {20,1.35,0, lc/2};
Point(9) = {20,5,0, lc/2};
//Lines
Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {3,4};
Line(4) = {4,5};
Line(5) = {5,1};
//Lines for Line in surface
Line(6) = {2,6};
Line(7) = {6,7};
Line(8) = {7,8};
Line(9) = {8,9};
Line Loop(10) = {1,2,3,4,5};
Plane Surface(1) = {10};
Line{6,7,8,9} In Surface{1};
Physical Surface(10)={1};
//Mesh properties
Mesh.Algorithm = 8;
Mesh.RecombinationAlgorithm = 2;
Mesh.MeshSizeExtendFromBoundary = 1;
Mesh.MeshSizeFromPoints = 1;
Mesh 2;
RecombineMesh;
Save "Mesh.msh";
.py script
import gmsh
import sys
gmsh.initialize()
lc = 1.00
points = {
1: [0, 0, 0, lc],
2: [20, 0, 0, lc/2],
3: [40, 0, 0, lc],
4: [40, 15, 0, lc],
5: [0, 15, 0, lc],
6: [20.1, 0.45, 0, lc/2],
7: [19.9, 0.89, 0, lc],
8: [20, 1.35, 0, lc],
9: [20, 5, 0, lc],
}
lines = {
1: [1, 2],
2: [2, 3],
3: [3, 4],
4: [4, 5],
5: [5, 1],
6: [2, 6],
7: [6, 7],
8: [7, 8],
9: [8, 9],
}
for i, (x, y, z, lc) in points.items():
gmsh.model.geo.addPoint(x, y, z, meshSize=lc, tag=i)
for i, (p1, p2) in lines.items():grinning:
gmsh.model.geo.addLine(p1, p2, tag=i)
gmsh.model.geo.synchronize()
gmsh.model.geo.addCurveLoop([1, 2, 3, 4, 5], tag=10)
gmsh.model.geo.synchronize()
gmsh.model.geo.addPlaneSurface([10], tag=1)
gmsh.model.geo.synchronize()
gmsh.model.addPhysicalGroup(2, [1], 10)
gmsh.model.geo.synchronize()
gmsh.model.mesh.embed(1, [6,7,8,9], 2, 1)
gmsh.model.geo.synchronize()
gmsh.option.setNumber("Mesh.Algorithm", 8)
gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2)
gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 1)
gmsh.option.setNumber("Mesh.MeshSizeFromPoints", 1)
gmsh.option.setNumber("Mesh.RecombineAll", 1)
gmsh.model.geo.synchronize()
gmsh.model.mesh.generate()
gmsh.write("MEsh.msh")
if 'close' not in sys.argv:
gmsh.fltk.run()
gmsh.finalize()
If you uncomment "gmsh.model.mesh.embed(1, [6,7,8,9], 2, 1)" it works otherwise it returns the error.
Question:
I'm aware of the following from gmsh.py API: "The embedded entities should not intersect each other or be part of the boundary of the entity `inTag', whose mesh will conform to the mesh of the embedded entities." The confusion comes - how so that Line In Surface work while python equivalent code doesn't?
I'm looking forward to your answer!
Best regards, Domagoj Uremovic