Exemple #1
0
def get_v_h_list(vol_id_list, chktop=False):
    """
    return the lists of the cubit ID of vertical/horizontal
    surface and vertical/horizontal curves
    where v/h is defined by the distance of the z normal component from
    the axis direction the parameter cfg.tres is the threshold as
    for example if
    -tres <= normal[2] <= tres
    then the surface is vertical
    #
    usage: surf_or,surf_vertical,list_curve_or,
        list_curve_vertical,bottom,top = get_v_h_list(list_vol,chktop=False)
    """
    #
    tres = 0.3

    try:
        _ = len(vol_id_list)
    except:
        vol_id_list = [vol_id_list]
    surf_vertical = []
    surf_or = []
    list_curve_vertical = []
    list_curve_or = []
    #
    #
    for id_vol in vol_id_list:
        lsurf = cubit.get_relatives("volume", id_vol, "surface")
        for k in lsurf:
            normal = cubit.get_surface_normal(k)
            center_point = cubit.get_center_point("surface", k)
            if -1 * tres <= normal[2] <= tres:
                surf_vertical.append(k)
                lcurve = cubit.get_relatives("surface", k, "curve")
                list_curve_vertical = list_curve_vertical + list(lcurve)
            else:
                surf_or.append(k)
                lcurve = cubit.get_relatives("surface", k, "curve")
                list_curve_or = list_curve_or + list(lcurve)
    for x in list_curve_or:
        try:
            list_curve_vertical.remove(x)
        except:
            pass

    # find the top and the bottom surfaces
    k = surf_or[0]
    center_point = cubit.get_center_point("surface", k)[2]
    center_point_top = center_point
    center_point_bottom = center_point
    top = k
    bottom = k
    for k in surf_or[1:]:
        center_point = cubit.get_center_point("surface", k)[2]
        if center_point > center_point_top:
            center_point_top = center_point
            top = k
        elif center_point < center_point_bottom:
            center_point_bottom = center_point
            bottom = k
    # check that a top surface exists
    # it assume that the z coord of the center point
    if chktop:
        k = lsurf[0]
        vertical_centerpoint_top = cubit.get_center_point("surface", k)[2]
        vertical_zmax_box_top = cubit.get_bounding_box('surface', k)[7]
        normal_top = cubit.get_surface_normal(k)
        top = k
        for k in lsurf:
            vertical_centerpoint = cubit.get_center_point("surface", k)[2]
            vertical_zmax_box = cubit.get_bounding_box('surface', k)[7]
            normal = cubit.get_surface_normal(k)
            check = (vertical_centerpoint >= vertical_centerpoint_top) and (
                     vertical_zmax_box >= vertical_zmax_box_top) and (
                     normal >= normal_top)
            if check:
                top = k
        if top in surf_vertical:
            surf_vertical.remove(top)
        if top not in surf_or:
            surf_or.append(top)
    # if more than one surf is on the top, I get all the surfaces that are in
    # touch with top surface but not the vertical surfaces
    surftop = list(cubit.get_adjacent_surfaces(
        "surface", top))  # top is included in the list
    for s in surf_vertical:
        try:
            surftop.remove(s)
        except:
            pass
    top = surftop
    # check that all the surf are Horizontal or vertical
    surf_all = surf_vertical + surf_or
    if len(surf_all) != len(lsurf):
        print 'not all the surf are horizontal or vertical, check the normals'
        print 'list of surfaces: ', surf_all
        print 'list of vertical surface', surf_vertical
        print 'list of horizontal surface', surf_or

    bottom = [bottom]
    return surf_or, surf_vertical, list_curve_or, \
        list_curve_vertical, bottom, top
Exemple #2
0
def get_v_h_list(vol_id_list, chktop=False):
    """return the lists of the cubit ID of vertical/horizontal surface and vertical/horizontal curves
    where v/h is defined by the distance of the z normal component from the axis direction
    the parameter cfg.tres is the threshold as for example if 
    -tres <= normal[2] <= tres 
    then the surface is vertical
    #
    usage: surf_or,surf_vertical,list_curve_or,list_curve_vertical,bottom,top = get_v_h_list(list_vol,chktop=False)
    """
    #
    tres = 0.3

    try:
        nvol = len(vol_id_list)
    except:
        nvol = 1
        vol_id_list = [vol_id_list]
    surf_vertical = []
    surf_or = []
    list_curve_vertical = []
    list_curve_or = []
    #
    #
    for id_vol in vol_id_list:
        lsurf = cubit.get_relatives("volume", id_vol, "surface")
        for k in lsurf:
            normal = cubit.get_surface_normal(k)
            center_point = cubit.get_center_point("surface", k)
            if -1 * tres <= normal[2] <= tres:
                surf_vertical.append(k)
                lcurve = cubit.get_relatives("surface", k, "curve")
                list_curve_vertical = list_curve_vertical + list(lcurve)
            else:
                surf_or.append(k)
                lcurve = cubit.get_relatives("surface", k, "curve")
                list_curve_or = list_curve_or + list(lcurve)
    for x in list_curve_or:
        try:
            list_curve_vertical.remove(x)
        except:
            pass

    #find the top and the bottom surfaces
    k = surf_or[0]
    center_point = cubit.get_center_point("surface", k)[2]
    center_point_top = center_point
    center_point_bottom = center_point
    top = k
    bottom = k
    for k in surf_or[1:]:
        center_point = cubit.get_center_point("surface", k)[2]
        if center_point > center_point_top:
            center_point_top = center_point
            top = k
        elif center_point < center_point_bottom:
            center_point_bottom = center_point
            bottom = k
    #check that a top surface exists
    #it assume that the z coord of the center point
    if chktop:
        k = lsurf[0]
        vertical_centerpoint_top = cubit.get_center_point("surface", k)[2]
        vertical_zmax_box_top = cubit.get_bounding_box('surface', k)[7]
        normal_top = cubit.get_surface_normal(k)
        top = k
        for k in lsurf:
            vertical_centerpoint = cubit.get_center_point("surface", k)[2]
            vertical_zmax_box = cubit.get_bounding_box('surface', k)[7]
            normal = cubit.get_surface_normal(k)
            check = (vertical_centerpoint >= vertical_centerpoint_top) and (
                vertical_zmax_box >= vertical_zmax_box_top) and (normal >=
                                                                 normal_top)
            if check:
                top = k
        if top in surf_vertical:
            surf_vertical.remove(top)
        if top not in surf_or:
            surf_or.append(top)
    #if more than one surf is on the top, I get all the surfaces that are in touch with top surface but not the vertical surfaces
    surftop = list(cubit.get_adjacent_surfaces(
        "surface", top))  #top is included in the list
    for s in surf_vertical:
        try:
            surftop.remove(s)
        except:
            pass
    top = surftop
    #check that all the surf are Horizontal or vertical
    surf_all = surf_vertical + surf_or
    if len(surf_all) != len(lsurf):
        print 'not all the surf are horizontal or vertical, check the normals'
        print 'list of surfaces: ', surf_all
        print 'list of vertical surface', surf_vertical
        print 'list of horizontal surface', surf_or

    bottom = [bottom]
    return surf_or, surf_vertical, list_curve_or, list_curve_vertical, bottom, top