11def circle_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
13 Create a circular mesh, either symmetric or full.
14 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
15 r - radius of the circle
17 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full circle
21 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
25 xc_mesh = [0., 0., 0.]
26 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
27 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r, xc_mesh[1], xc_mesh[2], h)
28 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r, xc_mesh[2], h)
30 l1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
31 l2 = gmsh.model.geo.addLine(p1, p2)
32 l3 = gmsh.model.geo.addLine(p3, p1)
34 c1 = gmsh.model.geo.addCurveLoop([l2, l1, l3])
36 p1 = gmsh.model.geo.addPlaneSurface([c1])
39 gmsh.model.geo.synchronize()
42 gmsh.model.mesh.generate(3)
54 gmsh.model.mesh.removeDuplicateNodes()
61 c = gmsh.model.occ.addCircle(xc[0], xc[1], xc[2], r)
64 cl = gmsh.model.occ.addCurveLoop([c])
67 s = gmsh.model.occ.addPlaneSurface([cl])
70 p = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], h)
73 gmsh.model.occ.synchronize()
76 gmsh.model.mesh.embed(0, [p], 2, s)
79 gmsh.model.mesh.generate(3)
82 gmsh.write(filename +
'.msh')
84 gmsh.write(filename +
'.vtk')
88def ellipse_mesh_symmetric(xc = [0., 0., 0.], rx = 1., ry = 0.5, h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
90 Create an elliptical mesh, either symmetric or full.
91 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
92 rx - radius in x direction
93 ry - radius in y direction
95 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full ellipse
99 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
103 xc_mesh = [0., 0., 0.]
104 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
105 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + rx, xc_mesh[1], xc_mesh[2], h)
106 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + ry, xc_mesh[2], h)
109 l1 = gmsh.model.geo.addEllipseArc(p2, p1, p2, p3)
110 l2 = gmsh.model.geo.addLine(p1, p2)
111 l3 = gmsh.model.geo.addLine(p3, p1)
114 c1 = gmsh.model.geo.addCurveLoop([l2, l1, l3])
115 s1 = gmsh.model.geo.addPlaneSurface([c1])
117 gmsh.model.geo.synchronize()
118 gmsh.model.mesh.generate(3)
129 gmsh.model.mesh.removeDuplicateNodes()
136 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
137 p2 = gmsh.model.geo.addPoint(xc[0] + rx, xc[1], xc[2], h)
138 p3 = gmsh.model.geo.addPoint(xc[0], xc[1] + ry, xc[2], h)
139 p4 = gmsh.model.geo.addPoint(xc[0] - rx, xc[1], xc[2], h)
140 p5 = gmsh.model.geo.addPoint(xc[0], xc[1] - ry, xc[2], h)
143 l1 = gmsh.model.geo.addEllipseArc(p2, p1, p2, p3)
144 l2 = gmsh.model.geo.addEllipseArc(p3, p1, p3, p4)
145 l3 = gmsh.model.geo.addEllipseArc(p4, p1, p4, p5)
146 l4 = gmsh.model.geo.addEllipseArc(p5, p1, p5, p2)
149 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
150 s1 = gmsh.model.geo.addPlaneSurface([c1])
153 gmsh.model.geo.synchronize()
156 gmsh.model.mesh.embed(0, [p1], 2, s1)
159 gmsh.model.mesh.generate(3)
162 gmsh.write(filename +
'.msh')
164 gmsh.write(filename +
'.vtk')
168def sphere_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
170 Create a spherical mesh, either symmetric or full.
171 xc - center point coordinates [x, y, z]
172 r - radius of the sphere
174 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full sphere
177 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
181 xc_mesh = [0., 0., 0.]
184 sphere = gmsh.model.occ.addSphere(xc_mesh[0], xc_mesh[1], xc_mesh[2], r)
187 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, r, 2*r, 2*r)
188 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, 2*r, r, 2*r)
189 cut_bottom = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, 2*r, 2*r, r)
192 gmsh.model.occ.cut([(3,sphere)], [(3,cut_left), (3,cut_back), (3,cut_bottom)])
194 gmsh.model.occ.synchronize()
197 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
200 gmsh.model.mesh.generate(3)
228 sphere = gmsh.model.occ.addSphere(xc[0], xc[1], xc[2], r)
231 gmsh.model.occ.synchronize()
234 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
237 gmsh.model.geo.synchronize()
240 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
241 gmsh.model.mesh.embed(0, [p1], 3, sphere)
244 gmsh.model.mesh.generate(3)
247 gmsh.write(filename +
'.msh')
249 gmsh.write(filename +
'.vtk')
253def rectangle_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
255 Create a rectangular mesh, either symmetric or full.
256 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
257 Lx - length in x direction
258 Ly - length in y direction
260 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full rectangle
264 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
268 xc_mesh = [0., 0., 0.]
271 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
272 p2 = gmsh.model.geo.addPoint(xc_mesh[0]+0.5*Lx, xc_mesh[1], xc_mesh[2], h)
273 p3 = gmsh.model.geo.addPoint(xc_mesh[0]+0.5*Lx, xc_mesh[1]+0.5*Ly, xc_mesh[2], h)
274 p4 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1]+0.5*Ly, xc_mesh[2], h)
277 l1 = gmsh.model.geo.addLine(p1, p2)
278 l2 = gmsh.model.geo.addLine(p2, p3)
279 l3 = gmsh.model.geo.addLine(p3, p4)
280 l4 = gmsh.model.geo.addLine(p4, p1)
283 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
284 s1 = gmsh.model.geo.addPlaneSurface([c1])
287 gmsh.model.geo.synchronize()
288 gmsh.model.mesh.generate(3)
299 gmsh.model.mesh.removeDuplicateNodes()
306 p0 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
307 p1 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
308 p2 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
309 p3 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
310 p4 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
313 l1 = gmsh.model.geo.addLine(p1, p2)
314 l2 = gmsh.model.geo.addLine(p2, p3)
315 l3 = gmsh.model.geo.addLine(p3, p4)
316 l4 = gmsh.model.geo.addLine(p4, p1)
319 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
320 s1 = gmsh.model.geo.addPlaneSurface([c1])
323 gmsh.model.geo.synchronize()
326 gmsh.model.mesh.embed(0, [p0], 2, s1)
329 gmsh.model.mesh.generate(3)
332 gmsh.write(filename +
'.msh')
334 gmsh.write(filename +
'.vtk')
338def hexagon_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
340 Create a hexagon mesh, either symmetric or full.
341 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
342 r - radius of the hexagon
344 symmetric_mesh - if True, creates 1/6 mesh and mirrors it. If False, creates full hexagon
347 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
351 xc_mesh = [0., 0., 0.]
352 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
353 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r, xc_mesh[1], xc_mesh[2], h)
354 p3 = gmsh.model.geo.addPoint(xc_mesh[0] + r*np.cos(np.pi/3), xc_mesh[1] + r*np.sin(np.pi/3), xc_mesh[2], h)
357 l1 = gmsh.model.geo.addLine(p1, p2)
358 l2 = gmsh.model.geo.addLine(p2, p3)
359 l3 = gmsh.model.geo.addLine(p3, p1)
362 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3])
363 s1 = gmsh.model.geo.addPlaneSurface([c1])
365 gmsh.model.geo.synchronize()
366 gmsh.model.mesh.generate(3)
373 angle = (i + 1) * np.pi/3
377 gmsh.model.mesh.removeDuplicateNodes()
387 px = xc[0] + r * np.cos(angle)
388 py = xc[1] + r * np.sin(angle)
389 points.append(gmsh.model.geo.addPoint(px, py, xc[2], h))
391 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
396 lines.append(gmsh.model.geo.addLine(points[i], points[i+1]))
397 lines.append(gmsh.model.geo.addLine(points[5], points[0]))
400 c1 = gmsh.model.geo.addCurveLoop(lines)
401 s1 = gmsh.model.geo.addPlaneSurface([c1])
404 gmsh.model.geo.synchronize()
407 gmsh.model.mesh.embed(0, [points[-1]], 2, s1)
410 gmsh.model.mesh.generate(3)
413 gmsh.write(filename +
'.msh')
415 gmsh.write(filename +
'.vtk')
419def drum2d_mesh_symmetric(xc = [0., 0., 0.], r = 1., width = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
421 Create a drum2d mesh, either symmetric or full.
422 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
423 r - radius of the drum2d
424 width - width of the drum2d
426 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full drum2d
429 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
433 xc_mesh = [0., 0., 0.]
435 v1, v2, v3 = x_drum[0], x_drum[1], x_drum[2]
436 v23 = [0.5*(v2[0] + v3[0]), 0.5*(v2[1] + v3[1]), 0.5*(v2[2] + v3[2])]
440 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
441 p2 = gmsh.model.geo.addPoint(v1[0], v1[1], v1[2], h)
442 p3 = gmsh.model.geo.addPoint(v2[0], v2[1], v2[2], h)
443 p4 = gmsh.model.geo.addPoint(v23[0], v23[1], v23[2], h)
447 points = [p1, p2, p3, p4, p1]
449 lines.append(gmsh.model.geo.addLine(points[i], points[i+1]))
452 c1 = gmsh.model.geo.addCurveLoop(lines)
453 s1 = gmsh.model.geo.addPlaneSurface([c1])
455 gmsh.model.geo.synchronize()
456 gmsh.model.mesh.generate(3)
467 gmsh.model.mesh.removeDuplicateNodes()
477 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
478 for i
in range(len(x_drum)):
479 points.append(gmsh.model.geo.addPoint(x_drum[i][0], x_drum[i][1], x_drum[i][2], h))
483 points.append(points[1])
484 for i
in range(len(x_drum)):
485 lines.append(gmsh.model.geo.addLine(points[i+1], points[i+2]))
488 c1 = gmsh.model.geo.addCurveLoop(lines)
489 s1 = gmsh.model.geo.addPlaneSurface([c1])
492 gmsh.model.geo.synchronize()
495 gmsh.model.mesh.embed(0, [points[0]], 2, s1)
498 gmsh.model.mesh.generate(3)
501 gmsh.write(filename +
'.msh')
503 gmsh.write(filename +
'.vtk')
509 Create a symmetric mesh by rotating a polygon segment n times, where n = 360/theta.
512 points - List of [x,y,z] coordinates defining the polygon segment. First point must be [0,0,0]
513 and first two edges must form angle theta at origin
514 theta - Angle in radians between first two edges at origin. Must divide 2pi evenly.
515 xc - Center point for final translation
517 filename - Output filename
518 vtk_out - Whether to output VTK file
521 if not points
or len(points) < 3:
522 raise ValueError(
"Need at least 3 points to define a polygon segment")
524 if not np.allclose(points[0], [0., 0., 0.]):
525 raise ValueError(
"First point must be at origin [0,0,0]")
528 n = int(round(2*np.pi/theta))
529 if not np.isclose(2*np.pi, n * theta):
530 raise ValueError(f
"Angle {theta} degrees must divide 360 evenly")
533 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
538 gmsh_points.append(gmsh.model.geo.addPoint(pt[0], pt[1], pt[2], h))
542 for i
in range(len(gmsh_points)-1):
543 lines.append(gmsh.model.geo.addLine(gmsh_points[i], gmsh_points[i+1]))
545 lines.append(gmsh.model.geo.addLine(gmsh_points[-1], gmsh_points[0]))
548 c1 = gmsh.model.geo.addCurveLoop(lines)
549 s1 = gmsh.model.geo.addPlaneSurface([c1])
552 gmsh.model.geo.synchronize()
553 gmsh.model.mesh.generate(3)
559 for i
in range(1, n):
564 gmsh.model.mesh.removeDuplicateNodes()
570 gmsh.write(filename +
'.msh')
572 gmsh.write(filename +
'.vtk')
577 bar_width=0.2, bar_length=0.3, h=0.1, filename='mesh', vtk_out=False):
579 Create a cylindrical wall mesh with bars.
582 center - Center point coordinates [x, y, z]
583 outer_radius - Outer radius of the wall
584 inner_radius - Inner radius of the wall
585 bar_width - Width of the bars
586 bar_length - Length of the bars
588 filename - Output filename
589 vtk_out - Whether to output VTK file
592 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
596 p1 = gmsh.model.geo.addPoint(center[0], center[1], center[2], h)
599 p2 = gmsh.model.geo.addPoint(center[0] + outer_radius, center[1], center[2], h)
600 p3 = gmsh.model.geo.addPoint(center[0], center[1] + outer_radius, center[2], h)
601 p4 = gmsh.model.geo.addPoint(center[0] - outer_radius, center[1], center[2], h)
602 p5 = gmsh.model.geo.addPoint(center[0], center[1] - outer_radius, center[2], h)
605 p6 = gmsh.model.geo.addPoint(center[0] + inner_radius, center[1] + 0.5*bar_width, center[2], h)
606 p7 = gmsh.model.geo.addPoint(center[0] + inner_radius, center[1] - 0.5*bar_width, center[2], h)
607 p8 = gmsh.model.geo.addPoint(center[0], center[1] + inner_radius, center[2], h)
608 p9 = gmsh.model.geo.addPoint(center[0] - inner_radius, center[1], center[2], h)
609 p10 = gmsh.model.geo.addPoint(center[0], center[1] - inner_radius, center[2], h)
612 p11 = gmsh.model.geo.addPoint(center[0] + inner_radius - bar_length, center[1] + 0.5*bar_width, center[2], h)
613 p12 = gmsh.model.geo.addPoint(center[0] + inner_radius - bar_length, center[1] - 0.5*bar_width, center[2], h)
616 c1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
617 c2 = gmsh.model.geo.addCircleArc(p3, p1, p4)
618 c3 = gmsh.model.geo.addCircleArc(p4, p1, p5)
619 c4 = gmsh.model.geo.addCircleArc(p5, p1, p2)
622 c5 = gmsh.model.geo.addCircleArc(p6, p1, p8)
623 c6 = gmsh.model.geo.addCircleArc(p8, p1, p9)
624 c7 = gmsh.model.geo.addCircleArc(p9, p1, p10)
625 c8 = gmsh.model.geo.addCircleArc(p10, p1, p7)
628 l1 = gmsh.model.geo.addLine(p6, p11)
629 l2 = gmsh.model.geo.addLine(p11, p12)
630 l3 = gmsh.model.geo.addLine(p12, p7)
633 outer_loop = gmsh.model.geo.addCurveLoop([c1, c2, c3, c4])
634 inner_loop = gmsh.model.geo.addCurveLoop([c5, c6, c7, c8, -l3, -l2, -l1])
637 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
640 gmsh.model.geo.synchronize()
641 gmsh.model.mesh.generate(2)
644 gmsh.write(filename +
'.msh')
646 gmsh.write(filename +
'.vtk')
652 Create a triangle mesh, either symmetric or full.
655 xc - center point coordinates [x, y, z]
656 r - radius of the circumscribed circle
658 filename - output filename
659 vtk_out - whether to output VTK file
660 symmetric_mesh - if True, creates 1/3 mesh and rotates it twice. If False, creates full triangle
663 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
667 xc_mesh = [0., 0., 0.]
670 v1, v2, v3 = x_tri[0], x_tri[1], x_tri[2]
673 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
674 p2 = gmsh.model.geo.addPoint(v1[0], v1[1], v1[2], h)
675 p3 = gmsh.model.geo.addPoint(v2[0], v2[1], v2[2], h)
678 l1 = gmsh.model.geo.addLine(p1, p2)
679 l2 = gmsh.model.geo.addLine(p2, p3)
680 l3 = gmsh.model.geo.addLine(p3, p1)
683 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3])
684 s1 = gmsh.model.geo.addPlaneSurface([c1])
686 gmsh.model.geo.synchronize()
687 gmsh.model.mesh.generate(3)
694 angle = (i + 1) * 2*np.pi/3
698 gmsh.model.mesh.removeDuplicateNodes()
709 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
711 points.append(gmsh.model.geo.addPoint(v[0], v[1], v[2], h))
716 lines.append(gmsh.model.geo.addLine(points[i+1], points[i+2]))
717 lines.append(gmsh.model.geo.addLine(points[3], points[1]))
720 c1 = gmsh.model.geo.addCurveLoop(lines)
721 s1 = gmsh.model.geo.addPlaneSurface([c1])
724 gmsh.model.geo.synchronize()
727 gmsh.model.mesh.embed(0, [points[0]], 2, s1)
730 gmsh.model.mesh.generate(3)
733 gmsh.write(filename +
'.msh')
735 gmsh.write(filename +
'.vtk')
739def cuboid_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 1., Lz = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
741 Create a cuboid mesh, either symmetric or full.
742 xc - center point for symmetric mesh, or bottom-left-back corner for non-symmetric mesh
743 Lx - length in x direction
744 Ly - length in y direction
745 Lz - length in z direction
747 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full cuboid
750 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
754 xc_mesh = [0., 0., 0.]
757 box = gmsh.model.occ.addBox(xc_mesh[0], xc_mesh[1], xc_mesh[2],
758 0.5*Lx, 0.5*Ly, 0.5*Lz)
760 gmsh.model.occ.synchronize()
763 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
766 gmsh.model.mesh.generate(3)
784 gmsh.model.mesh.removeDuplicateNodes()
792 box = gmsh.model.occ.addBox(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2] - 0.5*Lz,
796 p1 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], h)
799 gmsh.model.occ.synchronize()
802 gmsh.model.mesh.embed(0, [p1], 3, box)
805 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
808 gmsh.model.mesh.generate(3)
811 gmsh.write(filename +
'.msh')
813 gmsh.write(filename +
'.vtk')
817def ellipsoid_mesh_symmetric(xc = [0., 0., 0.], rx = 1., ry = 0.5, rz = 0.3, h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
819 Create an ellipsoid mesh, either symmetric or full.
820 xc - center point coordinates [x, y, z]
821 rx - radius in x direction
822 ry - radius in y direction
823 rz - radius in z direction
825 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full ellipsoid
828 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
832 xc_mesh = [0., 0., 0.]
835 sphere = gmsh.model.occ.addSphere(xc_mesh[0], xc_mesh[1], xc_mesh[2], 1.0)
838 gmsh.model.occ.dilate([(3, sphere)], xc_mesh[0], xc_mesh[1], xc_mesh[2], rx, ry, rz)
841 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, rx, 2*ry, 2*rz)
842 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, 2*rx, ry, 2*rz)
843 cut_bottom = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, 2*rx, 2*ry, rz)
846 gmsh.model.occ.cut([(3,sphere)], [(3,cut_left), (3,cut_back), (3,cut_bottom)])
848 gmsh.model.occ.synchronize()
851 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
854 gmsh.model.mesh.generate(3)
872 gmsh.model.mesh.removeDuplicateNodes()
880 sphere = gmsh.model.occ.addSphere(xc[0], xc[1], xc[2], 1.0)
883 gmsh.model.occ.dilate([(3, sphere)], xc[0], xc[1], xc[2], rx, ry, rz)
886 gmsh.model.occ.synchronize()
889 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
892 gmsh.model.mesh.generate(3)
895 gmsh.write(filename +
'.msh')
897 gmsh.write(filename +
'.vtk')
901def cylinder_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 1., mesh_size = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
903 Create a cylinder mesh, either symmetric or full.
904 xc - center point coordinates [x, y, z] (center of bottom face)
905 r - radius of cylinder
906 h - height of cylinder
907 mesh_size - mesh element size
908 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full cylinder
911 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
915 xc_mesh = [0., 0., 0.]
918 cyl = gmsh.model.occ.addCylinder(xc_mesh[0], xc_mesh[1], xc_mesh[2],
923 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2], r, 2*r, h)
924 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2], 2*r, r, h)
927 gmsh.model.occ.cut([(3,cyl)], [(3,cut_left), (3,cut_back)])
929 gmsh.model.occ.synchronize()
932 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), mesh_size)
935 gmsh.model.mesh.generate(3)
947 gmsh.model.mesh.removeDuplicateNodes()
954 cyl = gmsh.model.occ.addCylinder(xc[0], xc[1], xc[2],
959 p1 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], mesh_size)
960 p2 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2] + h, mesh_size)
963 gmsh.model.occ.synchronize()
967 surfaces = gmsh.model.getEntities(2)
970 com = gmsh.model.occ.getCenterOfMass(s[0], s[1])
971 if abs(com[2] - xc[2]) < 1e-6:
972 gmsh.model.mesh.embed(0, [p1], 2, s[1])
973 elif abs(com[2] - (xc[2] + h)) < 1e-6:
974 gmsh.model.mesh.embed(0, [p2], 2, s[1])
977 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), mesh_size)
980 gmsh.model.mesh.generate(3)
983 gmsh.write(filename +
'.msh')
985 gmsh.write(filename +
'.vtk')
991 Create an annulus (ring) mesh, either symmetric or full.
992 xc - center point coordinates [x, y, z]
993 r_outer - radius of outer circle
994 r_inner - radius of inner circle
996 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full annulus
998 if r_inner >= r_outer:
999 raise ValueError(
"Inner radius must be smaller than outer radius")
1002 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1005 xc_mesh = [0., 0., 0.]
1008 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
1009 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r_outer, xc_mesh[1], xc_mesh[2], h)
1010 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r_outer, xc_mesh[2], h)
1011 p4 = gmsh.model.geo.addPoint(xc_mesh[0] + r_inner, xc_mesh[1], xc_mesh[2], h)
1012 p5 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r_inner, xc_mesh[2], h)
1014 l1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
1015 l2 = gmsh.model.geo.addCircleArc(p4, p1, p5)
1016 l3 = gmsh.model.geo.addLine(p4, p2)
1017 l4 = gmsh.model.geo.addLine(p5, p3)
1019 c1 = gmsh.model.geo.addCurveLoop([l3, l1, -l4, -l2])
1020 s1 = gmsh.model.geo.addPlaneSurface([c1])
1022 gmsh.model.geo.synchronize()
1023 gmsh.model.mesh.generate(3)
1033 gmsh.model.mesh.removeDuplicateNodes()
1041 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
1042 p2 = gmsh.model.geo.addPoint(xc[0] + r_outer, xc[1], xc[2], h)
1043 p3 = gmsh.model.geo.addPoint(xc[0], xc[1] + r_outer, xc[2], h)
1044 p4 = gmsh.model.geo.addPoint(xc[0] - r_outer, xc[1], xc[2], h)
1045 p5 = gmsh.model.geo.addPoint(xc[0], xc[1] - r_outer, xc[2], h)
1048 p6 = gmsh.model.geo.addPoint(xc[0] + r_inner, xc[1], xc[2], h)
1049 p7 = gmsh.model.geo.addPoint(xc[0], xc[1] + r_inner, xc[2], h)
1050 p8 = gmsh.model.geo.addPoint(xc[0] - r_inner, xc[1], xc[2], h)
1051 p9 = gmsh.model.geo.addPoint(xc[0], xc[1] - r_inner, xc[2], h)
1054 c1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
1055 c2 = gmsh.model.geo.addCircleArc(p3, p1, p4)
1056 c3 = gmsh.model.geo.addCircleArc(p4, p1, p5)
1057 c4 = gmsh.model.geo.addCircleArc(p5, p1, p2)
1060 c5 = gmsh.model.geo.addCircleArc(p6, p1, p7)
1061 c6 = gmsh.model.geo.addCircleArc(p7, p1, p8)
1062 c7 = gmsh.model.geo.addCircleArc(p8, p1, p9)
1063 c8 = gmsh.model.geo.addCircleArc(p9, p1, p6)
1066 outer_loop = gmsh.model.geo.addCurveLoop([c1, c2, c3, c4])
1067 inner_loop = gmsh.model.geo.addCurveLoop([c5, c6, c7, c8])
1072 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
1075 gmsh.model.addPhysicalGroup(2, [s1], 1)
1078 gmsh.model.geo.synchronize()
1079 gmsh.model.mesh.generate(2)
1082 gmsh.write(filename +
'.msh')
1084 gmsh.write(filename +
'.vtk')
1088def annulus_rectangle_mesh(xc=[0., 0., 0.], Lx=1., Ly=1., hole_Lx=0.3, hole_Ly=0.3, h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True):
1090 Create a rectangular mesh with a rectangular hole in the center (annulus rectangle).
1095 Center coordinates [x, y, z]
1097 Length of outer rectangle in x direction
1099 Length of outer rectangle in y direction
1101 Length of inner hole in x direction
1103 Length of inner hole in y direction
1107 Output filename without extension
1109 If True, also writes a VTK file
1110 symmetric_mesh : bool
1111 If True, creates 1/4 mesh and mirrors it. If False, creates full mesh
1115 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1119 xc_mesh = [0., 0., 0.]
1122 p1 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1], xc_mesh[2], h)
1123 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h)
1124 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + 0.5*Ly, xc_mesh[2], h)
1125 p4 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1], xc_mesh[2], h)
1126 p5 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] + 0.5*hole_Ly, xc_mesh[2], h)
1127 p6 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + 0.5*hole_Ly, xc_mesh[2], h)
1130 l1 = gmsh.model.geo.addLine(p1, p2)
1131 l2 = gmsh.model.geo.addLine(p2, p3)
1132 l3 = gmsh.model.geo.addLine(p3, p6)
1133 l4 = gmsh.model.geo.addLine(p6, p5)
1134 l5 = gmsh.model.geo.addLine(p5, p4)
1135 l6 = gmsh.model.geo.addLine(p4, p1)
1138 cl = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4, l5, l6])
1141 s = gmsh.model.geo.addPlaneSurface([cl])
1144 gmsh.model.geo.synchronize()
1145 gmsh.model.mesh.generate(2)
1156 gmsh.model.mesh.removeDuplicateNodes()
1163 p1 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
1164 p2 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
1165 p3 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
1166 p4 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
1169 p5 = gmsh.model.geo.addPoint(xc[0] - 0.5*hole_Lx, xc[1] - 0.5*hole_Ly, xc[2], h)
1170 p6 = gmsh.model.geo.addPoint(xc[0] + 0.5*hole_Lx, xc[1] - 0.5*hole_Ly, xc[2], h)
1171 p7 = gmsh.model.geo.addPoint(xc[0] + 0.5*hole_Lx, xc[1] + 0.5*hole_Ly, xc[2], h)
1172 p8 = gmsh.model.geo.addPoint(xc[0] - 0.5*hole_Lx, xc[1] + 0.5*hole_Ly, xc[2], h)
1175 l1 = gmsh.model.geo.addLine(p1, p2)
1176 l2 = gmsh.model.geo.addLine(p2, p3)
1177 l3 = gmsh.model.geo.addLine(p3, p4)
1178 l4 = gmsh.model.geo.addLine(p4, p1)
1181 l5 = gmsh.model.geo.addLine(p5, p6)
1182 l6 = gmsh.model.geo.addLine(p6, p7)
1183 l7 = gmsh.model.geo.addLine(p7, p8)
1184 l8 = gmsh.model.geo.addLine(p8, p5)
1187 outer_loop = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
1188 inner_loop = gmsh.model.geo.addCurveLoop([l5, l6, l7, l8])
1191 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
1194 gmsh.model.geo.synchronize()
1195 gmsh.model.mesh.generate(2)
1198 gmsh.write(filename +
'.msh')
1200 gmsh.write(filename +
'.vtk')
1205def open_rectangle_mesh(xc = [0., 0., 0.], Lx = 1., Ly = 1., hole_Lx = 0.5, hole_Ly = 0.5, h = 0.1, filename = 'mesh', vtk_out = False):
1207 Create a rectangular mesh with a rectangular hole in the center (annulus rectangle).
1212 Center coordinates [x, y, z]
1214 Length of outer rectangle in x direction
1216 Length of outer rectangle in y direction
1218 Length of inner hole in x direction
1220 Length of inner hole in y direction
1224 Output filename without extension
1226 If True, also writes a VTK file
1230 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1235 xc_mesh = [0., 0., 0.]
1237 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] - 0.5*Ly, xc_mesh[2], h))
1238 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h))
1239 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h))
1240 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] - 0.5*hole_Ly, xc_mesh[2], h))
1241 points.append(gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] - 0.5*hole_Ly, xc_mesh[2], h))
1242 points.append(gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] - 0.5*Ly, xc_mesh[2], h))
1245 for i
in range(len(points) - 1):
1246 lines.append(gmsh.model.geo.addLine(points[i], points[i + 1]))
1247 lines.append(gmsh.model.geo.addLine(points[-1], points[0]))
1248 cl = gmsh.model.geo.addCurveLoop(lines)
1249 s = gmsh.model.geo.addPlaneSurface([cl])
1250 gmsh.model.geo.synchronize()
1251 gmsh.model.mesh.generate(2)
1257 gmsh.model.mesh.removeDuplicateNodes()
1260 gmsh.write(filename +
'.msh')
1262 gmsh.write(filename +
'.vtk')
1266def open_pipe_mesh(xc=[0., 0., 0.], axis=[0., 0., 1.], length=2., outer_radius=1., wall_thickness=0.1, h=0.1, filename='mesh', vtk_out=False):
1268 Create a 3D pipe mesh with specified axis, closed bottom and open top.
1269 The pipe is created by:
1270 1. Creating an outer cylinder
1271 2. Subtracting an inner cylinder to create walls
1272 3. Subtracting the top surface to create the opening
1277 Center coordinates [x, y, z] of the base center
1279 Axis vector defining pipe orientation [ax, ay, az]
1281 Length of the pipe along axis
1282 outer_radius : float
1283 Outer radius of the pipe
1284 wall_thickness : float
1285 Thickness of the pipe wall and bottom
1289 Output filename without extension
1291 If True, also writes a VTK file
1294 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1297 axis_norm = np.sqrt(axis[0]**2 + axis[1]**2 + axis[2]**2)
1299 raise ValueError(
"Axis vector cannot be zero")
1300 axis = [x/axis_norm
for x
in axis]
1303 l = length + wall_thickness
1304 outer_cylinder = gmsh.model.occ.addCylinder(xc[0], xc[1], xc[2],
1305 axis[0]*l, axis[1]*l, axis[2]*l,
1309 inner_cylinder = gmsh.model.occ.addCylinder(xc[0]+wall_thickness*axis[0], xc[1]+wall_thickness*axis[1], xc[2]+wall_thickness*axis[2],
1310 axis[0]*l, axis[1]*l, axis[2]*l,
1311 outer_radius - wall_thickness)
1315 dx = 2 * outer_radius
1316 box = gmsh.model.occ.addBox(xc[0] - dx, xc[1] - dx, xc[2] + l - wall_thickness,
1317 2*dx, 2*dx, 2*wall_thickness)
1320 if not (abs(axis[0]) < 1e-10
and abs(axis[1]) < 1e-10):
1323 rotation_axis = np.cross(z_axis, axis)
1324 rotation_angle = np.arccos(np.dot(z_axis, axis))
1327 gmsh.model.occ.rotate([(3, box)],
1328 xc[0], xc[1], xc[2],
1329 rotation_axis[0], rotation_axis[1], rotation_axis[2],
1333 pipe = gmsh.model.occ.cut([(3, outer_cylinder)], [(3, inner_cylinder), (3, box)])
1336 gmsh.model.occ.synchronize()
1339 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
1342 gmsh.model.mesh.generate(3)
1345 gmsh.write(filename +
'.msh')
1347 gmsh.write(filename +
'.vtk')
1353if __name__ ==
"__main__":
1356 test_meshes = [
'circle',
'ellipse',
'sphere',
'cuboid',
'ellipsoid',
'rectangle',
'hexagon',
'drum2d',
'triangle',
'polygon',
'cylindrical2d_wall',
'cylinder',
'annulus_circle',
'annulus_rectangle',
'open_rectangle',
'open_pipe']
1357 test_meshes = [
'open_pipe']
1360 for mesh
in test_meshes:
1361 if mesh ==
'circle':
1362 if symm_flag == 0
or symm_flag == 1:
1363 circle_mesh_symmetric(xc = [-3., -3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1364 if symm_flag == 0
or symm_flag == 2:
1365 circle_mesh_symmetric(xc = [-3., -3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1366 elif mesh ==
'ellipse':
1367 if symm_flag == 0
or symm_flag == 1:
1368 ellipse_mesh_symmetric(xc = [-1., -1., 0.], rx = 1., ry = 0.5, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1369 if symm_flag == 0
or symm_flag == 2:
1370 ellipse_mesh_symmetric(xc = [-1., -1., 0.], rx = 1., ry = 0.5, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1371 elif mesh ==
'sphere':
1372 if symm_flag == 0
or symm_flag == 1:
1373 sphere_mesh_symmetric(xc = [-5., -5., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1374 if symm_flag == 0
or symm_flag == 2:
1375 sphere_mesh_symmetric(xc = [-5., -5., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1376 elif mesh ==
'rectangle':
1377 if symm_flag == 0
or symm_flag == 1:
1378 rectangle_mesh_symmetric(xc = [1., 1., 0.], Lx = 1., Ly = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1379 if symm_flag == 0
or symm_flag == 2:
1380 rectangle_mesh_symmetric(xc = [1., 1., 0.], Lx = 1., Ly = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1381 elif mesh ==
'hexagon':
1382 if symm_flag == 0
or symm_flag == 1:
1383 hexagon_mesh_symmetric(xc = [3., 3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1384 if symm_flag == 0
or symm_flag == 2:
1385 hexagon_mesh_symmetric(xc = [3., 3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1386 elif mesh ==
'drum2d':
1387 if symm_flag == 0
or symm_flag == 1:
1388 drum2d_mesh_symmetric(xc = [5., 5., 0.], r = 1., width = 0.5, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1389 if symm_flag == 0
or symm_flag == 2:
1390 drum2d_mesh_symmetric(xc = [5., 5., 0.], r = 1., width = 0.5, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1391 elif mesh ==
'triangle':
1392 if symm_flag == 0
or symm_flag == 1:
1393 triangle_mesh_symmetric(xc = [7., 7., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1394 if symm_flag == 0
or symm_flag == 2:
1395 triangle_mesh_symmetric(xc = [7., 7., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1396 elif mesh ==
'polygon':
1400 v2 = [R*np.cos(0.5*theta), -R*np.sin(0.5*theta), 0.]
1401 v4 = [R*np.cos(0.5*theta), R*np.sin(0.5*theta), 0.]
1402 v3 = [R + a, 0., 0.]
1403 if symm_flag == 0
or symm_flag == 1:
1404 polygon_mesh_symmetric(points = [v1, v2, v3, v4], theta = theta, xc = [9., 9., 9.], h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1405 if symm_flag == 0
or symm_flag == 2:
1406 polygon_mesh_symmetric(points = [v1, v2, v3, v4], theta = theta, xc = [9., 9., 9.], h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1407 elif mesh ==
'cylindrical2d_wall':
1409 center=[0., 0., 0.],
1415 filename=
'./' + mesh +
'_sym',
1418 elif mesh ==
'cuboid':
1419 if symm_flag == 0
or symm_flag == 1:
1420 cuboid_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 0.5, Lz = 0.3, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1421 if symm_flag == 0
or symm_flag == 2:
1422 cuboid_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 0.5, Lz = 0.3, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1423 elif mesh ==
'ellipsoid':
1424 if symm_flag == 0
or symm_flag == 1:
1425 ellipsoid_mesh_symmetric(xc = [0., 0., 0.], rx = 1., ry = 0.5, rz = 0.3, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1426 if symm_flag == 0
or symm_flag == 2:
1427 ellipsoid_mesh_symmetric(xc = [0., 0., 0.], rx = 1., ry = 0.5, rz = 0.3, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1428 elif mesh ==
'cylinder':
1429 if symm_flag == 0
or symm_flag == 1:
1430 cylinder_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 2., mesh_size = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1431 if symm_flag == 0
or symm_flag == 2:
1432 cylinder_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 2., mesh_size = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1433 elif mesh ==
'annulus_circle':
1434 if symm_flag == 0
or symm_flag == 1:
1436 if symm_flag == 0
or symm_flag == 2:
1437 annulus_circle_mesh_symmetric(xc = [0., 0., 0.], r_outer = 1., r_inner = 0.5, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1438 elif mesh ==
'annulus_rectangle':
1439 if symm_flag == 0
or symm_flag == 1:
1440 annulus_rectangle_mesh(xc = [0., 0., 0.], Lx = 1., Ly = 0.8, hole_Lx = 0.2, hole_Ly = 0.4, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1441 if symm_flag == 0
or symm_flag == 2:
1442 annulus_rectangle_mesh(xc = [0., 0., 0.], Lx = 1., Ly = 0.8, hole_Lx = 0.2, hole_Ly = 0.4, h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1443 elif mesh ==
'open_rectangle':
1444 open_rectangle_mesh(xc = [0., 0., 0.], Lx = 1.2, Ly = 0.8, hole_Lx = 1., hole_Ly = 0.6, h = 0.1, filename =
'./' + mesh, vtk_out =
True)
1445 elif mesh ==
'open_pipe':
1447 wall_thickness=0.2, h=0.1, filename=
'./' + mesh, vtk_out=
True)
1449 print(f
"Mesh {mesh} not found")
get_ref_drum_points(center, radius, width, add_center=False)
gmsh_transform(m, offset_entity, offset_node, offset_element, tx, ty, tz)
get_ref_triangle_points(center, radius, add_center=False)
gmsh_transform_general(m, offset_entity, offset_node, offset_element, angle, axis=[0, 0, 1])
open_pipe_mesh(xc=[0., 0., 0.], axis=[0., 0., 1.], length=2., outer_radius=1., wall_thickness=0.1, h=0.1, filename='mesh', vtk_out=False)
triangle_mesh_symmetric(xc=[0., 0., 0.], r=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
sphere_mesh_symmetric(xc=[0., 0., 0.], r=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
open_rectangle_mesh(xc=[0., 0., 0.], Lx=1., Ly=1., hole_Lx=0.5, hole_Ly=0.5, h=0.1, filename='mesh', vtk_out=False)
cylinder_mesh_symmetric(xc=[0., 0., 0.], r=1., h=1., mesh_size=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
annulus_circle_mesh_symmetric(xc=[0., 0., 0.], r_outer=1., r_inner=0.5, h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
hexagon_mesh_symmetric(xc=[0., 0., 0.], r=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
circle_mesh_symmetric(xc=[0., 0., 0.], r=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
polygon_mesh_symmetric(points, theta, xc=[0., 0., 0.], h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
cylindrical2d_wall_mesh(center=[0., 0., 0.], outer_radius=1.0, inner_radius=0.8, bar_width=0.2, bar_length=0.3, h=0.1, filename='mesh', vtk_out=False)
drum2d_mesh_symmetric(xc=[0., 0., 0.], r=1., width=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
annulus_rectangle_mesh(xc=[0., 0., 0.], Lx=1., Ly=1., hole_Lx=0.3, hole_Ly=0.3, h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
cuboid_mesh_symmetric(xc=[0., 0., 0.], Lx=1., Ly=1., Lz=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
rectangle_mesh_symmetric(xc=[0., 0., 0.], Lx=1., Ly=1., h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
ellipsoid_mesh_symmetric(xc=[0., 0., 0.], rx=1., ry=0.5, rz=0.3, h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)
ellipse_mesh_symmetric(xc=[0., 0., 0.], rx=1., ry=0.5, h=0.1, filename='mesh', vtk_out=False, symmetric_mesh=True)