Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test():
geom = pygmsh.opencascade.Geometry()
rectangle = geom.add_rectangle(
[-1.0, -1.0, 0.0], 2.0, 2.0, corner_radius=0.2, char_length=0.05
)
disk1 = geom.add_disk([-1.2, 0.0, 0.0], 0.5)
disk2 = geom.add_disk([+1.2, 0.0, 0.0], 0.5, 0.3)
union = geom.boolean_union([rectangle, disk1, disk2])
disk3 = geom.add_disk([0.0, -0.9, 0.0], 0.5)
disk4 = geom.add_disk([0.0, +0.9, 0.0], 0.5)
flat = geom.boolean_difference([union], [disk3, disk4])
geom.extrude(flat, [0, 0, 0.3])
ref = 1.1742114942
mesh = pygmsh.generate_mesh(geom)
def test():
geom = pygmsh.opencascade.Geometry(
characteristic_length_min=0.1, characteristic_length_max=0.1
)
p0 = geom.add_point([-0.5, -0.5, 0], 0.01)
p1 = geom.add_point([+0.5, -0.5, 0], 0.01)
p2 = geom.add_point([+0.5, +0.5, 0], 0.01)
p3 = geom.add_point([-0.5, +0.5, 0], 0.01)
l0 = geom.add_line(p0, p1)
l1 = geom.add_line(p1, p2)
l2 = geom.add_line(p2, p3)
l3 = geom.add_line(p3, p0)
ll0 = geom.add_line_loop([l0, l1, l2, l3])
square_builtin = geom.add_plane_surface(ll0)
square_opencascade = geom.add_rectangle([0, 0, 0], 1.0, 1.0)
geom.boolean_difference([square_opencascade], [square_builtin])
def test():
geom = pygmsh.opencascade.Geometry(
characteristic_length_min=2.0, characteristic_length_max=2.0
)
rect1 = geom.add_rectangle([10.0, 0.0, 0.0], 20.0, 40.0, corner_radius=5.0)
rect2 = geom.add_rectangle([0.0, 10.0, 0.0], 40.0, 20.0, corner_radius=5.0)
disk1 = geom.add_disk([14.5, 35.0, 0.0], 1.85)
disk2 = geom.add_disk([25.5, 5.0, 0.0], 1.85)
rect3 = geom.add_rectangle([10.0, 30.0, 0.0], 10.0, 1.0)
rect4 = geom.add_rectangle([20.0, 9.0, 0.0], 10.0, 1.0)
r1 = geom.add_rectangle([9.0, 0.0, 0.0], 21.0, 20.5, corner_radius=8.0)
r2 = geom.add_rectangle([10.0, 00.0, 0.0], 20.0, 19.5, corner_radius=7.0)
diff1 = geom.boolean_difference([r1], [r2])
r22 = geom.add_rectangle([9.0, 10.0, 0.0], 11.0, 11.0)
inter1 = geom.boolean_intersection([diff1, r22])
def test():
geom = pygmsh.opencascade.Geometry()
geom.add_wedge([0.0, 0.0, 0.0], [1.0, 1.0, 1.0], top_extent=0.4, char_length=0.1)
ref = 0.7
mesh = pygmsh.generate_mesh(geom)
assert abs(compute_volume(mesh) - ref) < 1.0e-2 * ref
return mesh
def test_intersection():
geom = pygmsh.opencascade.Geometry(
characteristic_length_min=0.1, characteristic_length_max=0.1
)
rectangle = geom.add_rectangle([-1.0, -1.0, 0.0], 2.0, 2.0)
disk_w = geom.add_disk([-1.0, 0.0, 0.0], 0.5)
disk_e = geom.add_disk([+1.0, 0.0, 0.0], 0.5)
geom.boolean_intersection([rectangle, disk_w, disk_e])
ref = 0.7803612
mesh = pygmsh.generate_mesh(geom)
assert abs(compute_volume(mesh) - ref) < 1.0e-2 * ref
return mesh
def geom(self, lcar: float) -> Geometry:
geom = Geometry()
geom.add_ellipsoid([0.]*3, self.semiaxes, lcar)
return geom
def _old_logo():
geom = pygmsh.opencascade.Geometry(
characteristic_length_min=0.5, characteristic_length_max=0.5
)
container = geom.add_rectangle([0.0, 0.0, 0.0], 10.0, 10.0)
letter_i = geom.add_rectangle([2.0, 2.0, 0.0], 1.0, 4.5)
i_dot = geom.add_disk([2.5, 7.5, 0.0], 0.6)
disk1 = geom.add_disk([6.25, 4.5, 0.0], 2.5)
disk2 = geom.add_disk([6.25, 4.5, 0.0], 1.5)
letter_o = geom.boolean_difference([disk1], [disk2])
geom.boolean_difference([container], [letter_i, i_dot, letter_o])
mesh = pygmsh.generate_mesh(geom)
X, cells = mesh.points, mesh.cells