12def circle_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
14 Create a circular mesh, either symmetric or full.
15 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
16 r - radius of the circle
18 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full circle
22 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
26 xc_mesh = [0., 0., 0.]
27 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
28 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r, xc_mesh[1], xc_mesh[2], h)
29 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r, xc_mesh[2], h)
31 l1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
32 l2 = gmsh.model.geo.addLine(p1, p2)
33 l3 = gmsh.model.geo.addLine(p3, p1)
35 c1 = gmsh.model.geo.addCurveLoop([l2, l1, l3])
37 p1 = gmsh.model.geo.addPlaneSurface([c1])
40 gmsh.model.geo.synchronize()
43 gmsh.model.mesh.generate(3)
55 gmsh.model.mesh.removeDuplicateNodes()
62 c = gmsh.model.occ.addCircle(xc[0], xc[1], xc[2], r)
65 cl = gmsh.model.occ.addCurveLoop([c])
68 s = gmsh.model.occ.addPlaneSurface([cl])
71 p = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], h)
74 gmsh.model.occ.synchronize()
77 gmsh.model.mesh.embed(0, [p], 2, s)
80 gmsh.model.mesh.generate(3)
86 gmsh.write(filename +
'.msh')
88 gmsh.write(filename +
'.vtk')
92def ellipse_mesh_symmetric(xc = [0., 0., 0.], rx = 1., ry = 0.5, h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
94 Create an elliptical mesh, either symmetric or full.
95 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
96 rx - radius in x direction
97 ry - radius in y direction
99 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full ellipse
103 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
107 xc_mesh = [0., 0., 0.]
108 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
109 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + rx, xc_mesh[1], xc_mesh[2], h)
110 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + ry, xc_mesh[2], h)
113 l1 = gmsh.model.geo.addEllipseArc(p2, p1, p2, p3)
114 l2 = gmsh.model.geo.addLine(p1, p2)
115 l3 = gmsh.model.geo.addLine(p3, p1)
118 c1 = gmsh.model.geo.addCurveLoop([l2, l1, l3])
119 s1 = gmsh.model.geo.addPlaneSurface([c1])
121 gmsh.model.geo.synchronize()
122 gmsh.model.mesh.generate(3)
133 gmsh.model.mesh.removeDuplicateNodes()
140 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
141 p2 = gmsh.model.geo.addPoint(xc[0] + rx, xc[1], xc[2], h)
142 p3 = gmsh.model.geo.addPoint(xc[0], xc[1] + ry, xc[2], h)
143 p4 = gmsh.model.geo.addPoint(xc[0] - rx, xc[1], xc[2], h)
144 p5 = gmsh.model.geo.addPoint(xc[0], xc[1] - ry, xc[2], h)
147 l1 = gmsh.model.geo.addEllipseArc(p2, p1, p2, p3)
148 l2 = gmsh.model.geo.addEllipseArc(p3, p1, p3, p4)
149 l3 = gmsh.model.geo.addEllipseArc(p4, p1, p4, p5)
150 l4 = gmsh.model.geo.addEllipseArc(p5, p1, p5, p2)
153 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
154 s1 = gmsh.model.geo.addPlaneSurface([c1])
157 gmsh.model.geo.synchronize()
160 gmsh.model.mesh.embed(0, [p1], 2, s1)
163 gmsh.model.mesh.generate(3)
169 gmsh.write(filename +
'.msh')
171 gmsh.write(filename +
'.vtk')
175def sphere_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
177 Create a spherical mesh, either symmetric or full.
178 xc - center point coordinates [x, y, z]
179 r - radius of the sphere
181 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full sphere
184 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
188 xc_mesh = [0., 0., 0.]
191 sphere = gmsh.model.occ.addSphere(xc_mesh[0], xc_mesh[1], xc_mesh[2], r)
194 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, r, 2*r, 2*r)
195 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, 2*r, r, 2*r)
196 cut_bottom = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2]-r, 2*r, 2*r, r)
199 gmsh.model.occ.cut([(3,sphere)], [(3,cut_left), (3,cut_back), (3,cut_bottom)])
201 gmsh.model.occ.synchronize()
204 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
207 gmsh.model.mesh.generate(3)
235 sphere = gmsh.model.occ.addSphere(xc[0], xc[1], xc[2], r)
238 gmsh.model.occ.synchronize()
241 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
244 gmsh.model.geo.synchronize()
247 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
248 gmsh.model.mesh.embed(0, [p1], 3, sphere)
251 gmsh.model.mesh.generate(3)
257 gmsh.write(filename +
'.msh')
259 gmsh.write(filename +
'.vtk')
263def rectangle_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
265 Create a rectangular mesh, either symmetric or full.
266 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
267 Lx - length in x direction
268 Ly - length in y direction
270 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full rectangle
274 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
278 xc_mesh = [0., 0., 0.]
281 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
282 p2 = gmsh.model.geo.addPoint(xc_mesh[0]+0.5*Lx, xc_mesh[1], xc_mesh[2], h)
283 p3 = gmsh.model.geo.addPoint(xc_mesh[0]+0.5*Lx, xc_mesh[1]+0.5*Ly, xc_mesh[2], h)
284 p4 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1]+0.5*Ly, xc_mesh[2], h)
287 l1 = gmsh.model.geo.addLine(p1, p2)
288 l2 = gmsh.model.geo.addLine(p2, p3)
289 l3 = gmsh.model.geo.addLine(p3, p4)
290 l4 = gmsh.model.geo.addLine(p4, p1)
293 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
294 s1 = gmsh.model.geo.addPlaneSurface([c1])
297 gmsh.model.geo.synchronize()
298 gmsh.model.mesh.generate(3)
309 gmsh.model.mesh.removeDuplicateNodes()
316 p0 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
317 p1 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
318 p2 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
319 p3 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
320 p4 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
323 l1 = gmsh.model.geo.addLine(p1, p2)
324 l2 = gmsh.model.geo.addLine(p2, p3)
325 l3 = gmsh.model.geo.addLine(p3, p4)
326 l4 = gmsh.model.geo.addLine(p4, p1)
329 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
330 s1 = gmsh.model.geo.addPlaneSurface([c1])
333 gmsh.model.geo.synchronize()
336 gmsh.model.mesh.embed(0, [p0], 2, s1)
339 gmsh.model.mesh.generate(3)
345 gmsh.write(filename +
'.msh')
347 gmsh.write(filename +
'.vtk')
351def hexagon_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
353 Create a hexagon mesh, either symmetric or full.
354 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
355 r - radius of the hexagon
357 symmetric_mesh - if True, creates 1/6 mesh and mirrors it. If False, creates full hexagon
360 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
364 xc_mesh = [0., 0., 0.]
365 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
366 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r, xc_mesh[1], xc_mesh[2], h)
367 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)
370 l1 = gmsh.model.geo.addLine(p1, p2)
371 l2 = gmsh.model.geo.addLine(p2, p3)
372 l3 = gmsh.model.geo.addLine(p3, p1)
375 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3])
376 s1 = gmsh.model.geo.addPlaneSurface([c1])
378 gmsh.model.geo.synchronize()
379 gmsh.model.mesh.generate(3)
386 angle = (i + 1) * np.pi/3
390 gmsh.model.mesh.removeDuplicateNodes()
400 px = xc[0] + r * np.cos(angle)
401 py = xc[1] + r * np.sin(angle)
402 points.append(gmsh.model.geo.addPoint(px, py, xc[2], h))
404 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
409 lines.append(gmsh.model.geo.addLine(points[i], points[i+1]))
410 lines.append(gmsh.model.geo.addLine(points[5], points[0]))
413 c1 = gmsh.model.geo.addCurveLoop(lines)
414 s1 = gmsh.model.geo.addPlaneSurface([c1])
417 gmsh.model.geo.synchronize()
420 gmsh.model.mesh.embed(0, [points[-1]], 2, s1)
423 gmsh.model.mesh.generate(3)
429 gmsh.write(filename +
'.msh')
431 gmsh.write(filename +
'.vtk')
435def drum2d_mesh_symmetric(xc = [0., 0., 0.], r = 1., width = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
437 Create a drum2d mesh, either symmetric or full.
438 xc - center point for symmetric mesh, or bottom-left corner for non-symmetric mesh
439 r - radius of the drum2d
440 width - width of the drum2d
442 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full drum2d
445 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
449 xc_mesh = [0., 0., 0.]
451 v1, v2, v3 = x_drum[0], x_drum[1], x_drum[2]
452 v23 = [0.5*(v2[0] + v3[0]), 0.5*(v2[1] + v3[1]), 0.5*(v2[2] + v3[2])]
456 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
457 p2 = gmsh.model.geo.addPoint(v1[0], v1[1], v1[2], h)
458 p3 = gmsh.model.geo.addPoint(v2[0], v2[1], v2[2], h)
459 p4 = gmsh.model.geo.addPoint(v23[0], v23[1], v23[2], h)
463 points = [p1, p2, p3, p4, p1]
465 lines.append(gmsh.model.geo.addLine(points[i], points[i+1]))
468 c1 = gmsh.model.geo.addCurveLoop(lines)
469 s1 = gmsh.model.geo.addPlaneSurface([c1])
471 gmsh.model.geo.synchronize()
472 gmsh.model.mesh.generate(3)
483 gmsh.model.mesh.removeDuplicateNodes()
493 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
494 for i
in range(len(x_drum)):
495 points.append(gmsh.model.geo.addPoint(x_drum[i][0], x_drum[i][1], x_drum[i][2], h))
499 points.append(points[1])
500 for i
in range(len(x_drum)):
501 lines.append(gmsh.model.geo.addLine(points[i+1], points[i+2]))
504 c1 = gmsh.model.geo.addCurveLoop(lines)
505 s1 = gmsh.model.geo.addPlaneSurface([c1])
508 gmsh.model.geo.synchronize()
511 gmsh.model.mesh.embed(0, [points[0]], 2, s1)
514 gmsh.model.mesh.generate(3)
520 gmsh.write(filename +
'.msh')
522 gmsh.write(filename +
'.vtk')
528 Create a symmetric mesh by rotating a polygon segment n times, where n = 360/theta.
531 points - List of [x,y,z] coordinates defining the polygon segment. First point must be [0,0,0]
532 and first two edges must form angle theta at origin
533 theta - Angle in radians between first two edges at origin. Must divide 2pi evenly.
534 xc - Center point for final translation
536 filename - Output filename
537 vtk_out - Whether to output VTK file
540 if not points
or len(points) < 3:
541 raise ValueError(
"Need at least 3 points to define a polygon segment")
543 if not np.allclose(points[0], [0., 0., 0.]):
544 raise ValueError(
"First point must be at origin [0,0,0]")
547 n = int(round(2*np.pi/theta))
548 if not np.isclose(2*np.pi, n * theta):
549 raise ValueError(f
"Angle {theta} degrees must divide 360 evenly")
552 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
557 gmsh_points.append(gmsh.model.geo.addPoint(pt[0], pt[1], pt[2], h))
561 for i
in range(len(gmsh_points)-1):
562 lines.append(gmsh.model.geo.addLine(gmsh_points[i], gmsh_points[i+1]))
564 lines.append(gmsh.model.geo.addLine(gmsh_points[-1], gmsh_points[0]))
567 c1 = gmsh.model.geo.addCurveLoop(lines)
568 s1 = gmsh.model.geo.addPlaneSurface([c1])
571 gmsh.model.geo.synchronize()
572 gmsh.model.mesh.generate(3)
578 for i
in range(1, n):
583 gmsh.model.mesh.removeDuplicateNodes()
592 gmsh.write(filename +
'.msh')
594 gmsh.write(filename +
'.vtk')
599 bar_width=0.2, bar_length=0.3, h=0.1, filename='mesh', vtk_out=False):
601 Create a cylindrical wall mesh with bars.
604 center - Center point coordinates [x, y, z]
605 outer_radius - Outer radius of the wall
606 inner_radius - Inner radius of the wall
607 bar_width - Width of the bars
608 bar_length - Length of the bars
610 filename - Output filename
611 vtk_out - Whether to output VTK file
614 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
618 p1 = gmsh.model.geo.addPoint(center[0], center[1], center[2], h)
621 p2 = gmsh.model.geo.addPoint(center[0] + outer_radius, center[1], center[2], h)
622 p3 = gmsh.model.geo.addPoint(center[0], center[1] + outer_radius, center[2], h)
623 p4 = gmsh.model.geo.addPoint(center[0] - outer_radius, center[1], center[2], h)
624 p5 = gmsh.model.geo.addPoint(center[0], center[1] - outer_radius, center[2], h)
627 p6 = gmsh.model.geo.addPoint(center[0] + inner_radius, center[1] + 0.5*bar_width, center[2], h)
628 p7 = gmsh.model.geo.addPoint(center[0] + inner_radius, center[1] - 0.5*bar_width, center[2], h)
629 p8 = gmsh.model.geo.addPoint(center[0], center[1] + inner_radius, center[2], h)
630 p9 = gmsh.model.geo.addPoint(center[0] - inner_radius, center[1], center[2], h)
631 p10 = gmsh.model.geo.addPoint(center[0], center[1] - inner_radius, center[2], h)
634 p11 = gmsh.model.geo.addPoint(center[0] + inner_radius - bar_length, center[1] + 0.5*bar_width, center[2], h)
635 p12 = gmsh.model.geo.addPoint(center[0] + inner_radius - bar_length, center[1] - 0.5*bar_width, center[2], h)
638 c1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
639 c2 = gmsh.model.geo.addCircleArc(p3, p1, p4)
640 c3 = gmsh.model.geo.addCircleArc(p4, p1, p5)
641 c4 = gmsh.model.geo.addCircleArc(p5, p1, p2)
644 c5 = gmsh.model.geo.addCircleArc(p6, p1, p8)
645 c6 = gmsh.model.geo.addCircleArc(p8, p1, p9)
646 c7 = gmsh.model.geo.addCircleArc(p9, p1, p10)
647 c8 = gmsh.model.geo.addCircleArc(p10, p1, p7)
650 l1 = gmsh.model.geo.addLine(p6, p11)
651 l2 = gmsh.model.geo.addLine(p11, p12)
652 l3 = gmsh.model.geo.addLine(p12, p7)
655 outer_loop = gmsh.model.geo.addCurveLoop([c1, c2, c3, c4])
656 inner_loop = gmsh.model.geo.addCurveLoop([c5, c6, c7, c8, -l3, -l2, -l1])
659 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
662 gmsh.model.geo.synchronize()
665 gmsh.model.addPhysicalGroup(2, [s1], 1)
668 gmsh.model.mesh.generate(2)
674 gmsh.write(filename +
'.msh')
676 gmsh.write(filename +
'.vtk')
682 Create a triangle mesh, either symmetric or full.
685 xc - center point coordinates [x, y, z]
686 r - radius of the circumscribed circle
688 filename - output filename
689 vtk_out - whether to output VTK file
690 symmetric_mesh - if True, creates 1/3 mesh and rotates it twice. If False, creates full triangle
693 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
697 xc_mesh = [0., 0., 0.]
700 v1, v2, v3 = x_tri[0], x_tri[1], x_tri[2]
703 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
704 p2 = gmsh.model.geo.addPoint(v1[0], v1[1], v1[2], h)
705 p3 = gmsh.model.geo.addPoint(v2[0], v2[1], v2[2], h)
708 l1 = gmsh.model.geo.addLine(p1, p2)
709 l2 = gmsh.model.geo.addLine(p2, p3)
710 l3 = gmsh.model.geo.addLine(p3, p1)
713 c1 = gmsh.model.geo.addCurveLoop([l1, l2, l3])
714 s1 = gmsh.model.geo.addPlaneSurface([c1])
716 gmsh.model.geo.synchronize()
717 gmsh.model.mesh.generate(3)
724 angle = (i + 1) * 2*np.pi/3
728 gmsh.model.mesh.removeDuplicateNodes()
739 points.append(gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h))
741 points.append(gmsh.model.geo.addPoint(v[0], v[1], v[2], h))
746 lines.append(gmsh.model.geo.addLine(points[i+1], points[i+2]))
747 lines.append(gmsh.model.geo.addLine(points[3], points[1]))
750 c1 = gmsh.model.geo.addCurveLoop(lines)
751 s1 = gmsh.model.geo.addPlaneSurface([c1])
754 gmsh.model.geo.synchronize()
757 gmsh.model.mesh.embed(0, [points[0]], 2, s1)
760 gmsh.model.mesh.generate(3)
766 gmsh.write(filename +
'.msh')
768 gmsh.write(filename +
'.vtk')
772def cuboid_mesh_symmetric(xc = [0., 0., 0.], Lx = 1., Ly = 1., Lz = 1., h = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
774 Create a cuboid mesh, either symmetric or full.
775 xc - center point for symmetric mesh, or bottom-left-back corner for non-symmetric mesh
776 Lx - length in x direction
777 Ly - length in y direction
778 Lz - length in z direction
780 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full cuboid
783 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
787 xc_mesh = [0., 0., 0.]
790 box = gmsh.model.occ.addBox(xc_mesh[0], xc_mesh[1], xc_mesh[2],
791 0.5*Lx, 0.5*Ly, 0.5*Lz)
793 gmsh.model.occ.synchronize()
796 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
799 gmsh.model.mesh.generate(3)
817 gmsh.model.mesh.removeDuplicateNodes()
825 box = gmsh.model.occ.addBox(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2] - 0.5*Lz,
829 p1 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], h)
832 gmsh.model.occ.synchronize()
835 gmsh.model.mesh.embed(0, [p1], 3, box)
838 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
841 gmsh.model.mesh.generate(3)
847 gmsh.write(filename +
'.msh')
849 gmsh.write(filename +
'.vtk')
853def 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):
855 Create an ellipsoid mesh, either symmetric or full.
856 xc - center point coordinates [x, y, z]
857 rx - radius in x direction
858 ry - radius in y direction
859 rz - radius in z direction
861 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full ellipsoid
864 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
868 xc_mesh = [0., 0., 0.]
871 sphere = gmsh.model.occ.addSphere(xc_mesh[0], xc_mesh[1], xc_mesh[2], 1.0)
874 gmsh.model.occ.dilate([(3, sphere)], xc_mesh[0], xc_mesh[1], xc_mesh[2], rx, ry, rz)
877 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, rx, 2*ry, 2*rz)
878 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, 2*rx, ry, 2*rz)
879 cut_bottom = gmsh.model.occ.addBox(xc_mesh[0]-rx, xc_mesh[1]-ry, xc_mesh[2]-rz, 2*rx, 2*ry, rz)
882 gmsh.model.occ.cut([(3,sphere)], [(3,cut_left), (3,cut_back), (3,cut_bottom)])
884 gmsh.model.occ.synchronize()
887 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
890 gmsh.model.mesh.generate(3)
908 gmsh.model.mesh.removeDuplicateNodes()
916 sphere = gmsh.model.occ.addSphere(xc[0], xc[1], xc[2], 1.0)
919 gmsh.model.occ.dilate([(3, sphere)], xc[0], xc[1], xc[2], rx, ry, rz)
922 gmsh.model.occ.synchronize()
925 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
928 gmsh.model.mesh.generate(3)
934 gmsh.write(filename +
'.msh')
936 gmsh.write(filename +
'.vtk')
940def cylinder_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 1., mesh_size = 0.1, filename = 'mesh', vtk_out = False, symmetric_mesh = True):
942 Create a cylinder mesh, either symmetric or full.
943 xc - center point coordinates [x, y, z] (center of bottom face)
944 r - radius of cylinder
945 h - height of cylinder
946 mesh_size - mesh element size
947 symmetric_mesh - if True, creates 1/8 mesh and mirrors it. If False, creates full cylinder
950 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
954 xc_mesh = [0., 0., 0.]
957 cyl = gmsh.model.occ.addCylinder(xc_mesh[0], xc_mesh[1], xc_mesh[2],
962 cut_left = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2], r, 2*r, h)
963 cut_back = gmsh.model.occ.addBox(xc_mesh[0]-r, xc_mesh[1]-r, xc_mesh[2], 2*r, r, h)
966 gmsh.model.occ.cut([(3,cyl)], [(3,cut_left), (3,cut_back)])
968 gmsh.model.occ.synchronize()
971 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), mesh_size)
974 gmsh.model.mesh.generate(3)
986 gmsh.model.mesh.removeDuplicateNodes()
993 cyl = gmsh.model.occ.addCylinder(xc[0], xc[1], xc[2],
998 p1 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2], mesh_size)
999 p2 = gmsh.model.occ.addPoint(xc[0], xc[1], xc[2] + h, mesh_size)
1002 gmsh.model.occ.synchronize()
1006 surfaces = gmsh.model.getEntities(2)
1009 com = gmsh.model.occ.getCenterOfMass(s[0], s[1])
1010 if abs(com[2] - xc[2]) < 1e-6:
1011 gmsh.model.mesh.embed(0, [p1], 2, s[1])
1012 elif abs(com[2] - (xc[2] + h)) < 1e-6:
1013 gmsh.model.mesh.embed(0, [p2], 2, s[1])
1016 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), mesh_size)
1019 gmsh.model.mesh.generate(3)
1025 gmsh.write(filename +
'.msh')
1027 gmsh.write(filename +
'.vtk')
1033 Create an annulus (ring) mesh, either symmetric or full.
1034 xc - center point coordinates [x, y, z]
1035 r_outer - radius of outer circle
1036 r_inner - radius of inner circle
1038 symmetric_mesh - if True, creates 1/4 mesh and mirrors it. If False, creates full annulus
1040 if r_inner >= r_outer:
1041 raise ValueError(
"Inner radius must be smaller than outer radius")
1044 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1047 xc_mesh = [0., 0., 0.]
1050 p1 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1], xc_mesh[2], h)
1051 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + r_outer, xc_mesh[1], xc_mesh[2], h)
1052 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r_outer, xc_mesh[2], h)
1053 p4 = gmsh.model.geo.addPoint(xc_mesh[0] + r_inner, xc_mesh[1], xc_mesh[2], h)
1054 p5 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + r_inner, xc_mesh[2], h)
1056 l1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
1057 l2 = gmsh.model.geo.addCircleArc(p4, p1, p5)
1058 l3 = gmsh.model.geo.addLine(p4, p2)
1059 l4 = gmsh.model.geo.addLine(p5, p3)
1061 c1 = gmsh.model.geo.addCurveLoop([l3, l1, -l4, -l2])
1062 s1 = gmsh.model.geo.addPlaneSurface([c1])
1064 gmsh.model.geo.synchronize()
1065 gmsh.model.mesh.generate(3)
1075 gmsh.model.mesh.removeDuplicateNodes()
1083 p1 = gmsh.model.geo.addPoint(xc[0], xc[1], xc[2], h)
1084 p2 = gmsh.model.geo.addPoint(xc[0] + r_outer, xc[1], xc[2], h)
1085 p3 = gmsh.model.geo.addPoint(xc[0], xc[1] + r_outer, xc[2], h)
1086 p4 = gmsh.model.geo.addPoint(xc[0] - r_outer, xc[1], xc[2], h)
1087 p5 = gmsh.model.geo.addPoint(xc[0], xc[1] - r_outer, xc[2], h)
1090 p6 = gmsh.model.geo.addPoint(xc[0] + r_inner, xc[1], xc[2], h)
1091 p7 = gmsh.model.geo.addPoint(xc[0], xc[1] + r_inner, xc[2], h)
1092 p8 = gmsh.model.geo.addPoint(xc[0] - r_inner, xc[1], xc[2], h)
1093 p9 = gmsh.model.geo.addPoint(xc[0], xc[1] - r_inner, xc[2], h)
1096 c1 = gmsh.model.geo.addCircleArc(p2, p1, p3)
1097 c2 = gmsh.model.geo.addCircleArc(p3, p1, p4)
1098 c3 = gmsh.model.geo.addCircleArc(p4, p1, p5)
1099 c4 = gmsh.model.geo.addCircleArc(p5, p1, p2)
1102 c5 = gmsh.model.geo.addCircleArc(p6, p1, p7)
1103 c6 = gmsh.model.geo.addCircleArc(p7, p1, p8)
1104 c7 = gmsh.model.geo.addCircleArc(p8, p1, p9)
1105 c8 = gmsh.model.geo.addCircleArc(p9, p1, p6)
1108 outer_loop = gmsh.model.geo.addCurveLoop([c1, c2, c3, c4])
1109 inner_loop = gmsh.model.geo.addCurveLoop([c5, c6, c7, c8])
1114 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
1117 gmsh.model.geo.synchronize()
1120 gmsh.model.addPhysicalGroup(2, [s1], 1)
1123 gmsh.model.mesh.generate(2)
1129 gmsh.write(filename +
'.msh')
1131 gmsh.write(filename +
'.vtk')
1135def 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):
1137 Create a rectangular mesh with a rectangular hole in the center (annulus rectangle).
1142 Center coordinates [x, y, z]
1144 Length of outer rectangle in x direction
1146 Length of outer rectangle in y direction
1148 Length of inner hole in x direction
1150 Length of inner hole in y direction
1154 Output filename without extension
1156 If True, also writes a VTK file
1157 symmetric_mesh : bool
1158 If True, creates 1/4 mesh and mirrors it. If False, creates full mesh
1162 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1166 xc_mesh = [0., 0., 0.]
1169 p1 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1], xc_mesh[2], h)
1170 p2 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h)
1171 p3 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + 0.5*Ly, xc_mesh[2], h)
1172 p4 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1], xc_mesh[2], h)
1173 p5 = gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] + 0.5*hole_Ly, xc_mesh[2], h)
1174 p6 = gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] + 0.5*hole_Ly, xc_mesh[2], h)
1177 l1 = gmsh.model.geo.addLine(p1, p2)
1178 l2 = gmsh.model.geo.addLine(p2, p3)
1179 l3 = gmsh.model.geo.addLine(p3, p6)
1180 l4 = gmsh.model.geo.addLine(p6, p5)
1181 l5 = gmsh.model.geo.addLine(p5, p4)
1182 l6 = gmsh.model.geo.addLine(p4, p1)
1185 cl = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4, l5, l6])
1188 s = gmsh.model.geo.addPlaneSurface([cl])
1191 gmsh.model.geo.synchronize()
1192 gmsh.model.mesh.generate(2)
1203 gmsh.model.mesh.removeDuplicateNodes()
1210 p1 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
1211 p2 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] - 0.5*Ly, xc[2], h)
1212 p3 = gmsh.model.geo.addPoint(xc[0] + 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
1213 p4 = gmsh.model.geo.addPoint(xc[0] - 0.5*Lx, xc[1] + 0.5*Ly, xc[2], h)
1216 p5 = gmsh.model.geo.addPoint(xc[0] - 0.5*hole_Lx, xc[1] - 0.5*hole_Ly, xc[2], h)
1217 p6 = gmsh.model.geo.addPoint(xc[0] + 0.5*hole_Lx, xc[1] - 0.5*hole_Ly, xc[2], h)
1218 p7 = gmsh.model.geo.addPoint(xc[0] + 0.5*hole_Lx, xc[1] + 0.5*hole_Ly, xc[2], h)
1219 p8 = gmsh.model.geo.addPoint(xc[0] - 0.5*hole_Lx, xc[1] + 0.5*hole_Ly, xc[2], h)
1222 l1 = gmsh.model.geo.addLine(p1, p2)
1223 l2 = gmsh.model.geo.addLine(p2, p3)
1224 l3 = gmsh.model.geo.addLine(p3, p4)
1225 l4 = gmsh.model.geo.addLine(p4, p1)
1228 l5 = gmsh.model.geo.addLine(p5, p6)
1229 l6 = gmsh.model.geo.addLine(p6, p7)
1230 l7 = gmsh.model.geo.addLine(p7, p8)
1231 l8 = gmsh.model.geo.addLine(p8, p5)
1234 outer_loop = gmsh.model.geo.addCurveLoop([l1, l2, l3, l4])
1235 inner_loop = gmsh.model.geo.addCurveLoop([l5, l6, l7, l8])
1238 s1 = gmsh.model.geo.addPlaneSurface([outer_loop, inner_loop])
1241 gmsh.model.geo.synchronize()
1242 gmsh.model.mesh.generate(2)
1248 gmsh.write(filename +
'.msh')
1250 gmsh.write(filename +
'.vtk')
1255def 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):
1257 Create a rectangular mesh with a rectangular hole in the center (annulus rectangle).
1262 Center coordinates [x, y, z]
1264 Length of outer rectangle in x direction
1266 Length of outer rectangle in y direction
1268 Length of inner hole in x direction
1270 Length of inner hole in y direction
1274 Output filename without extension
1276 If True, also writes a VTK file
1280 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1285 xc_mesh = [0., 0., 0.]
1287 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] - 0.5*Ly, xc_mesh[2], h))
1288 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h))
1289 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] + 0.5*Ly, xc_mesh[2], h))
1290 points.append(gmsh.model.geo.addPoint(xc_mesh[0] + 0.5*hole_Lx, xc_mesh[1] - 0.5*hole_Ly, xc_mesh[2], h))
1291 points.append(gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] - 0.5*hole_Ly, xc_mesh[2], h))
1292 points.append(gmsh.model.geo.addPoint(xc_mesh[0], xc_mesh[1] - 0.5*Ly, xc_mesh[2], h))
1295 for i
in range(len(points) - 1):
1296 lines.append(gmsh.model.geo.addLine(points[i], points[i + 1]))
1297 lines.append(gmsh.model.geo.addLine(points[-1], points[0]))
1298 cl = gmsh.model.geo.addCurveLoop(lines)
1299 s = gmsh.model.geo.addPlaneSurface([cl])
1300 gmsh.model.geo.synchronize()
1301 gmsh.model.mesh.generate(2)
1307 gmsh.model.mesh.removeDuplicateNodes()
1313 gmsh.write(filename +
'.msh')
1315 gmsh.write(filename +
'.vtk')
1319def 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):
1321 Create a 3D pipe mesh with specified axis, closed bottom and open top.
1322 The pipe is created by:
1323 1. Creating an outer cylinder
1324 2. Subtracting an inner cylinder to create walls
1325 3. Subtracting the top surface to create the opening
1330 Center coordinates [x, y, z] of the base center
1332 Axis vector defining pipe orientation [ax, ay, az]
1334 Length of the pipe along axis
1335 outer_radius : float
1336 Outer radius of the pipe
1337 wall_thickness : float
1338 Thickness of the pipe wall and bottom
1342 Output filename without extension
1344 If True, also writes a VTK file
1347 gmsh.option.setNumber(
"Mesh.MshFileVersion", 2.2)
1350 axis_norm = np.sqrt(axis[0]**2 + axis[1]**2 + axis[2]**2)
1352 raise ValueError(
"Axis vector cannot be zero")
1353 axis = [x/axis_norm
for x
in axis]
1356 l = length + wall_thickness
1357 outer_cylinder = gmsh.model.occ.addCylinder(xc[0], xc[1], xc[2],
1358 axis[0]*l, axis[1]*l, axis[2]*l,
1362 inner_cylinder = gmsh.model.occ.addCylinder(xc[0]+wall_thickness*axis[0], xc[1]+wall_thickness*axis[1], xc[2]+wall_thickness*axis[2],
1363 axis[0]*l, axis[1]*l, axis[2]*l,
1364 outer_radius - wall_thickness)
1368 dx = 2 * outer_radius
1369 box = gmsh.model.occ.addBox(xc[0] - dx, xc[1] - dx, xc[2] + l - wall_thickness,
1370 2*dx, 2*dx, 2*wall_thickness)
1373 if not (abs(axis[0]) < 1e-10
and abs(axis[1]) < 1e-10):
1376 rotation_axis = np.cross(z_axis, axis)
1377 rotation_angle = np.arccos(np.dot(z_axis, axis))
1380 gmsh.model.occ.rotate([(3, box)],
1381 xc[0], xc[1], xc[2],
1382 rotation_axis[0], rotation_axis[1], rotation_axis[2],
1386 pipe = gmsh.model.occ.cut([(3, outer_cylinder)], [(3, inner_cylinder), (3, box)])
1389 gmsh.model.occ.synchronize()
1392 gmsh.model.mesh.setSize(gmsh.model.getEntities(0), h)
1395 gmsh.model.mesh.generate(3)
1401 gmsh.write(filename +
'.msh')
1403 gmsh.write(filename +
'.vtk')
1409if __name__ ==
"__main__":
1412 test_meshes = [
'circle',
'ellipse',
'sphere',
'cuboid',
'ellipsoid',
'rectangle', \
1413 'hexagon',
'drum2d',
'triangle',
'polygon',
'cylindrical2d_wall', \
1414 'cylinder',
'annulus_circle',
'annulus_rectangle',
'open_rectangle',
'open_pipe']
1415 test_meshes = [
'open_pipe']
1418 for mesh
in test_meshes:
1419 if mesh ==
'circle':
1420 if symm_flag == 0
or symm_flag == 1:
1421 circle_mesh_symmetric(xc = [-3., -3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1422 if symm_flag == 0
or symm_flag == 2:
1423 circle_mesh_symmetric(xc = [-3., -3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1424 elif mesh ==
'ellipse':
1425 if symm_flag == 0
or symm_flag == 1:
1426 ellipse_mesh_symmetric(xc = [-1., -1., 0.], rx = 1., ry = 0.5, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1427 if symm_flag == 0
or symm_flag == 2:
1428 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)
1429 elif mesh ==
'sphere':
1430 if symm_flag == 0
or symm_flag == 1:
1431 sphere_mesh_symmetric(xc = [-5., -5., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1432 if symm_flag == 0
or symm_flag == 2:
1433 sphere_mesh_symmetric(xc = [-5., -5., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1434 elif mesh ==
'rectangle':
1435 if symm_flag == 0
or symm_flag == 1:
1436 rectangle_mesh_symmetric(xc = [1., 1., 0.], Lx = 1., Ly = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1437 if symm_flag == 0
or symm_flag == 2:
1438 rectangle_mesh_symmetric(xc = [1., 1., 0.], Lx = 1., Ly = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1439 elif mesh ==
'hexagon':
1440 if symm_flag == 0
or symm_flag == 1:
1441 hexagon_mesh_symmetric(xc = [3., 3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1442 if symm_flag == 0
or symm_flag == 2:
1443 hexagon_mesh_symmetric(xc = [3., 3., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1444 elif mesh ==
'drum2d':
1445 if symm_flag == 0
or symm_flag == 1:
1446 drum2d_mesh_symmetric(xc = [5., 5., 0.], r = 1., width = 0.5, h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1447 if symm_flag == 0
or symm_flag == 2:
1448 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)
1449 elif mesh ==
'triangle':
1450 if symm_flag == 0
or symm_flag == 1:
1451 triangle_mesh_symmetric(xc = [7., 7., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1452 if symm_flag == 0
or symm_flag == 2:
1453 triangle_mesh_symmetric(xc = [7., 7., 0.], r = 1., h = 0.1, filename =
'./' + mesh +
'_non_sym', vtk_out =
True, symmetric_mesh =
False)
1454 elif mesh ==
'polygon':
1458 v2 = [R*np.cos(0.5*theta), -R*np.sin(0.5*theta), 0.]
1459 v4 = [R*np.cos(0.5*theta), R*np.sin(0.5*theta), 0.]
1460 v3 = [R + a, 0., 0.]
1461 if symm_flag == 0
or symm_flag == 1:
1462 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)
1463 if symm_flag == 0
or symm_flag == 2:
1464 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)
1465 elif mesh ==
'cylindrical2d_wall':
1467 center=[0., 0., 0.],
1473 filename=
'./' + mesh +
'_sym',
1476 elif mesh ==
'cuboid':
1477 if symm_flag == 0
or symm_flag == 1:
1478 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)
1479 if symm_flag == 0
or symm_flag == 2:
1480 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)
1481 elif mesh ==
'ellipsoid':
1482 if symm_flag == 0
or symm_flag == 1:
1483 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)
1484 if symm_flag == 0
or symm_flag == 2:
1485 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)
1486 elif mesh ==
'cylinder':
1487 if symm_flag == 0
or symm_flag == 1:
1488 cylinder_mesh_symmetric(xc = [0., 0., 0.], r = 1., h = 2., mesh_size = 0.1, filename =
'./' + mesh +
'_sym', vtk_out =
True, symmetric_mesh =
True)
1489 if symm_flag == 0
or symm_flag == 2:
1490 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)
1491 elif mesh ==
'annulus_circle':
1492 if symm_flag == 0
or symm_flag == 1:
1494 if symm_flag == 0
or symm_flag == 2:
1495 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)
1496 elif mesh ==
'annulus_rectangle':
1497 if symm_flag == 0
or symm_flag == 1:
1498 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)
1499 if symm_flag == 0
or symm_flag == 2:
1500 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)
1501 elif mesh ==
'open_rectangle':
1502 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)
1503 elif mesh ==
'open_pipe':
1505 wall_thickness=0.2, h=0.1, filename=
'./' + mesh, vtk_out=
True)
1507 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)