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


Python assign_type.components_or_blank函数代码示例

本文整理汇总了Python中pyNastran.bdf.bdf_interface.assign_type.components_or_blank函数的典型用法代码示例。如果您正苦于以下问题:Python components_or_blank函数的具体用法?Python components_or_blank怎么用?Python components_or_blank使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: add_card

    def add_card(cls, card, comment=''):
        conid = integer(card, 1, 'conid')
        gids = []
        constraints = []
        enforced = []

        fields = card.fields(0)
        nfields = len(fields)

        i = 1
        for ifield in range(2, nfields, 8):
            grid = integer(card, ifield, 'G%i' % i)
            component = components_or_blank(card, ifield + 1, 'constraint%i' % i, 0)  # scalar point
            if i == 1:
                enforcedi = double(card, ifield + 2, 'enforced%i' % i)
                if enforcedi == 0.0:
                    raise RuntimeError('enforced1 must be nonzero; enforcedi=%r' % enforcedi)
            else:
                enforcedi = double_or_blank(card, ifield + 2, 'enforced%i' % i, 0.0)
            gids.append(grid)
            constraints.append(component)
            enforced.append(enforcedi)
            i += 1

            if ifield + 4 > nfields and i != 2:
                # if G2 is empty (it's ifield+4 because nfields is length based and not loop friendly)
                break
            grid = integer(card, ifield + 3, 'G%i' % i)
            component = components_or_blank(card, ifield + 4, 'constraint%i' % i, 0)  # scalar point
            enforcedi = double_or_blank(card, ifield + 5, 'enforced%i' % i)
            gids.append(grid)
            constraints.append(component)
            enforced.append(enforcedi)
            i += 1
        return MPC(conid, gids, constraints, enforced, comment=comment)
开发者ID:marcinch18,项目名称:pyNastran,代码行数:35,代码来源:constraints.py

示例2: add_card

    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        nid0 = integer(card, 2, 'nid0')
        # component 0 means an SPOINT/EPOINT
        c = components_or_blank(card, 3, 'components_0', 0)
        b0 = double_or_blank(card, 4, 'b0', 0.)
        b1 = double_or_blank(card, 5, 'b1', 0.)
        b2 = double_or_blank(card, 6, 'b2', 0.)

        nfields = len(card) - 9
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1

        nids = []
        components = []
        a = []
        for irow in range(nrows):
            j = irow * 8 + 9
            #ifield = irow + 1
            nid = integer(card, j, 'grid_%i' % (irow + 1))
            component = components_or_blank(card, j + 1, 'components_%i' % (irow + 1), 0)
            a0 = double_or_blank(card, j + 2, 'a0_%i' % (irow + 1), 0.)
            a1 = double_or_blank(card, j + 3, 'a1_%i' % (irow + 1), 0.)
            a2 = double_or_blank(card, j + 4, 'a2_%i' % (irow + 1), 0.)
            nids.append(nid)
            components.append(component)
            a.append([a0, a1, a2])
        return TF(sid, nid0, c, b0, b1, b2, nids, components, a,
                  comment=comment)
开发者ID:hurlei,项目名称:pyNastran,代码行数:30,代码来源:dynamic.py

