Пример #1
0
    g1, c, [[0, 0]], [p1], algo="direct_laplace")

# hm.export_grid_vtk(g2, "g2.vtk")
# hm.export_grid_vtk(g3, "g3.vtk")
# hm.export_grid_vtk(g4, "g4.vtk")
# hm.export_grid_vtk(g5, "g5.vtk")
# hm.export_contour_vtk(c, "ctarget.vtk")
# hm.export_contour_vtk(g1, "cbase.vtk")
# hm.export_grid_vtk(g5, "gtar.vtk")
# hm.export_contour_vtk(g5, "ctar.vtk")
hm.remove_all()

g1 = hm.add_unf_ring_grid([0, 0], 1, 1.5, 32, 12, 0.95)
c1 = hm.add_circ_contour([0, 0], 1, 100)
cm = hm.add_rect_contour([-30, -30], [0, 30])
c1 = hm.clip_domain(c1, cm, "intersection")
hm.scale_geom(c1, 300, 100)
cm = hm.add_circ_contour([0, 0], 1, 100)
c1 = hm.clip_domain(c1, cm, "union")
c2 = hm.add_circ_contour([-2, 0], 0.3, 100)
hm.scale_geom(c2, 100, 30)
c = hm.unite_contours([c1, c2])

gtmp = hm.map_grid(g1, c, [[-1.5, 0], [-1, 0]], [[-3, 0], [-2, 0.01]],
                   algo="direct_laplace", return_invalid=True)
hm.export_grid_vtk(gtmp, "gtmp.vtk")

g2 = hm.map_grid(g1, c, [[-1.5, 0], [-1, 0]], [[-3, 0], [-2.3, 0]],
                 algo="direct_laplace")

Пример #2
0
# ======================= Meshing procedure
# 1. channel region
region_channel = hm.add_rect_contour([-Lx1, 0], [Lx2, Ly],
                                     [bbottom, boutput, btop, binput])

# 2. rib boundary layer region
cyl = hm.add_circ_contour([0, 0], hcyl / 2, 128, brib)
[bcyl] = hm.copy_geom([cyl])
xpc = 100. * (hcyl + Lx1_rib_blay + Lx2_rib_blay) / (hcyl)
ypc = 100. * (hcyl + 2 * Ly_rib_blay) / (hcyl)
hm.scale_geom(bcyl, xpc, ypc)
xmv = (Lx2_rib_blay - Lx1_rib_blay) / 2.
hm.move_geom(bcyl, xmv, 0.)
region_blay = hm.unite_contours([cyl, bcyl])
region_blay = hm.clip_domain(region_blay, region_channel, "intersection")

# 3. wake region
x0 = 1.1 * hcyl / 2
x1 = Lx_wake_reg
y0 = 0
y10 = 0.9 * (Ly_rib_blay + hcyl / 2)
y11 = Ly_wake_reg
region_wake = hm.create_contour([[x0, y0], [x1, y0], [x1, y11], [x0, y10],
                                 [x0, y0]])
region_wake = hm.clip_domain(region_wake, bcyl, "difference")
pcross = hm.get_point(region_wake, vclosest=[-Lx1, Ly])

# 4. meshing bcyl region
p1 = hm.get_point(region_blay, vclosest=[-Lx1, 0])
p2 = hm.get_point(region_blay, vclosest=[-hcyl / 2, 0])
Пример #3
0
from hybmeshpack import hmscript as hm
hm.check_compatibility("0.5.0", 2)

ncirc = 256  # precision of circle contours

# I. Build body parts grids ***************************************************

# build body contour as intersection of two circles
circ1 = hm.add_circ_contour3([6, 0], [-6, 0], 0.08, ncirc)
circ2 = hm.add_circ_contour3([-6, 0], [6, 0], 0.08, ncirc)
bodyc = hm.clip_domain(circ1, circ2, "intersection")
# assemble a prototype grid for body by attaching triangles to left and
# right side of a rectangle.
ntri, nspan = 12, 60  # vertical and horizontal partition of rectangle
g3l = hm.add_triangle_grid([0, 0], [-0.5, 0.5], [0, 1], ntri)
g3r = hm.add_triangle_grid([5, 0], [5.5, 0.5], [5, 1], ntri)
g4 = hm.add_unf_rect_grid([0, 0], [5, 1], nspan, ntri)
# Grids in triangle and rectangle areas have same partition at contact line
# so we can simply unite them with zero buffer size
gb = hm.unite_grids(g4, [(g3l, 0), (g3r, 0)])
# Map grid at hexagon area on body area so that points at the acute angles
# of base grid contour be translated into acute angle vertices of body contour.
# We use snap="no" since there is no need to preserve initial body contour
# precisely.
body = hm.map_grid(gb,
                   bodyc, [[-0.5, 0.5], [5.5, 0.5]], [[-6, 0], [6, 0]],
                   snap="no")

