Exemple #1
0
    hm.info_contour(a6),
    {'btypes': {1: 40}, 'Nnodes': 40, 'subcont': [40], 'Nedges': 40})

print "rectangle grid from 2 straight contours: linear algo"
left_line = hm.create_contour([[0, 0], [0, 1]], 1)
bottom_line = hm.create_contour([[0, 0], [2, 0]], 2)

left_line_part = hm.partition_contour(left_line, "const", 0.2)
bottom_line_part = hm.partition_contour(
    bottom_line, "ref_points",
    [0.2, [0, 0], 0.01, [1, 0], 0.08, [2, 0]])
g1 = hm.add_custom_rect_grid("linear", left_line_part, bottom_line_part)
check(hm.info_contour(g1)['btypes'] == {1: 10, 2: 90})

print "rectangle grid from 4 straight contours: linear algo"
[top_line_part] = hm.copy_geom(bottom_line_part)
hm.move_geom(top_line_part, 0, 1.0)
hm.set_boundary_type(top_line_part, 3)
right_line = hm.create_contour([[2, 0], [2, 1]], 4)
right_line_part = hm.partition_contour(right_line, "ref_points",
                                       [0.1, [2, 0], 0.3, [2, 1]])
g1 = hm.add_custom_rect_grid(
    "linear",
    left_line_part, bottom_line_part,
    right_line_part, top_line_part)
check(hm.info_contour(g1)['btypes'] == {1: 5, 2: 45, 3: 45, 4: 5})

print "linear with disconnected right side"
pts = []
for i in range(100):
    x = 2 + 0.05 * math.sin(4.0 * math.pi * i / 99)
Exemple #2
0
from hybmeshpack import hmscript as hm
hm.check_compatibility('0.5.0')

# create a substrate 20x20 square grid
sqr = hm.add_unf_rect_grid([0, 0], [1, 1], 20, 20)

# create tube grids
# 1) create a prototype
tube_proto = hm.add_unf_rect_grid([0, 0], [0.15, 0.5], 10, 20)
# 2) copy, replace and rotate to build left, right, bottom tubes.
[tube_left, tube_right, tube_bot] = hm.copy_geom([tube_proto] * 3)
hm.move_geom([tube_left, tube_right], 0.425, 1.0)
hm.move_geom([tube_bot], 0.425, -0.5)
hm.rotate_geom([tube_left], -45, [0.5, 0.5])
hm.rotate_geom([tube_right], 45, [0.5, 0.5])

# exclude pentagon from base grid
cont5 = hm.create_contour([[0.3, 0.6], [0.35, 0.4], [0.65, 0.4],
                            [0.7, 0.6], [0.5, 0.7], [0.3, 0.6]])
exsqr = hm.exclude_contours(sqr, [cont5], "inner")
# ******* see fig2

# make series of grid superpositions with defined buffer sizes
imposed = hm.unite_grids(exsqr, [(tube_left, 0.05),
                                 (tube_right, 0.05),
                                 (tube_bot, 0.1)])
# ******* see fig3

# create a boundary grid prototype around the pentagon.
# 1) make partition of pentagon contour with constant step
cont5 = hm.partition_contour(cont5, "const", 0.02)
Exemple #3
0
# step sizes
step0 = 0.03  # lowest step in the walls boundary layers
step1 = 0.03  # step in the boudary layer straight behind the rib
step2 = 0.02 # outer rib boundary region step
step3 = 0.15 # maximum wake region step, maximum wall boundary step
step4 = 0.25  # largest step

# ======================= 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],
Exemple #4
0
hmdbg.check(all(a == b for a, b in zip(zg2, hm.registered_grids())))
hmdbg.check(all(a == b for a, b in zip(zs3, hm.registered_surfaces())))
hmdbg.check(all(a == b for a, b in zip(zg3, hm.registered_grids3d())))
hmdbg.check(hm.registered_btypes() == [(0,
                                        'default-boundary'), (15,
                                                              'boundary15')])
hm.load_project("../external_files/empty.hmp")

print "export 2d to fluent"
bleft = hm.add_boundary_type(1, "bleft")
bright = hm.add_boundary_type(2, "bright")
bbot = hm.add_boundary_type(3, "bbot")
btop = hm.add_boundary_type(4, "btop")
g1 = hm.add_unf_rect_grid([0, 0], [1, 1], 10, 10)
g2 = hm.add_triangle_grid([0.3, -0.4], [0.5, 0.2], [0.7, -0.4], 10)
[g3] = hm.copy_geom(g2)
hm.reflect_geom(g3, [0, 0.5], [1, 0.5])
g4 = hm.unite_grids(g1, [(g2, 0.05), (g3, 0.05)])
hm.set_boundary_type(g4,
                     bfun=lambda x0, y0, x1, y1, b: {
                         True: 0,
                         x0 + x1 == 0: 1,
                         x0 + x1 == 2: 2,
                         y0 + y1 == -0.8: 3,
                         y0 + y1 == 2.8: 4
                     }[True])
