-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mesh.py
More file actions
64 lines (48 loc) · 1.96 KB
/
Copy pathtest_mesh.py
File metadata and controls
64 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import gmsh
# Geometry (m)
Lx = 0.078
t_s = 0.002032
t_l = 0.005363582
Htot = t_s + t_l
def generate_mesh(mesh_size=2e-4, fname="2D.msh"):
gmsh.initialize()
gmsh.model.add("LIQUID_SOLID_HOLE")
y_int = t_s
# solid
gmsh.model.occ.addRectangle(0.0, 0.0, 0.0, Lx, t_s, tag=1)
# liquid
gmsh.model.occ.addRectangle(0.0, y_int, 0.0, Lx, Htot - y_int, tag=2)
gmsh.model.occ.fragment([(2, 1)], [(2, 2)])
gmsh.model.occ.synchronize()
solid = gmsh.model.addPhysicalGroup(2, [1], tag=1)
gmsh.model.setPhysicalName(2, solid, "solid")
liquid = gmsh.model.addPhysicalGroup(2, [2], tag=2)
gmsh.model.setPhysicalName(2, liquid, "liquid")
boundary_liquid = set(
gmsh.model.getBoundary([(2, 2)], oriented=False, recursive=False)
)
boundary_solid = set(
gmsh.model.getBoundary([(2, 1)], oriented=False, recursive=False)
)
# liquid-solid interface (wet contact only; bubble removes the middle)
ls_curves = list(boundary_liquid.intersection(boundary_solid))
ls_tags = [c[1] for c in ls_curves]
gmsh.model.addPhysicalGroup(1, ls_tags, tag=101)
gmsh.model.setPhysicalName(1, 101, "liquid_solid_interface")
# surface
print("Curves:", gmsh.model.getEntities(1))
left_boundary = gmsh.model.addPhysicalGroup(1, [4, 7], tag=31)
gmsh.model.setPhysicalName(1, left_boundary, "left_boundary")
right_boundary = gmsh.model.addPhysicalGroup(1, [2, 5], tag=32)
gmsh.model.setPhysicalName(1, right_boundary, "right_boundary")
top_boundary = gmsh.model.addPhysicalGroup(1, [6], tag=33)
gmsh.model.setPhysicalName(1, top_boundary, "top_boundary")
bottom_boundary = gmsh.model.addPhysicalGroup(1, [1], tag=34)
gmsh.model.setPhysicalName(1, bottom_boundary, "bottom_boundary")
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", mesh_size)
gmsh.model.mesh.generate(2)
gmsh.write(fname)
gmsh.finalize()
if __name__ == "__main__":
generate_mesh()
# gmsh.fltk.run()