示例3: add_card

 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     ga = integer(card, 2, 'ga')
     gb = integer(card, 3, 'gb')
     cma = components_or_blank(card, 4, 'cma')
     cmb = components_or_blank(card, 5, 'cmb')
     alpha = double_or_blank(card, 6, 'alpha', 0.0)
     assert len(card) <= 7, 'len(RROD card) = %i\ncard=%s' % (len(card), card)
     return RROD(eid, ga, gb, cma, cmb, alpha, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:9,代码来源:rigid.py

示例4: add_card

 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     ga = integer(card, 2, 'ga')
     gb = integer(card, 3, 'gb')
     cna = components_or_blank(card, 4, 'cna')
     cnb = components_or_blank(card, 5, 'cnb')
     cma = components_or_blank(card, 6, 'cma')
     cmb = components_or_blank(card, 7, 'cmb')
     alpha = double_or_blank(card, 8, 'alpha', 0.0)
     assert len(card) <= 9, 'len(RBAR card) = %i' % len(card)
     return RBAR(eid, ga, gb, cna, cnb, cma, cmb, alpha, comment=comment)
开发者ID:watkinrt,项目名称:pyNastran,代码行数:11,代码来源:rigid.py

示例5: get_spc_constraint

def get_spc_constraint(card, i):
    if i == 0:
        constraint_id = integer(card, 1, 'sid')
        node_id = integer(card, 2, 'G1')
        dofs = components_or_blank(card, 3, 'C1', 0)
        enforced_motion = double_or_blank(card, 4, 'D1', 0.0)
    elif i == 1:
        constraint_id = integer(card, 1, 'sid')
        node_id = integer_or_blank(card, 5, 'G2')
        dofs = components_or_blank(card, 6, 'C2', 0)
        enforced_motion = double_or_blank(card, 7, 'D2', 0.0)
    else:
        raise RuntimeError('i =', i)

    return constraint_id, node_id, dofs, enforced_motion
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:15,代码来源:spc.py

示例6: add

    def add(self, card, comment=''):
        #self.model.log.debug('RBE2.add')
        i = self.i
        #if comment:
            #self._comment = comment
        eid = integer(card, 1, 'element_id')
        gn = integer(card, 2, 'gn')
        cm = components_or_blank(card, 3, 'cm')
        #assert gn is not None, 'gn=%s' % self.gn
        #assert cm is not None, 'cm=%s' % self.cm

        self.element_id[i] = eid
        self.gn[i] = gn
        self.cm[i] = cm

        alpha = integer_or_double(card, len(card) - 1, 'alpha')
        if isinstance(alpha, float):
            # the last field is not part of Gmi
            self.alpha[i] = alpha
            n = 1
        else:
            # the last field is part of Gmi
            n = 0
            #self.alpha[i] = 0.0  # we don't need to set alpha

        j = 4
        gmis = []
        for k in range(len(card) - 4 - n):
            gmi = integer(card, j + k, 'Gm%i' % (k + 1))
            #print('GM%i = %s' % (k + 1, gmi))
            gmis.append(gmi)
        self.gmi[i] = gmis
        self.i += 1
开发者ID:marcinch18,项目名称:pyNastran,代码行数:33,代码来源:rbe2.py

示例7: add_card

 def add_card(cls, card, icard=0, comment=''):
     noffset = 3 * icard
     sid = integer(card, 1, 'sid')
     p = integer(card, 2 + noffset, 'p')
     c = components_or_blank(card, 3 + noffset, 'c', 0)
     scale = double(card, 4 + noffset, 'scale')
     return DAREA(sid, p, c, scale, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:7,代码来源:loads.py

示例8: parse

 def parse(self, card, icard=0, comment=''):
     noffset = 3 * icard
     sid = integer(card, 1, 'sid')
     node = integer(card, 2 + noffset, 'node_p')
     component = int(components_or_blank(card, 3 + noffset, 'c', 0))
     scale = double(card, 4 + noffset, 'scale')
     data = (sid, node, component, scale)
     return data, comment
开发者ID:hurlei,项目名称:pyNastran,代码行数:8,代码来源:darea.py

示例9: get_mpc_constraint

def get_mpc_constraint(card):
    #: Set identification number. (Integer > 0)
    constraint_id = integer(card, 1, 'conid')
    #: Identification number of grid or scalar point. (Integer > 0)
    #gids = []
    #: Component number. (Any one of the Integers 1 through 6 for grid
    #: points; blank or zero for scalar points.)
    #constraints = []
    #: Coefficient. (Real; Default = 0.0 except A1 must be nonzero.)
    #enforced = []
    constraints = []

    fields = card.fields(0)
    nfields = len(fields) - 1
    for iField in range(2, nfields, 8):
        grid = integer(card, iField, 'gid')
        component = components_or_blank(card, iField + 1, 'constraint', 0)  # scalar point
        value = double_or_blank(card, iField + 2, 'enforced', 0.0)

        constraints.append([grid, int(component), value])
        #self.gids.append(grid)
        #self.constraints.append(component)
        #self.enforced.append(value)

        if iField + 3 > nfields:
            break
        grid = integer(card, iField + 3, 'gid')
        component = components_or_blank(card, iField + 4, 'constraint', 0)  # scalar point
        value = double_or_blank(card, iField + 5, 'enforced')

        constraints.append([grid, int(component), value])
        #self.gids.append(grid)
        #self.constraints.append(component)
        #self.enforced.append(value)

    return constraint_id, constraints
开发者ID:hurlei,项目名称:pyNastran,代码行数:36,代码来源:mpc.py

示例10: add_card

    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        diameter_ratio = double_or_blank(card, 2, 'diameter_ratio', 0.1)
        nfields = len(card)
        assert nfields % 2 == 1, 'nfields=%s card=%s'  % (nfields, card)

        nids = []
        components = []
        j = 1
        for i in range(3, nfields, 2):
            nid = integer(card, i, 'nid_%s' % j)
            comp = components_or_blank(card, i+1, 'components_%i' % j)
            nids.append(nid)
            components.append(comp)
            j += 1
        return RSPLINE(eid, nids, components, diameter_ratio=diameter_ratio, comment=comment)
开发者ID:hurlei,项目名称:pyNastran,代码行数:16,代码来源:rigid.py

示例11: add_card

    def add_card(cls, card, comment=''):
        conid = integer(card, 1, 'conid')  # really a support id sid

        nfields = len(card)
        assert len(card) > 2
        nterms = int((nfields - 1.) / 2.)
        n = 1
        IDs = []
        Cs = []
        for i in range(nterms):
            nstart = 2 + 2 * i
            ID = integer(card, nstart, 'ID%s' % n)
            C = components_or_blank(card, nstart + 1, 'component%s' % n, '0')
            IDs.append(ID)
            Cs.append(C)
            n += 1
        return SUPORT1(conid, IDs, Cs, comment=comment)
开发者ID:hurlei,项目名称:pyNastran,代码行数:17,代码来源:constraints.py

示例12: __init__

    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Method of eigenvalue extraction. (Character: 'INV' for inverse
            #: power method or 'SINV' for enhanced inverse power method.)
            #: apparently it can also be blank...
            self.method = string_or_blank(card, 2, 'method')

            if self.method not in ['INV', 'SINV', None]:
                msg = 'method must be INV or SINV.  method=|%s|' % self.method
                raise RuntimeError(msg)

            #: Eigenvalue range of interest. (Real, L1 < L2)
            self.L1 = double(card, 3, 'L1')
            self.L2 = double(card, 4, 'L2')
            if not self.L1 < self.L2:
                msg = 'L1=%s L2=%s; L1<L2 is requried' % (self.L1, self.L2)
                raise RuntimeError(msg)

            #: Estimate of number of roots in positive range not used for
            #: METHOD = 'SINV'. (Integer > 0)
            self.nep = integer_or_blank(card, 5, 'nep', 0)

            #: Desired number of positive and negative roots.
            #: (Integer>0; Default = 3*NEP)
            self.ndp = integer_or_blank(card, 6, 'ndp', 3 * self.nep)
            self.ndn = integer_or_blank(card, 7, 'ndn', 3 * self.nep)

            #: Method for normalizing eigenvectors.
            #: ('MAX' or 'POINT';Default='MAX')
            self.norm = string_or_blank(card, 9, 'norm', 'MAX')
            if self.norm == 'POINT':
                self.G = integer(card, 10, 'G')
                self.C = components(card, 11, 'C')
            else:
                self.G = integer_or_blank(card, 10, 'G')
                self.C = components_or_blank(card, 11, 'C')
            assert len(card) <= 12, 'len(EIGB card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGB')
开发者ID:watkinrt,项目名称:pyNastran,代码行数:45,代码来源:methods.py

示例13: __init__

    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment
        #:  Component number. (Integer zero or blank for scalar points or any
        #:  unique combination of the Integers 1 through 6 for grid points with
        #:  no embedded blanks.)
        self.components = components_or_blank(card, 1, 'components', 0)

        nfields = len(card)
        IDs = []
        i = 1
        for ifield in range(2, nfields):
            ID = integer_string_or_blank(card, ifield, 'ID%i' % i)
            if ID:
                i += 1
                IDs.append(ID)

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = expand_thru(IDs)
开发者ID:marcinch18,项目名称:pyNastran,代码行数:20,代码来源:bdf_sets.py

示例14: add_card

    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        method = string_or_blank(card, 2, 'method')

        L1 = double(card, 3, 'L1')
        L2 = double(card, 4, 'L2')

        nep = integer_or_blank(card, 5, 'nep', 0)
        ndp = integer_or_blank(card, 6, 'ndp', 3 * nep)
        ndn = integer_or_blank(card, 7, 'ndn', 3 * nep)

        norm = string_or_blank(card, 9, 'norm', 'MAX')
        if norm == 'POINT':
            G = integer(card, 10, 'G')
            C = components(card, 11, 'C')
        else:
            G = integer_or_blank(card, 10, 'G')
            C = components_or_blank(card, 11, 'C')
        assert len(card) <= 12, 'len(EIGB card) = %i\ncard=%s' % (len(card), card)
        return EIGB(sid, method, L1, L2, nep, ndp, ndn, norm, G, C,
                    comment=comment)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:21,代码来源:methods.py

示例15: test_components_or_blank_02

    def test_components_or_blank_02(self):
        # single ints
        val = components_or_blank(BDFCard([0]), 0, 'field', 'default')
        self.assertEqual(val, '0')

        val = components_or_blank(BDFCard([1]), 0, 'field', 'default')
        self.assertEqual(val, '1')

        # single strings
        val = components_or_blank(BDFCard(['0']), 0, 'field', 'default')
        self.assertEqual(val, '0')

        val = components_or_blank(BDFCard(['1']), 0, 'field', 'default')
        self.assertEqual(val, '1')

        # double ints
        val = components_or_blank(BDFCard(['123']), 0, 'field', 'default')
        self.assertEqual(val, '123')

        val = components_or_blank(BDFCard([123]), 0, 'field', 'default')
        self.assertEqual(val, '123')

        val = components_or_blank(BDFCard([321]), 0, 'field', 'default')
        self.assertEqual(val, '123')

        # embedded whiteshape
        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['12 3']), 0, 'field', 'default')

        # all numbers
        val = components_or_blank(BDFCard(['123456']), 0, 'field', 'default')
        self.assertEqual(val, '123456')

        # invalid 0's defined with numbers
        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['0123456']), 0, 'field', 'default')

        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['01']), 0, 'field', 'default')

        # doubles
        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['4524']), 0, 'field', 'default')

        # only 0 to 6
        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['7']), 0, 'field', 'default')

        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard([7]), 0, 'field', 'default')

        # dumb input
        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['4.0']), 0, 'field', 'default')

        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['-4.0']), 0, 'field', 'default')

        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['asdf']), 0, 'field', 'default')

        with self.assertRaises(SyntaxError):
            val = components_or_blank(BDFCard(['-1']), 0, 'field', 'default')

        # blank
        val = components_or_blank(BDFCard(['   ']), 0, 'field', 'default')
        self.assertEqual(val, 'default')
        val = components_or_blank(BDFCard([None]), 0, 'field', 'default')
        self.assertEqual(val, 'default')
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:69,代码来源:test_assign_type.py


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