# build tail area by clipping of three circle areas
circ1 = hm.add_circ_contour3([0, 0], [-2, 2], 0.2, ncirc)
circ2 = hm.add_circ_contour3([-2.5, -2.3], [0, 0], 0.1, ncirc)
Пример #4
0
[b1, b2] = hm.extract_subcontours(c_lappendix, [c[10], c[9], c[10]])
b1 = hm.partition_contour(b1,
                          "const",
                          3 * step_bl,
                          angle0=180,
                          keep_pts=[[286.399, 1647.06], [231.428, 1608.5]])
b1 = hm.unite_contours([b1, b2])
bgo = hm.BoundaryGridOptions(b1,
                             bs,
                             "left",
                             3 * step_bl,
                             "no",
                             start_point=c[10],
                             end_point=c[9])
g41 = hm.build_boundary_grid(bgo)
ctri = hm.clip_domain(b1, g41, "difference", False)
[c1, c2] = hm.extract_subcontours(ctri, [c[9], c[10], c[9]])
c1 = hm.partition_contour(c1, "const", 4 * step_bl)
ctri = hm.unite_contours([c1, c2])
g42 = hm.triangulate_domain(ctri, fill='4')
g4 = hm.unite_grids(g41, [(g42, 0)])

# right appendix: g5
g5 = hm.map_grid(g4,
                 c_rappendix,
                 [c[9], c[10], [231.5, 1608.5], [286.399, 1647.06]],
                 [c[11], c[12], [1164, 1611], [1109.88, 1649.44]],
                 "no",
                 "vertex",
                 is_reversed=True)
Пример #5
0
                           [pi/2., hcave/rad])[1:]+\
      hm.partition_segment(pi-alpha, pi, hhormin/rad, hblayer/rad)[1:]+\
      hm.partition_segment(pi, 2.*pi, hblayer/rad, hblayer/rad,
                           [1.5*pi, hcave/rad])[1:]

rads = [0, rad - layheight]
for b in list(reversed(blay))[1:]:
    rads.append(rad - b)

g = hm.add_unf_circ_grid(pc, custom_arcs=arc, custom_rads=rads, is_trian=False)

gfiller = hm.add_circ_rect_grid(pc, rad - 1.3 * layheight, internal_step)
g = hm.unite_grids(g, [(gfiller, buf)])

chord = hm.add_circ_contour2(p2, [pc[0], p1[1] + shiftlay], p1, 512)
mapping_area = hm.clip_domain(chord, g, "intersection")
hm.export_contour_vtk(mapping_area, "c1.vtk")

g2 = hm.map_grid(g, mapping_area, [p1, p2], [p1, p2], algo="direct_laplace")

pbef, paft = [p1[0] - layheight, 0], [p2[0] + layheight, 0]
c1 = hm.create_contour([pbef, p1])
c1 = hm.partition_contour(c1,
                          "ref_weights", [hblayer, 1, hhormin, 0],
                          start=p1)
c2 = hm.create_contour([p2, paft])
c2 = hm.partition_contour(c2,
                          "ref_weights", [hhormin, 0, hblayer, 1],
                          start=p2)
[c3] = hm.extract_subcontours(g2, [p2, p1])
c4 = hm.create_contour([pbef, [pbef[0], 100]])
Пример #6
0
    [1, 1, 1, 1, 1, 2, 1, 0])
c12 = hm.create_contour(
    [[-20, -20], [20, -20], [20, 20], [-20, 20], [-20, 0], [-20, -20]], 22)
c13 = hm.unite_contours([c11, c12])
[c14] = hm.simplify_contour(c13, simplify=True, angle=60, separate=False)
[c15, c16] = hm.simplify_contour(c13, simplify=True, angle=60, separate=True)
check_cont(c14, 9, 9, [5, 4], {22: 4, 0: 1, 1: 3, 2: 1})
check_cont(c15, 5, 5, [5], {0: 1, 1: 3, 2: 1})
check_cont(c16, 4, 4, [4], {22: 4})
check(len(hm.registered_contours()) == 16)
hm.remove_all()

print "domain clipping"
c1 = hm.create_contour([[0, 0], [100, 100], [0, 100], [0, 0]], 5)
c2 = hm.add_circ_contour([2, 2], 15, 30, 2)
c3 = hm.clip_domain(c1, c2, "union")
c4 = hm.clip_domain(c1, c2, "difference")
c5 = hm.clip_domain(c1, c2, "intersection")
c6 = hm.clip_domain(c1, c2, "xor")
ar3 = hm.domain_area(c3)
ar4 = hm.domain_area(c4)
ar5 = hm.domain_area(c5)
ar6 = hm.domain_area(c6)
check(abs(ar6 + ar5 - ar3) < 1e-6)
check(abs(ar4 + hm.domain_area(c2) - ar3) < 1e-6)
check_cont(c6, 37, 37, [9, 28], {2: 32, 5: 5})
hm.remove_all()

g1 = hm.add_unf_rect_grid([0, 0], [1, 1], 10, 10)
c1 = hm.grid_bnd_to_contour(g1, False)
hm.remove_geom(g1)