hm.export_grid_vtk(g4, "g1.vtk")
hm.export_contour_vtk(g4, "c1.vtk")
hmdbg.check_ascii_file(15697319238564148717, "g1.vtk", "dev")
hmdbg.check_ascii_file(16408920837426241157, "c1.vtk", "dev")
hm.export_grid_msh(g4, "g1.msh")
Exemple #5
0
                               start_point=[5, -0.5],
                               end_point=[5.45, -0.36],
                               project_to="corner")
# shut down acute angle algorithm in order to obtain grid which lies strictly
# within body contour at the bottom point
btopt.range_angles[0] = 0
jgrid = hm.build_boundary_grid(btopt)

# gills areas are constructed by a boundary grid built around
# contours which are constructed by two circles intersection
circ1 = hm.add_circ_contour3([2.7, -0.4], [2.7, 0.4], 0.4, ncirc)
circ2 = hm.add_circ_contour3([2.7, -0.4], [2.7, 0.4], 1.2, ncirc)
gillc = hm.clip_domain(circ2, circ1, "difference")
gillc = hm.partition_contour(gillc, "const", 0.1)
gills = hm.build_boundary_grid1(gillc, [0, 0.1], "right")
[gills2, gills3] = hm.copy_geom([gills] * 2)
hm.move_geom(gills2, -0.5, 0)
hm.move_geom(gills3, 0.5, 0)
# since gills grids have no intersection area, their union
# does nothing but assembling three grids into single connectivity table.
gills = hm.unite_grids(gills, [(gills2, 0), (gills3, 0)])

# an eye is built as a ring grid.
eye = hm.add_unf_ring_grid([4.7, 0.3], 0.05, 0.1, 5, 1)

# II. Coupling grids **********************************************************

# Fins and the body are not tightly connected and direct superposition
# procedure may give bad results. To fix that we snap body grid to those fins.
p1 = hm.get_point(fin1, vclosest=[-1.2, 1.4])
p2 = hm.get_point(fin1, vclosest=[0.5, 1.4])
Exemple #6
0
hm.move_geom(gtube, 0.7, 0.9)

# after combining of 'house_wroof' and 'gtube' the resulting grid
# boundary edges will get their features from both parent grids
house_wtube = hm.unite_grids(house_wroof, [(gtube, 0.05)])

# first we create an outer window frame by building an external
# boundary grid around square contour
win_cont = hm.add_rect_contour([-0.15, -0.15], [0.15, 0.15])
op1 = hm.BoundaryGridOptions(win_cont, bnd_step=0.02, direction='right')
op1.uniform_partition(0.03, 2)
win_frame1 = hm.build_boundary_grid([op1])

# now we create a internal window frames
win_frame2 = hm.add_unf_rect_grid([-0.02, -0.15], [0.02, 0.15], 3, 30)
[win_frame3] = hm.copy_geom([win_frame2])
hm.rotate_geom(win_frame2, 90)

# to assemble a window we make an superposition of internal frames to outer one
# and assigns 'Window' boundary type to the whole resulting grid.
window = hm.unite_grids(win_frame1, [(win_frame2, 0.02), (win_frame3, 0.02)])
hm.set_boundary_type(window, bwindow)

# finally we move window to its position according to house and
# impose it to it. Note that in order to purge area within window spans
# option 'empty_holes=True' is used.
hm.move_geom(window, 0.5, 0.4)
house_final = hm.unite_grids(house_wtube, [(window, 0.05)], empty_holes=True)

# now we can check quality of resulting grid by calculating its skewness
skew = hm.skewness(house_final)
Exemple #7
0
# hm.export_contour_vtk(g3, "c3.vtk")
# hm.export_grid_vtk(g4, "g4.vtk")
# hm.export_contour_vtk(g4, "c4.vtk")
# hm.export_grid_vtk(g5, "g5.vtk")
# hm.export_contour_vtk(g5, "c5.vtk")
# hm.export_grid_vtk(g6, "g6.vtk")
# hm.export_contour_vtk(g6, "c6.vtk")
check(hm.skewness(g3)['ok'])
check(hm.skewness(g4)['ok'])
check(hm.info_grid(g5)['cell_types'].keys() == [4])
check(hm.info_grid(g6)['cell_types'].keys() == [4])
hm.remove_all()

