示例#1
0
import hybmeshpack.hmscript as hm

outercont = hm.create_contour([[0, 0], [0.2, -0.6], [1, -1.3], [2, -1.3],
                               [2.5, -0.3], [2.6, 0.4], [1.5, 1], [0.4, 0.4],
                               [0, 0]])

faultline = hm.create_contour([[0, 1], [1.5, -0.5]])
w1 = [0.64, -0.11]
w2 = [1.54, 0.4]
gw1 = hm.add_unf_circ_grid(w1, 0.05, 16, 5, 1.2, False)
gw2 = hm.add_unf_circ_grid(w2, 0.05, 16, 5, 1.2, False)

faultline = hm.partition_contour(faultline, "const", 0.01, crosses=[outercont])
outercont = hm.matched_partition(outercont, 0.05, 0.5, [faultline])

hm.export_contour_vtk([outercont, faultline], "outer.vtk")

g = hm.pebi_fill(outercont, [faultline])
g = hm.unite_grids(g, [(gw1, 0.01), (gw2, 0.01)], buffer_fill='4')

hm.export_grid_vtk([g], "grid.vtk")
示例#2
0
    g1, c1,
    [[0, 0], [5, 0], [5, 1], [0, 1]],
    [[0, 0], [1, 0], [1, 1], [0, 1]],
    snap="shift_vertices", btypes="from_grid")
checkdict(
    hm.info_grid(a6),
    {'cell_types': {4: 100}, 'Nnodes': 121, 'Nedges': 220, 'Ncells': 100})
checkdict(
    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",
示例#3
0
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)
# 2) call build_boundary_grid1 procedure with explicitly defined perpendecular segmentation.
bnd1 = hm.build_boundary_grid1(cont5, [0, 0.01, 0.02, 0.03], "right")

# make final superposition
res = hm.unite_grids(imposed, [(bnd1, 0.05)])
# ******* see fig4

# now we can see the result in paraview
hm.export_grid_vtk(res, "pentagon.vtk")

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
if not hm.skewness(res)['ok']:
        raise Exception
示例#4
0
                               "left",
                               0.1,
                               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.
示例#5
0
文件: fullcyl.py 项目: cescjf/HybMesh
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])
p3 = hm.get_point(region_blay, vclosest=[hcyl / 2, 0])
p4 = hm.get_point(region_blay, vclosest=[Lx2, 0])
[b1, b2, b3, b4] = hm.extract_subcontours(region_blay, [p1, p2, p3, p4, p1])
b3 = hm.partition_contour(
    b3, "ref_weights", [step1, 0, step2, 1], start=p3)
b4 = hm.partition_contour(
    b4, "ref_points", [step2, p4, step2, pcross, step2, p1],
    keep_pts=[pcross])
mesh_blay = hm.add_custom_rect_grid("orthogonal", b3, b4, b1, b2)

# 5. meshing wake region
# 5.1 separation into transitional traingle and main region
p1 = [hcyl / 2 + Lx2_rib_blay, 0]
p2 = [p1[0] + hcyl / 2, Ly_wake_reg]
ctmp = hm.create_contour([p1, p2])
region_wake = hm.unite_contours([region_wake, ctmp])
rr = hm.decompose_contour(region_wake)
region_wake_trans = hm.pick_contour(pcross, rr)
region_wake_main = hm.pick_contour([Lx2, 0], rr)
p2 = hm.get_point(region_wake_trans, vclosest=[Lx2, Ly])
示例#6
0
文件: rrj2.py 项目: cescjf/HybMesh
c_top = hm.pick_contour([687, 2096], dcm)
c_mid = hm.pick_contour([282, 1803], dcm)
c_lappendix = hm.pick_contour([252, 1617], dcm)
c_rappendix = hm.pick_contour([1164, 1611], dcm)
c_bot = hm.pick_contour(c[0], dcm)
c_lchairs = hm.pick_contour(c[24], dcm)
c_rchairs = hm.pick_contour([1390, 1105], dcm)

# bottom grid: g1
[bc, rc, t1, t2, t3, t4, t5, t6, t7, lc] = hm.extract_subcontours(
    c_bot, [c[i] for i in [0, 1, 2, 18, 17, 6, 5, 16, 15, 3, 0]])
t2 = hm.create_contour([c[18], c[17]])
t6 = hm.create_contour([c[16], c[15]])
tc = hm.unite_contours([t1, t2, t3, t4, t5, t6, t7])

lc = hm.partition_contour(lc, "ref_weights", bstep_main, 90, start=c[0])
tc = hm.partition_contour(tc,
                          "ref_weights",
                          bstep_main,
                          180,
                          start=c[2],
                          keep_pts=[c[0], c[1], c[2], c[3], c[5], c[6]])
