当前位置: 首页>>代码示例>>Python>>正文


Python BDF.get_card_ids_by_card_types方法代码示例

本文整理汇总了Python中pyNastran.bdf.bdf.BDF.get_card_ids_by_card_types方法的典型用法代码示例。如果您正苦于以下问题:Python BDF.get_card_ids_by_card_types方法的具体用法?Python BDF.get_card_ids_by_card_types怎么用?Python BDF.get_card_ids_by_card_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyNastran.bdf.bdf.BDF的用法示例。


在下文中一共展示了BDF.get_card_ids_by_card_types方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: extract_surface_patches

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import get_card_ids_by_card_types [as 别名]
def extract_surface_patches(bdf_filename, starting_eids, theta_tols=40.):
    """
    Extracts the unique patches of a model based on a list of starting
    element ids and surface curvature.

    Parameters
    ----------
    bdf_filename : str
        the bdf_filename
    starting_eids : List[int]
        a list of starting element ids
    theta_tols : List[float]
        a list of tolerances for each element id
        (e.g. the nose has a different tolerance than the base)

    Returns
    -------
    model : BDF()
        the BDF object
    groups : List[Set[int]]
        the list of element ids in each group

    .. warning:: only supports CTRIA3 & CQUAD4
    """
    if isinstance(theta_tols, (float, float32)):
        theta_tols = [theta_tols] * len(starting_eids)

    model = BDF(debug=False)
    model.read_bdf(bdf_filename)

    # get data for all shell elemenst
    card_types = ['CTRIA3', 'CQUAD4']
    out = model.get_card_ids_by_card_types(card_types,
                                           reset_type_to_slot_map=False,
                                           stop_on_missing_card=False)
    shell_eids = hstack([out[card_type] for card_type in card_types])
    shell_eids.sort()

    # set_shell_eids = set(shell_eids)
    neids = len(shell_eids)
    assert neids > 0, neids
    normals = np.zeros((neids, 3), dtype='float32')
    for i, eid in enumerate(shell_eids):
        element = model.elements[eid]
        normal = element.Normal()
        normals[i, :] = normal

    #print('shell_eids = %s' % shell_eids)

    # get neighboring shell elements
    out_map = model._get_maps(eids=shell_eids)
    edge_to_eid_map = out_map[0]

    eid_to_eid_map = defaultdict(set)
    #if 1:
    for edge, eids in iteritems(edge_to_eid_map):
        for eid_a in eids:
            for eid_b in eids:
                eid_to_eid_map[eid_a].add(eid_b)
    # else:
        # for edge, eids in iteritems(edge_to_eid_map):
            # for eid_a in eids:
                # for eid_b in eids:
                    # if eid_a < eid_b:
                        # eid_to_eid_map[eid_a].add(eid_b)
                        # eid_to_eid_map[eid_b].add(eid_a)

    #print('\neid_to_eid_map:')
    #for eid, eids in iteritems(eid_to_eid_map):
        #print('%-6s %s' % (eid, eids))

    groups = []
    # now trace the model
    for starting_eid, theta_tol in zip(starting_eids, theta_tols):
        print('starting_eid = %s' % starting_eid)
        group = set([])
        check = set([starting_eid])
        while check:
            eid = next(iter(check))
            #print('  eid = %s' % eid)
            neighboring_eids = eid_to_eid_map[eid]
            #print('    neighbors = %s' % neighboring_eids)

            # don't double check eids
            neigboring_eids_to_check = array(list(neighboring_eids - group), dtype='int32')
            nneighbors = len(neigboring_eids_to_check)
            if nneighbors == 0:
                check.remove(eid)
                continue
            assert nneighbors > 0, neigboring_eids_to_check

            i = searchsorted(shell_eids, eid)
            #assert len(i) > 0, 'eid=%s cant be found' % eid
            local_normal = normals[i, :]

            # find the normals
            i = searchsorted(shell_eids, neigboring_eids_to_check)
            assert len(i) > 0, 'eid=%s cant be found' % eid
            normal = normals[i, :]