g1 = hm.add_unf_rect_grid([0, 0], [10, 3], 50, 15)
g2 = hm.add_unf_rect_grid([0, -1], [2, 0], 10, 5)
[g3] = hm.copy_geom(g2)
hm.move_geom(g3, 8, 0)
g1 = hm.unite_grids(g1, [(g2, 0), (g3, 0)])
hm.set_boundary_type(g1, 1)
g2 = hm.add_unf_rect_grid([0, -2], [10, -0.5], 15, 3)
hm.set_boundary_type(g2, 2)
hm.rotate_geom([g1, g2], 37)
g3 = hm.unite_grids(g1, [(g2, 0.1)])
g4 = hm.unite_grids(g1, [(g2, 0.5)])
g5 = hm.unite_grids(g1, [(g2, 1)])
g6 = hm.unite_grids(g1, [(g2, 2)])
check(hm.info_grid(g3)['cell_types'][4] == 835)
check(hm.info_grid(g4)['cell_types'][4] == 795)
check(hm.info_grid(g5)['cell_types'][4] == 711)
check(hm.info_grid(g6)['cell_types'][4] == 509)
Exemple #8
0
                 ali, [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0.5]],
                 [c[15], c[16], p1, p2, [-590, 1477]],
                 project_to="vertex",
                 algo="inverse_laplace")

# right input: g3
p0 = hm.get_point(g1cont, eclosest=c[18])
p1 = hm.get_point(c_bot, vclosest=[1785.79, 1489.68])
p2 = hm.get_point(c_bot, vclosest=[1776.04, 1489.65])
p3 = hm.get_point(g1cont, eclosest=c[17])
p4 = hm.get_point(g1cont, eclosest=[1748.54, 1481.69])
p5 = hm.get_point(g1cont, eclosest=[1742, 1482])
[c0, c1, c2, c4] = hm.extract_subcontours(c_bot, [p0, p1, p2, p3, p4], "line")
c3 = hm.create_contour([p0, p3])
c5 = hm.create_contour([p4, p5])
[c6] = hm.copy_geom(c4)
hm.scale_geom([c6], 150, 250)
ar1 = hm.connect_subcontours([c3, c0, c1, c2], fix=[0, 2], close="yes")
ar2 = hm.connect_subcontours([c3, c4, c5, c6], fix=[0, 2], close="yes")
go = hm.add_unf_rect_grid(nx=3, ny=10)
gb = hm.add_rect_contour([0, 0], [1, 1], [0, 0, binput_right2, 0])
go = hm.exclude_contours(go, gb, "outer")
g31 = hm.map_grid(go,
                  ar1, [[0, 0], [1, 0], [1, 1], [0, 1], [1, 0.5]],
                  [p3, p0, p1, p2, [1774.22, 1483.7]],
                  project_to="vertex",
                  algo="inverse_laplace")
go = hm.add_unf_rect_grid(nx=3, ny=15)
g32 = hm.map_grid(go,
                  ar2, [[0, 0], [1, 0], [1, 1], [0, 1]], [p4, p5, p0, p3],
                  project_to="vertex",
Exemple #9
0
hm.set_boundary_type(g2, 1)
hm.set_boundary_type(g3, 4)
g2 = hm.unite_grids(g2, [(g3, 0)])

# main area
bot = hm.create_contour([[0, 0], pbef, paft, [x2, 0]])
bot = hm.partition_contour(bot, algo="const", step=hmain, angle0=-1)
left = map(
    lambda x: [0, x], blay[:-1] +
    hm.partition_segment(layheight, y2, hblayer, hmin,
                         [y2 / 2., hmain, y2 - layheight, hblayer]))
left = hm.create_contour(left)
outh = hm.get_point(left,
                    vclosest=[0,
                              paft[1] + layheight + shiftlay + 2 * hmain])[1]
[right] = hm.copy_geom(left)
[top] = hm.copy_geom(bot)
hm.set_boundary_type(left, 2)
hm.set_boundary_type(right, 3)
hm.set_boundary_type(bot, 4)
hm.set_boundary_type(top, 5)
gmain = hm.add_custom_rect_grid("linear", left, bot, right, top)

outcont = hm.add_rect_contour(pbef, [paft[0], outh])
gmain = hm.exclude_contours(gmain, outcont, "inner")

#final unite
gout = hm.unite_grids(gmain, [(g2, 0)])
hm.export_contour_vtk(gout, "c2.vtk")
cc = hm.simplify_contour(gout, simplify=False, separate=True)
filler = hm.pick_contour([pc[0], outh], cc)