g1 = hm.add_custom_rect_grid("orthogonal", lc, tc, rc, bc)
g1cont = hm.grid_bnd_to_contour(g1, False)
hm.export_grid_vtk(g1, "g1.vtk")

# left appendix: g4
bs = [0, step_bl, 2 * step_bl, 3 * step_bl]
[b1, b2] = hm.extract_subcontours(c_lappendix, [c[10], c[9], c[10]])
b1 = hm.partition_contour(b1,
                          "const",
示例#7
0
文件: cave1.py 项目: cescjf/HybMesh
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]])
c5 = hm.create_contour([[paft[0], 100], paft])
c3 = hm.connect_subcontours([c4, c1, c3, c2, c5], [2], shiftnext=False)
[c3] = hm.decompose_contour(c3)
bopt = hm.BoundaryGridOptions(c3,
                              blay,
                              bnd_stepping="no",
                              start_point=pbef,
                              end_point=paft)
示例#8
0
from hybmeshpack import hmscript

# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# unit segment
linear_segment = hmscript.create_contour([[0, 0], [1, 0]])

# divide into segments of length 0.03.
# part1 has 33 equal segments
part1 = hmscript.partition_contour(linear_segment, "const", step=0.03)

# partition with refinement towards the center of input line
# segments near end points have length 0.1, at the center - 0.01,
# and between them linear size transition is applied
part2 = hmscript.partition_contour(
    linear_segment,
    "ref_points",
    step=[0.1, [0, 0], 0.01, [0.5, 0], 0.1, [1.0, 0]])
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

print "partition contour example"
if hmscript.info_contour(part1)['Nedges'] != 33:
    raise Exception
if hmscript.info_contour(part2)['Nedges'] != 26:
    raise Exception
示例#9
0
# === build boundary grid around the foil
# First we make custom repartition of the foil to use
# all contour vertices for boundary grid.
# Assign recommended partition distance to points on foil contour:
foilpart = [
    0.01,
    [0.0, 0.0],  # frontal point
    0.03,
    [1.0, -0.17],  # backward point
    0.01,
    [0.25, 0.64],  # upper boundary below vortex generator (finer)
    0.05,
    [0.5, -0.17],  # lower boundary (coarser)
]
foil = hm.partition_contour(foil, "ref_points", foilpart)

# create boundary grid around foil using contour partition
# obtained above as a horizontal boundary grid partition
foilgrid_bo = hm.BoundaryGridOptions(foil,
                                     direction="right",
                                     bnd_stepping="no")
foilgrid_bo.incremental_partition(0.002, 1.5, 7)
foilgrid = hm.build_boundary_grid(foilgrid_bo)

# === boundary grid around vortex generator
vgen = hm.add_circ_contour([0.25, 0.12], 0.015, 32, bcirc)
# build boundary grid
vgen_bo = hm.BoundaryGridOptions(vgen,
                                 direction="right",
                                 bnd_step=0.006,
示例#10
0
hm.remove_all()

print "domain reflection"
c1 = hm.create_contour([[0, 0], [1, 0], [2, 1]])
c2 = hm.add_rect_contour([1, 1], [3, 2])
g3 = hm.add_unf_ring_grid([1, 0], 1, 3, 16, 3)
hm.reflect_geom([c1, c2, g3], [0, 0], [1, 1])
hm.remove_all()

print "contour partition"
i1 = hm.create_contour([[0, 0], [1, 0], [2, 1]])
i2 = hm.add_rect_contour([0, 0], [1, 1], [0, 1, 0, 0])
i3 = hm.add_circ_contour([0, 0], 1, 200)
i4 = hm.create_contour([[0, 0], [0.5, 0], [1, 0], [1, 1]])

c1 = hm.partition_contour(i1, "const", 0.18)
c2 = hm.partition_contour(i1, "const", 0.18, 180)
check(hm.info_contour(c1)['Nedges'] == 14)
check(hm.info_contour(c2)['Nedges'] == 13)

c1 = hm.partition_contour(i2, "const", 0.18, 100)
c2 = hm.partition_contour(i2, "const", 0.18, 100, True)
check(hm.info_contour(c1)['Nedges'] == 24)
check(hm.info_contour(c2)['Nedges'] == 23)
hm.export_contour_vtk(c1, "c1.vtk")
hm.export_contour_vtk(c2, "c2.vtk")

c1 = hm.partition_contour(i1, "ref_points", [0.18, [0, 0]])
c2 = hm.partition_contour(i1, "ref_points", [0.01, [0, 0], 0.3, [1, 0]])
c3 = hm.partition_contour(i3, "ref_points", [0.01, [-1, -1], 0.3, [0, 1]])
check(hm.info_contour(c1)['Nedges'] == 14)