#.........这里部分代码省略.........
开发者ID:saullocastro,项目名称:pyNastran,代码行数:103,代码来源:dev_utils.py

示例2: export_to_vtk_filename

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import get_card_ids_by_card_types [as 别名]
def export_to_vtk_filename(bdf_filename, op2_filename, vtk_filename):
    with open(vtk_filename, 'w') as vtk_file:
        vtk_file.write('# vtk DataFile Version 3.1\n')
        vtk_file.write('created by pyNastran\n')
        #vtk_file.write('BINARY\n')
        vtk_file.write('ASCII\n')
        vtk_file.write('DATASET UNSTRUCTURED_GRID\n')

        etype_map = {
            # line
            'CDAMP1' : 3,
            'CDAMP2' : 3,
            'CDAMP3' : 3,
            'CDAMP4' : 3,
            'CELAS1' : 3,
            'CELAS2' : 3,
            'CELAS3' : 3,
            'CELAS4' : 3,
            'CBAR' : 3,
            'CBEAM' : 3,
            'CROD' : 3,
            'CONROD' : 3,
            'CTUBE' : 3,

            'CTRIA3' : 5, # triangle
            'CQUAD4' : 9,  # quad

            # quadratic
            'CTRIA6' : 22,  # quadratic triangle
            #'CQUAD8' : 23/28/30,

            'CTETRA' : 10,
            'CPENTA' : 13, # wedge
            'CPYRAM' : 14,
            'CHEXA' : 12, # hex

            # quadratic solids
            #'CTETRA' : 64,
            #'CPENTA' : 65, # wedge
            #'CPYRAM' : 66,
            #'CHEXA' : 67, # hex
        }

        bdf = BDF()
        bdf.read_bdf(bdf_filename)
        op2 = OP2()
        op2.read_op2(op2_filename)

        out = bdf.get_card_ids_by_card_types()
        #print('cards = [', ', '.join(sorted(out.keys())), ']')
        grids = sorted(out['GRID'])
        spoint = sorted(out['SPOINT'])
        epoint = sorted(out['EPOINT'])
        ngrid = len(grids)
        nspoint = len(spoint)
        nepoint = len(epoint)
        nnodes = ngrid + nspoint + nepoint

        ncrod = len(out['CROD'])
        nconrod = len(out['CONROD'])
        nctube = len(out['CTUBE'])
        nline = ncrod + nconrod + nctube

        nctria3 = len(out['CTRIA3'])
        ncquad4 = len(out['CQUAD4'])
        nctria6 = len(out['CTRIA6'])
        ncquad8 = len(out['CQUAD8'])
        nshell = nctria3 + ncquad4 + nctria6 + ncquad8

        nctetra4 = len(out['CTETRA'])
        ncpyram5 = len(out['CPYRAM'])
        ncpenta6 = len(out['CPENTA'])
        nchexa8 = len(out['CHEXA'])
        nctetra10 = 0
        ncpyram8 = 0
        ncpenta15 = 0
        nchexa20 = 0
        nsolid = (nctetra4 + ncpyram5 + ncpenta6 + nchexa8 +
                  nctetra10 + ncpyram8 + ncpenta15 + nchexa20)

        nelements = nline + nshell + nsolid
        nproperties = nelements
        etypes = [
            'CELAS1', 'CELAS2', 'CELAS3', 'CELAS4',
            'CDAMP', 'CDAMP', 'CDAMP', 'CDAMP',
            'CROD', 'CONROD', 'CBAR', 'CBEAM',
            'CFAST',

            'CTRIA3', 'CQUAD4', 'CTRIA3', 'CQUAD8',

            'CTETRA', 'CPENTA', 'CPYRAM', 'CHEXA',
        ]
        for etype in etypes:
            if etype in out:
                ne = len(out[etype])
                nelements += ne

        # SPOINT & EPOINT are implicitly defined
        xyz_cid0 = zeros((nnodes, 3), dtype='float32')
        nids = zeros(nnodes, dtype='float32')
#.........这里部分代码省略.........
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:103,代码来源:export_to_vtk.py


注:本文中的pyNastran.bdf.bdf.BDF.get_card_ids_by_card_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。