Example #1
0
def getNodesBoundInSelectedVols(target_list):
    """
    Return nodes bound in selected CUBIT volumes.
        
    Parameters:
        * target_list List of indices of target nodes
                    
    Return:
        List of indices of nodes bound by the volumes
    """

    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)

    in_list = []

    for v in target_list:
        cords = cubit.get_nodal_coordinates(v)
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            status = body.point_containment(cords)
            if status == 1 or status == 2:
                in_list.append(v)
                break
    cubit.delete_group(group_id)
    return in_list
Example #2
0
def getNodesBoundInSelectedVols(mesh, scale=1e-6):
    """
    Return nodes bound in selected CUBIT volumes.
        
    Parameters:
        * mesh        Associated Tetmesh object created in STEPS
        * scale       LENGTH scale from the CUBIT gemoetry to real geometry.
                    e.g. a radius of 10 in CUBIT to a radius of 1 micron in STEPS, scale is 1e-7.
                    By default the scale is 1e-6, i.e. 1 unit in CUBIT equals 1 micron in STEPS.
                    
    Return:
        list of STEPS indices of vertex nodes
    """

    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)
    nverts = mesh.nverts

    in_list = []

    for v in range(nverts):
        cords = mesh.getVertex(v)
        cords = [x / scale for x in cords]
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            status = body.point_containment(cords)
            if status == 1 or status == 2:
                in_list.append(v)
                break
    cubit.delete_group(group_id)
    return in_list
def getNodesBoundInSelectedVols(target_list):
    """
    Return nodes bound in mouse selected CUBIT volumes.
        
    Parameters:
        * target_list List of indices of target nodes
                    
    Return:
        List of indices of nodes bound by the volumes
    """
    
    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)
    
    in_list = []
    
    for v in target_list:
        cords = cubit.get_nodal_coordinates(v)
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            status = body.point_containment(cords)
            if status == 1 or status == 2:
                in_list.append(v)
                break
    cubit.delete_group(group_id)
    return in_list
Example #4
0
def WebcutTool(body_list_in, tool_ID, delete=False):
    import cubit
    print("body_list_in: ", body_list_in)
    print("tool_ID: ", tool_ID)
    ### delete group 'webcut_group' if it exists
    cubit.delete_group(cubit.get_id_from_name('webcut_group'))
    ### webcut
    cmd = 'webcut volume '
    for i in body_list_in:
        cmd += '%i ' % i
    cmd += 'tool volume %i group_results' % tool_ID
    cubit.cmd(cmd)
    ### identify the grain and the outside
    ### I need a list of the volume IDs in webcut_group, but cubit.get_group_volumes returns a t-uple
    tmp_IDs = cubit.get_id_from_name('webcut_group')
    webcut_group_IDs = [vol_id for vol_id in cubit.get_group_volumes(tmp_IDs)]
    webcut_group_IDs.append(tool_ID)
    ovlp = cubit.get_overlapping_volumes(webcut_group_IDs)
    ### ovlp now contains the overlap and the tool
    ### remove tool_id to get tool_list_out
    tmp_list = [vol_id for vol_id in ovlp if not vol_id == tool_ID]
    tool_list_out = tmp_list  # just so that I can make a call with tool_ID = tool_list_out
    ### remove tool_list_out and tool_ID from ovlp
    body_list_out = [
        vol_id for vol_id in webcut_group_IDs if vol_id not in ovlp
    ]
    print("body_list_out: ", body_list_out)
    ### delete the tool of requested
    if delete:
        cubit.cmd('delete volume %i' % tool_ID)
    ### Be nice and clean up
    cubit.delete_group(cubit.get_id_from_name('webcut_group'))
    return body_list_out, tool_list_out
Example #5
0
def WebcutTool2(body_list_in, tool_ID, delete=False):
    import cubit
    print("body_list_in: ", body_list_in)
    print("tool_ID: ", tool_ID)
    ### delete group 'webcut_group' if it exists
    cubit.delete_group(cubit.get_id_from_name('webcut_group'))
    ### webcut
    cmd = 'webcut volume '
    for i in body_list_in:
        cmd += '%i ' % i
    cmd += 'tool volume %i group_results' % tool_ID
    cubit.cmd(cmd)
Example #6
0
def getSelectedNodes():
    """
    Return the CUBIT indices of the selected vertex nodes.
        
    Parameters:
        None
        
    Return:
        cubit_ids
    """
    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    idxs = cubit.get_group_nodes(group_id)
    cubit.delete_group(group_id)
    return idxs
def getSelectedTets():
    """
    Return the CUBIT indices of mouse selected tetrahedrons.
    
    Parameters:
        None
        
    Return:
        cubit_ids
    """
    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    idxs = cubit.get_group_tets(group_id)
    cubit.delete_group(group_id)
    return idxs
Example #8
0
def getSelectedTris(tri_proxy):
    """
    Return the STEPS indices and CUBIT indices of the selected triangles.
    
    Parameters:
        * tri_proxy   Triangle element proxy generated by STEPS mesh importing function
    
    Return:
        (steps_ids, cubit_ids)
    """
    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    cubit_ids = cubit.get_group_tris(group_id)
    steps_ids = [tri_proxy.getSTEPSID(id) for id in cubit_ids]
    cubit.delete_group(group_id)
    return (steps_ids, cubit_ids)
Example #9
0
def getTrisBoundInSelectedVols(mesh, scale=1e-6):
    """
    Return triangles bound in selected CUBIT volumes.
        
    Parameters:
        * mesh        Associated Tetmesh object created in STEPS
        * scale       LENGTH scale from the CUBIT gemoetry to real geometry.
                    e.g. a radius of 10 in CUBIT to a radius of 1 micron in STEPS, scale is 1e-7.
                    By default the scale is 1e-6, i.e. 1 unit in CUBIT equals 1 micron in STEPS.
                    
    Return:
        list of STEPS indices of triangles
    """

    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)
    ntris = mesh.ntris

    in_list = []

    for t in range(ntris):
        verts = mesh.getTri(t)
        with_in = True
        cords = []
        for v in verts:
            c = mesh.getVertex(v)
            c = [x / scale for x in c]
            cords.append(c)
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            within = True
            for cord in cords:
                status = body.point_containment(cord)
                if status == 0:
                    within = False
                    break
            if within:
                in_list.append(t)
                break
    cubit.delete_group(group_id)
    return in_list
Example #10
0
def getTrisBoundInSelectedVols(target_list):
    """
    Return triangles bound in selected CUBIT volumes.
        
    Parameters:
        * target_list List of indices of target triangles
                    
    Return:
        List of indices of triangles bound by the volumes
    """

    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)

    in_list = []

    for t in target_list:
        verts = cubit.get_connectivity("tri", t)
        with_in = True
        cords = []
        for v in verts:
            c = cubit.get_nodal_coordinates(v)
            cords.append(c)
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            within = True
            for cord in cords:
                status = body.point_containment(cord)
                if status == 0:
                    within = False
                    break
            if within:
                in_list.append(t)
                break
    cubit.delete_group(group_id)
    return in_list
def getTrisOverlapSelectedVols(target_list):
    """
    Return triangles overlap with mouse selected CUBIT volumes.
        
    Parameters:
        * target_list List of indices of target triangles
                    
    Return:
        List of indices of triangles overlap with the volumes
    """
    
    group_id = cubit.create_new_group()
    cubit.silent_cmd("group %i add selection" % (group_id))
    volume_ids = cubit.get_group_volumes(group_id)
    
    in_list = []
    
    for t in target_list:
        verts = cubit.get_connectivity("tri", t)
        cords = []
        for v in verts:
            c = cubit.get_nodal_coordinates(v)
            cords.append(c)
        for vol_id in volume_ids:
            volume = cubit.volume(vol_id)
            body = volume.bodies()[0]
            within = False
            for cord in cords:
                status = body.point_containment(cord)
                if status == 1:
                    within = True
                    break
            if within:
                in_list.append(t)
                break
    cubit.delete_group(group_id)
    return in_list