Skip to content
Snippets Groups Projects
Commit d86ec45a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

pp

parent 20d499de
No related branches found
No related tags found
No related merge requests found
Pipeline #10427 passed
...@@ -44,7 +44,7 @@ gmsh.model.geo.translate([(0, 5)], -0.02, 0, 0) ...@@ -44,7 +44,7 @@ gmsh.model.geo.translate([(0, 5)], -0.02, 0, 0)
# And it can be further rotated by -Pi/4 around (0, 0.3, 0) (with the rotation # And it can be further rotated by -Pi/4 around (0, 0.3, 0) (with the rotation
# along the z axis) with: # along the z axis) with:
gmsh.model.geo.rotate([(0, 5)], 0,0.3,0, 0,0,1, -pi/4) gmsh.model.geo.rotate([(0, 5)], 0, 0.3, 0, 0, 0, 1, -pi / 4)
# Note that there are no units in Gmsh: coordinates are just numbers - it's # Note that there are no units in Gmsh: coordinates are just numbers - it's
# up to the user to associate a meaning to them. # up to the user to associate a meaning to them.
...@@ -59,7 +59,7 @@ gmsh.model.geo.translate(ov, 0, 0.05, 0) ...@@ -59,7 +59,7 @@ gmsh.model.geo.translate(ov, 0, 0.05, 0)
# lines: # lines:
gmsh.model.geo.addLine(3, ov[1][2], 7) gmsh.model.geo.addLine(3, ov[1][2], 7)
gmsh.model.geo.addLine(ov[1][2], 5, 8) gmsh.model.geo.addLine(ov[1][2], 5, 8)
gmsh.model.geo.addCurveLoop([5,-8,-7,3], 10) gmsh.model.geo.addCurveLoop([5, -8, -7, 3], 10)
gmsh.model.geo.addPlaneSurface([10], 11) gmsh.model.geo.addPlaneSurface([10], 11)
# In the same way, we can translate copies of the two surfaces 1 and 11 to the # In the same way, we can translate copies of the two surfaces 1 and 11 to the
...@@ -117,8 +117,8 @@ ov2 = gmsh.model.geo.extrude([ov[2]], 0, 0, 0.12) ...@@ -117,8 +117,8 @@ ov2 = gmsh.model.geo.extrude([ov[2]], 0, 0, 0.12)
# Mesh sizes associated to geometrical points can be set by passing a vector of # Mesh sizes associated to geometrical points can be set by passing a vector of
# (dim, tag) pairs for the corresponding points: # (dim, tag) pairs for the corresponding points:
gmsh.model.geo.mesh.setSize([(0,103), (0,105), (0,109), (0,102), (0,28), gmsh.model.geo.mesh.setSize([(0, 103), (0, 105), (0, 109), (0, 102), (0, 28),
(0, 24), (0,6), (0,5)], lc * 3) (0, 24), (0, 6), (0, 5)], lc * 3)
# We finish by synchronizing the data from the built-in CAD kernel with the Gmsh # We finish by synchronizing the data from the built-in CAD kernel with the Gmsh
# model: # model:
...@@ -126,7 +126,7 @@ gmsh.model.geo.synchronize() ...@@ -126,7 +126,7 @@ gmsh.model.geo.synchronize()
# We group volumes 129 and 130 in a single physical group with tag `1' and name # We group volumes 129 and 130 in a single physical group with tag `1' and name
# "The volume": # "The volume":
gmsh.model.addPhysicalGroup(3, [129,130], 1, "The volume") gmsh.model.addPhysicalGroup(3, [129, 130], 1, "The volume")
# We finally generate and save the mesh: # We finally generate and save the mesh:
gmsh.model.mesh.generate(3) gmsh.model.mesh.generate(3)
......
...@@ -48,7 +48,7 @@ function createGeometryAndMesh() ...@@ -48,7 +48,7 @@ function createGeometryAndMesh()
# only one layer here, with 7 subdivisions). All rotations are specified by # only one layer here, with 7 subdivisions). All rotations are specified by
# an an axis point (-0.1, 0, 0.1), an axis direction (0, 1, 0), and a # an an axis point (-0.1, 0, 0.1), an axis direction (0, 1, 0), and a
# rotation angle (-Pi/2): # rotation angle (-Pi/2):
ov = gmsh.model.geo.revolve([(2,28)], -0.1,0,0.1, 0,1,0, -pi / 2, [7]) ov = gmsh.model.geo.revolve([(2, 28)], -0.1, 0, 0.1, 0, 1, 0, -pi / 2, [7])
# Using the built-in geometry kernel, only rotations with angles < Pi are # Using the built-in geometry kernel, only rotations with angles < Pi are
# supported. To do a full turn, you will thus need to apply at least 3 # supported. To do a full turn, you will thus need to apply at least 3
......
...@@ -23,78 +23,78 @@ function hypot(a, b) ...@@ -23,78 +23,78 @@ function hypot(a, b)
return sqrt(a * a + b * b) return sqrt(a * a + b * b)
end end
ccos = (-h5*R1 + e2 * hypot(h5, hypot(e2, R1))) / (h5*h5 + e2*e2) ccos = (-h5 * R1 + e2 * hypot(h5, hypot(e2, R1))) / (h5 * h5 + e2 * e2)
ssin = sqrt(1 - ccos*ccos) ssin = sqrt(1 - ccos*ccos)
# We start by defining some points and some lines. To make the code shorter we # We start by defining some points and some lines. To make the code shorter we
# can redefine a namespace: # can redefine a namespace:
factory = gmsh.model.geo factory = gmsh.model.geo
factory.addPoint(-e1-e2, 0 , 0, Lc1, 1) factory.addPoint(-e1 - e2, 0, 0, Lc1, 1)
factory.addPoint(-e1-e2, h1 , 0, Lc1, 2) factory.addPoint(-e1 - e2, h1, 0, Lc1, 2)
factory.addPoint(-e3-r , h1 , 0, Lc2, 3) factory.addPoint(-e3 - r, h1, 0, Lc2, 3)
factory.addPoint(-e3-r , h1+r , 0, Lc2, 4) factory.addPoint(-e3 - r, h1 + r, 0, Lc2, 4)
factory.addPoint(-e3 , h1+r , 0, Lc2, 5) factory.addPoint(-e3, h1 + r, 0, Lc2, 5)
factory.addPoint(-e3 , h1+h2, 0, Lc1, 6) factory.addPoint(-e3, h1 + h2, 0, Lc1, 6)
factory.addPoint( e3 , h1+h2, 0, Lc1, 7) factory.addPoint(e3, h1 + h2, 0, Lc1, 7)
factory.addPoint( e3 , h1+r , 0, Lc2, 8) factory.addPoint(e3, h1 + r, 0, Lc2, 8)
factory.addPoint( e3+r , h1+r , 0, Lc2, 9) factory.addPoint(e3 + r, h1 + r, 0, Lc2, 9)
factory.addPoint( e3+r , h1 , 0, Lc2, 10) factory.addPoint(e3 + r, h1, 0, Lc2, 10)
factory.addPoint( e1+e2, h1 , 0, Lc1, 11) factory.addPoint(e1 + e2, h1, 0, Lc1, 11)
factory.addPoint( e1+e2, 0 , 0, Lc1, 12) factory.addPoint(e1 + e2, 0, 0, Lc1, 12)
factory.addPoint( e2 , 0 , 0, Lc1, 13) factory.addPoint(e2, 0, 0, Lc1, 13)
factory.addPoint( R1 / ssin, h5+R1*ccos, 0, Lc2, 14) factory.addPoint(R1 / ssin, h5 + R1 * ccos, 0, Lc2, 14)
factory.addPoint( 0 , h5 , 0, Lc2, 15) factory.addPoint(0, h5, 0, Lc2, 15)
factory.addPoint(-R1 / ssin, h5+R1*ccos, 0, Lc2, 16) factory.addPoint(-R1 / ssin, h5 + R1 * ccos, 0, Lc2, 16)
factory.addPoint(-e2 , 0.0 , 0, Lc1, 17) factory.addPoint(-e2, 0.0, 0, Lc1, 17)
factory.addPoint(-R2 , h1+h3 , 0, Lc2, 18) factory.addPoint(-R2, h1 + h3, 0, Lc2, 18)
factory.addPoint(-R2 , h1+h3+h4, 0, Lc2, 19) factory.addPoint(-R2, h1 + h3 + h4, 0, Lc2, 19)
factory.addPoint( 0 , h1+h3+h4, 0, Lc2, 20) factory.addPoint(0, h1 + h3 + h4, 0, Lc2, 20)
factory.addPoint( R2 , h1+h3+h4, 0, Lc2, 21) factory.addPoint(R2, h1 + h3 + h4, 0, Lc2, 21)
factory.addPoint( R2 , h1+h3 , 0, Lc2, 22) factory.addPoint(R2, h1 + h3, 0, Lc2, 22)
factory.addPoint( 0 , h1+h3 , 0, Lc2, 23) factory.addPoint(0, h1 + h3, 0, Lc2, 23)
factory.addPoint( 0, h1+h3+h4+R2, 0, Lc2, 24) factory.addPoint(0, h1 + h3 + h4 + R2, 0, Lc2, 24)
factory.addPoint( 0, h1+h3-R2, 0, Lc2, 25) factory.addPoint(0, h1 + h3 - R2, 0, Lc2, 25)
factory.addLine(1 , 17, 1) factory.addLine(1, 17, 1)
factory.addLine(17, 16, 2) factory.addLine(17, 16, 2)
# Gmsh provides other curve primitives than straight lines: splines, B-splines, # Gmsh provides other curve primitives than straight lines: splines, B-splines,
# circle arcs, ellipse arcs, etc. Here we define a new circle arc, starting at # circle arcs, ellipse arcs, etc. Here we define a new circle arc, starting at
# point 14 and ending at point 16, with the circle's center being the point 15: # point 14 and ending at point 16, with the circle's center being the point 15:
factory.addCircleArc(14,15,16, 3) factory.addCircleArc(14, 15, 16, 3)
# Note that, in Gmsh, circle arcs should always be smaller than Pi. The # Note that, in Gmsh, circle arcs should always be smaller than Pi. The
# OpenCASCADE geometry kernel does not have this limitation. # OpenCASCADE geometry kernel does not have this limitation.
# We can then define additional lines and circles, as well as a new surface: # We can then define additional lines and circles, as well as a new surface:
factory.addLine(14,13, 4) factory.addLine(14, 13, 4)
factory.addLine(13,12, 5) factory.addLine(13, 12, 5)
factory.addLine(12,11, 6) factory.addLine(12, 11, 6)
factory.addLine(11,10, 7) factory.addLine(11, 10, 7)
factory.addCircleArc(8,9,10, 8) factory.addCircleArc(8, 9, 10, 8)
factory.addLine(8,7, 9) factory.addLine(8, 7, 9)
factory.addLine(7,6, 10) factory.addLine(7, 6, 10)
factory.addLine(6,5, 11) factory.addLine(6, 5, 11)
factory.addCircleArc(3,4,5, 12) factory.addCircleArc(3, 4, 5, 12)
factory.addLine(3,2, 13) factory.addLine(3, 2, 13)
factory.addLine(2,1, 14) factory.addLine(2, 1, 14)
factory.addLine(18,19, 15) factory.addLine(18, 19, 15)
factory.addCircleArc(21,20,24, 16) factory.addCircleArc(21, 20, 24, 16)
factory.addCircleArc(24,20,19, 17) factory.addCircleArc(24, 20, 19, 17)
factory.addCircleArc(18,23,25, 18) factory.addCircleArc(18, 23, 25, 18)
factory.addCircleArc(25,23,22, 19) factory.addCircleArc(25, 23, 22, 19)
factory.addLine(21,22, 20) factory.addLine(21, 22, 20)
factory.addCurveLoop([17,-15,18,19,-20,16], 21) factory.addCurveLoop([17, -15, 18, 19, -20, 16], 21)
factory.addPlaneSurface([21], 22) factory.addPlaneSurface([21], 22)
# But we still need to define the exterior surface. Since this surface has a # But we still need to define the exterior surface. Since this surface has a
# hole, its definition now requires two curves loops: # hole, its definition now requires two curves loops:
factory.addCurveLoop([11,-12,13,14,1,2,-3,4,5,6,7,-8,9,10], 23) factory.addCurveLoop([11, -12, 13, 14, 1, 2, -3, 4, 5, 6, 7, -8, 9, 10], 23)
factory.addPlaneSurface([23,21], 24) factory.addPlaneSurface([23, 21], 24)
# As a general rule, if a surface has N holes, it is defined by N+1 curve loops: # As a general rule, if a surface has N holes, it is defined by N+1 curve loops:
# the first loop defines the exterior boundary; the other loops define the # the first loop defines the exterior boundary; the other loops define the
......
...@@ -40,50 +40,60 @@ lcar3 = .055 ...@@ -40,50 +40,60 @@ lcar3 = .055
# We proceed by defining some elementary entities describing a truncated cube: # We proceed by defining some elementary entities describing a truncated cube:
gmsh.model.geo.addPoint(0.5,0.5,0.5, lcar2, 1) gmsh.model.geo.addPoint(0.5, 0.5, 0.5, lcar2, 1)
gmsh.model.geo.addPoint(0.5,0.5,0, lcar1, 2) gmsh.model.geo.addPoint(0.5, 0.5, 0, lcar1, 2)
gmsh.model.geo.addPoint(0,0.5,0.5, lcar1, 3) gmsh.model.geo.addPoint(0, 0.5, 0.5, lcar1, 3)
gmsh.model.geo.addPoint(0,0,0.5, lcar1, 4) gmsh.model.geo.addPoint(0, 0, 0.5, lcar1, 4)
gmsh.model.geo.addPoint(0.5,0,0.5, lcar1, 5) gmsh.model.geo.addPoint(0.5, 0, 0.5, lcar1, 5)
gmsh.model.geo.addPoint(0.5,0,0, lcar1, 6) gmsh.model.geo.addPoint(0.5, 0, 0, lcar1, 6)
gmsh.model.geo.addPoint(0,0.5,0, lcar1, 7) gmsh.model.geo.addPoint(0, 0.5, 0, lcar1, 7)
gmsh.model.geo.addPoint(0,1,0, lcar1, 8) gmsh.model.geo.addPoint(0, 1, 0, lcar1, 8)
gmsh.model.geo.addPoint(1,1,0, lcar1, 9) gmsh.model.geo.addPoint(1, 1, 0, lcar1, 9)
gmsh.model.geo.addPoint(0,0,1, lcar1, 10) gmsh.model.geo.addPoint(0, 0, 1, lcar1, 10)
gmsh.model.geo.addPoint(0,1,1, lcar1, 11) gmsh.model.geo.addPoint(0, 1, 1, lcar1, 11)
gmsh.model.geo.addPoint(1,1,1, lcar1, 12) gmsh.model.geo.addPoint(1, 1, 1, lcar1, 12)
gmsh.model.geo.addPoint(1,0,1, lcar1, 13) gmsh.model.geo.addPoint(1, 0, 1, lcar1, 13)
gmsh.model.geo.addPoint(1,0,0, lcar1, 14) gmsh.model.geo.addPoint(1, 0, 0, lcar1, 14)
gmsh.model.geo.addLine(8,9, 1); gmsh.model.geo.addLine(9,12, 2) gmsh.model.geo.addLine(8, 9, 1)
gmsh.model.geo.addLine(12,11, 3); gmsh.model.geo.addLine(11,8, 4) gmsh.model.geo.addLine(9, 12, 2)
gmsh.model.geo.addLine(9,14, 5); gmsh.model.geo.addLine(14,13, 6) gmsh.model.geo.addLine(12, 11, 3)
gmsh.model.geo.addLine(13,12, 7); gmsh.model.geo.addLine(11,10, 8) gmsh.model.geo.addLine(11, 8, 4)
gmsh.model.geo.addLine(10,13, 9); gmsh.model.geo.addLine(10,4, 10) gmsh.model.geo.addLine(9, 14, 5)
gmsh.model.geo.addLine(4,5, 11); gmsh.model.geo.addLine(5,6, 12) gmsh.model.geo.addLine(14, 13, 6)
gmsh.model.geo.addLine(6,2, 13); gmsh.model.geo.addLine(2,1, 14) gmsh.model.geo.addLine(13, 12, 7)
gmsh.model.geo.addLine(1,3, 15); gmsh.model.geo.addLine(3,7, 16) gmsh.model.geo.addLine(11, 10, 8)
gmsh.model.geo.addLine(7,2, 17); gmsh.model.geo.addLine(3,4, 18) gmsh.model.geo.addLine(10, 13, 9)
gmsh.model.geo.addLine(5,1, 19); gmsh.model.geo.addLine(7,8, 20) gmsh.model.geo.addLine(10, 4, 10)
gmsh.model.geo.addLine(6,14, 21); gmsh.model.geo.addLine(4, 5, 11)
gmsh.model.geo.addLine(5, 6, 12)
gmsh.model.geo.addCurveLoop([-11,-19,-15,-18], 22) gmsh.model.geo.addLine(6, 2, 13)
gmsh.model.geo.addLine(2, 1, 14)
gmsh.model.geo.addLine(1, 3, 15)
gmsh.model.geo.addLine(3, 7, 16)
gmsh.model.geo.addLine(7, 2, 17)
gmsh.model.geo.addLine(3, 4, 18)
gmsh.model.geo.addLine(5, 1, 19)
gmsh.model.geo.addLine(7, 8, 20)
gmsh.model.geo.addLine(6, 14, 21)
gmsh.model.geo.addCurveLoop([-11, -19, -15, -18], 22)
gmsh.model.geo.addPlaneSurface([22], 23) gmsh.model.geo.addPlaneSurface([22], 23)
gmsh.model.geo.addCurveLoop([16,17,14,15], 24) gmsh.model.geo.addCurveLoop([16, 17, 14, 15], 24)
gmsh.model.geo.addPlaneSurface([24], 25) gmsh.model.geo.addPlaneSurface([24], 25)
gmsh.model.geo.addCurveLoop([-17,20,1,5,-21,13], 26) gmsh.model.geo.addCurveLoop([-17, 20, 1, 5, -21, 13], 26)
gmsh.model.geo.addPlaneSurface([26], 27) gmsh.model.geo.addPlaneSurface([26], 27)
gmsh.model.geo.addCurveLoop([-4,-1,-2,-3], 28) gmsh.model.geo.addCurveLoop([-4, -1, -2, -3], 28)
gmsh.model.geo.addPlaneSurface([28], 29) gmsh.model.geo.addPlaneSurface([28], 29)
gmsh.model.geo.addCurveLoop([-7,2,-5,-6], 30) gmsh.model.geo.addCurveLoop([-7, 2, -5, -6], 30)
gmsh.model.geo.addPlaneSurface([30], 31) gmsh.model.geo.addPlaneSurface([30], 31)
gmsh.model.geo.addCurveLoop([6,-9,10,11,12,21], 32) gmsh.model.geo.addCurveLoop([6, -9, 10, 11, 12, 21], 32)
gmsh.model.geo.addPlaneSurface([32], 33) gmsh.model.geo.addPlaneSurface([32], 33)
gmsh.model.geo.addCurveLoop([7,3,8,9], 34) gmsh.model.geo.addCurveLoop([7, 3, 8, 9], 34)
gmsh.model.geo.addPlaneSurface([34], 35) gmsh.model.geo.addPlaneSurface([34], 35)
gmsh.model.geo.addCurveLoop([-10,18,-16,-20,4,-8], 36) gmsh.model.geo.addCurveLoop([-10, 18, -16, -20, 4, -8], 36)
gmsh.model.geo.addPlaneSurface([36], 37) gmsh.model.geo.addPlaneSurface([36], 37)
gmsh.model.geo.addCurveLoop([-14,-13,-12,19], 38) gmsh.model.geo.addCurveLoop([-14, -13, -12, 19], 38)
gmsh.model.geo.addPlaneSurface([38], 39) gmsh.model.geo.addPlaneSurface([38], 39)
shells = [] shells = []
...@@ -95,35 +105,35 @@ function cheeseHole(x, y, z, r, lc, shells) ...@@ -95,35 +105,35 @@ function cheeseHole(x, y, z, r, lc, shells)
# This function will create a spherical hole in a volume. We don't specify # This function will create a spherical hole in a volume. We don't specify
# tags manually, and let the functions return them automatically: # tags manually, and let the functions return them automatically:
p1 = gmsh.model.geo.addPoint(x, y, z, lc) p1 = gmsh.model.geo.addPoint(x, y, z, lc)
p2 = gmsh.model.geo.addPoint(x+r,y, z, lc) p2 = gmsh.model.geo.addPoint(x + r, y, z, lc)
p3 = gmsh.model.geo.addPoint(x, y+r,z, lc) p3 = gmsh.model.geo.addPoint(x, y + r, z, lc)
p4 = gmsh.model.geo.addPoint(x, y, z+r, lc) p4 = gmsh.model.geo.addPoint(x, y, z + r, lc)
p5 = gmsh.model.geo.addPoint(x-r,y, z, lc) p5 = gmsh.model.geo.addPoint(x - r, y, z, lc)
p6 = gmsh.model.geo.addPoint(x, y-r,z, lc) p6 = gmsh.model.geo.addPoint(x, y - r, z, lc)
p7 = gmsh.model.geo.addPoint(x, y, z-r, lc) p7 = gmsh.model.geo.addPoint(x, y, z - r, lc)
c1 = gmsh.model.geo.addCircleArc(p2,p1,p7) c1 = gmsh.model.geo.addCircleArc(p2, p1, p7)
c2 = gmsh.model.geo.addCircleArc(p7,p1,p5) c2 = gmsh.model.geo.addCircleArc(p7, p1, p5)
c3 = gmsh.model.geo.addCircleArc(p5,p1,p4) c3 = gmsh.model.geo.addCircleArc(p5, p1, p4)
c4 = gmsh.model.geo.addCircleArc(p4,p1,p2) c4 = gmsh.model.geo.addCircleArc(p4, p1, p2)
c5 = gmsh.model.geo.addCircleArc(p2,p1,p3) c5 = gmsh.model.geo.addCircleArc(p2, p1, p3)
c6 = gmsh.model.geo.addCircleArc(p3,p1,p5) c6 = gmsh.model.geo.addCircleArc(p3, p1, p5)
c7 = gmsh.model.geo.addCircleArc(p5,p1,p6) c7 = gmsh.model.geo.addCircleArc(p5, p1, p6)
c8 = gmsh.model.geo.addCircleArc(p6,p1,p2) c8 = gmsh.model.geo.addCircleArc(p6, p1, p2)
c9 = gmsh.model.geo.addCircleArc(p7,p1,p3) c9 = gmsh.model.geo.addCircleArc(p7, p1, p3)
c10 = gmsh.model.geo.addCircleArc(p3,p1,p4) c10 = gmsh.model.geo.addCircleArc(p3, p1, p4)
c11 = gmsh.model.geo.addCircleArc(p4,p1,p6) c11 = gmsh.model.geo.addCircleArc(p4, p1, p6)
c12 = gmsh.model.geo.addCircleArc(p6,p1,p7) c12 = gmsh.model.geo.addCircleArc(p6, p1, p7)
l1 = gmsh.model.geo.addCurveLoop([c5,c10,c4]) l1 = gmsh.model.geo.addCurveLoop([c5, c10, c4])
l2 = gmsh.model.geo.addCurveLoop([c9,-c5,c1]) l2 = gmsh.model.geo.addCurveLoop([c9, -c5, c1])
l3 = gmsh.model.geo.addCurveLoop([c12,-c8,-c1]) l3 = gmsh.model.geo.addCurveLoop([c12, -c8, -c1])
l4 = gmsh.model.geo.addCurveLoop([c8,-c4,c11]) l4 = gmsh.model.geo.addCurveLoop([c8, -c4, c11])
l5 = gmsh.model.geo.addCurveLoop([-c10,c6,c3]) l5 = gmsh.model.geo.addCurveLoop([-c10, c6, c3])
l6 = gmsh.model.geo.addCurveLoop([-c11,-c3,c7]) l6 = gmsh.model.geo.addCurveLoop([-c11, -c3, c7])
l7 = gmsh.model.geo.addCurveLoop([-c2,-c7,-c12]) l7 = gmsh.model.geo.addCurveLoop([-c2, -c7, -c12])
l8 = gmsh.model.geo.addCurveLoop([-c6,-c9,c2]) l8 = gmsh.model.geo.addCurveLoop([-c6, -c9, c2])
# We need non-plane surfaces to define the spherical holes. Here we use the # We need non-plane surfaces to define the spherical holes. Here we use the
# `gmsh.model.geo.addSurfaceFilling()' function, which can be used for # `gmsh.model.geo.addSurfaceFilling()' function, which can be used for
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment