예제 #1
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)
예제 #2
0
from hybmeshpack import hmscript as hm
from hybmeshpack.hmscript import _dbg as hmdbg
hm.check_compatibility("0.4.0")

g1 = hm.add_unf_rect_grid([0, 0], [1, 1], 10, 10)
hm.set_boundary_type(g1,
                     bfun=lambda x0, y0, x1, y1, bt: {
                         y0 + y1 == 0: 1,
                         x0 + x1 == 2: 2,
                         y0 + y1 == 2: 3,
                         x0 + x1 == 0: 4
                     }[1])
print "extrusion with zero bc"
s1 = hm.extrude_grid(g1, [0, 0.1, 0.2], 0, 0, 0)
hm.export3d_grid_vtk(s1, "s1.vtk", "s2.vtk")
hmdbg.check_ascii_file(9760293401399903439, "s1.vtk")
hmdbg.check_ascii_file(9133727113521198898, "s2.vtk")
hm.remove_geom(s1)

print "extrusion with side bc from contour"
s1 = hm.extrude_grid(g1, [0, 0.1], 0, 0, None)
hm.export3d_grid_vtk(s1, None, "s2.vtk")
hmdbg.check_ascii_file(17055111601829986000, "s2.vtk")
hm.remove_geom(s1)

print "extrusion with non-zero at zfaces and side bc from contour"
s1 = hm.extrude_grid(g1, [-0.1, 0.1, 22], 8, 10, None)
hm.export3d_grid_vtk(s1, None, "s2.vtk")
hmdbg.check_ascii_file(4721469755399912982, "s2.vtk")

print "extrusion with function at bottom z face"
예제 #3
0
파일: fullcyl.py 프로젝트: cescjf/HybMesh
from hybmeshpack import hmscript as hm
hm.check_compatibility('0.4.6', 2)

# boundary features
brib = hm.add_boundary_type(1, "rib")
bbottom = hm.add_boundary_type(2, "bottom")
binput = hm.add_boundary_type(3, "input")
boutput = hm.add_boundary_type(4, "output")
btop = hm.add_boundary_type(5, "top")

# ===================== Options
# area sizes
Lx1 = 16.66
Lx2 = 25.
Ly = 3.33
Lz = 8.33
hcyl = 0.5

# auxiliary sizes
Lx1_rib_blay = 0.15
Lx2_rib_blay = 0.7
Ly_rib_blay = 0.3
Lx_wake_reg = 15.
Ly_wake_reg = 1.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
예제 #4
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)
예제 #5
0
from hybmeshpack import hmscript as hm

# This script was created for hybmesh 0.2.1.
# If running version of hybmesh is not compatible with this version
# an exception will be raised at this line.
hm.check_compatibility("0.2.1", 2)

# Register separate boundary types for edges on tube, roof and window.
# All other boundary edges will get default 0 boundary type
btube = hm.add_boundary_type(1, "Tube")
broof = hm.add_boundary_type(2, "Roof")
bwindow = hm.add_boundary_type(3, "Window")

# First we create a house silhouette and assign boundary types for it.
# They will be carried to all grids derived from this contour
house_cont = hm.create_contour(
    [[0, 0], [1, 0], [1, 0.7], [0.5, 1.3], [0, 0.7], [0, 0]],
    [0, 0, broof, broof, 0])

# Build a background rectangular mesh and cut a house silhouette from it.
# Now 'house' grid bears boundary features of 'house_cont'
back_grid = hm.add_unf_rect_grid([0, 0], [1, 2], 50, 100)
house = hm.exclude_contours(back_grid, house_cont, "outer")

# A set of ugly cells near the roof appeared as a result of previous operation.
# To get rid of 'em we build a short single layered boundary grid near the
# roof section and make a union. 'roof' grid inherits its boundary types
# from 'house_cont' which is its source and delivers 'em to 'house_wroof' object.
oproof = hm.BoundaryGridOptions(house_cont,
                                start_point=[1, 0.7],
                                end_point=[0, 0.7],
예제 #6
0
from hybmeshpack import hmscript as hm
from hybmeshpack.hmscript._dbg import checkdict

hm.check_compatibility("0.4.5", 2)


def check(cond):
    import traceback
    if not cond:
        print "TEST FAILED <<<<<<<<<<<<<<<<<<<<<<<"
        traceback.print_stack()


def check_cont(cont, nn, ne, scont, btypes):
    info = hm.info_contour(cont)
    check(info['Nnodes'] == nn)
    check(info['Nedges'] == ne)
    check(cmp(sorted(info['subcont']), sorted(scont)) == 0)
    for k in btypes.keys():
        check(info['btypes'][k] == btypes[k])


def check_grid(grid, nn, ne, nc, ct):
    info = hm.info_grid(grid)
    check(info['Nnodes'] == nn)
    check(info['Nedges'] == ne)
    check(info['Ncells'] == nc)
    for k in ct.keys():
        check(info['cell_types'][k] == ct[k])