예제 #1
0
    def add_card(cls, card, comment=''):
        """
        Adds an EIGB card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        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 = parse_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)
예제 #2
0
파일: spc1.py 프로젝트: ratalex/pyNastran
def get_spc1_constraint(card):
    constraint_id = integer(card, 1, 'constraint_id')
    dofs = parse_components(card, 2, 'constraints')  # 246 = y; dx, dz dir

    node_ids = card.fields(3)
    node_ids = expand_thru(node_ids)

    assert isinstance(constraint_id, int), constraint_id
    return constraint_id, dofs, node_ids
예제 #3
0
    def _add_column(self, card, comment=''):
        load_seq = integer(card, 2, 'load_seq')

        g1 = integer(card, 5, 'nid1')
        c1 = parse_components(card, 6, 'c1')
        x1 = double(card, 7, 'x1')
        assert len(card) <= 8, 'len=%s card=%s' % (len(card), card)

        gcx = [g1, c1, x1]
        self.load_sequences[load_seq] = [gcx]
예제 #4
0
파일: spc1.py 프로젝트: ratalex/pyNastran
    def add_card(self, card, comment=''):
        #if comment:
        # self.comment = comment
        constraint_id = integer(card, 1, 'conid')
        dofs = parse_components(card, 2, 'constraints')  # 246 = y; dx, dz dir
        node_ids = card.fields(3)

        assert isinstance(constraint_id, int), constraint_id
        self.constraint_id = constraint_id
        self.components[dofs] += node_ids
        self.n += 1
예제 #5
0
    def add_card(cls, card, comment=''):
        ids = []
        components = []

        nterms = len(card) // 2
        for n in range(nterms):
            i = n * 2 + 1
            idi = integer(card, i, 'ID' + str(n))
            component = parse_components(card, i + 1, 'component' + str(n))
            ids.append(idi)
            components.append(component)
        return cls(ids, components, comment=comment)
예제 #6
0
    def add_card(cls, card, comment=''):
        """
        Adds a SPCOFF1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        components = parse_components(card, 1, 'components')  # 246 = y; dx, dz dir
        nodes = card.fields(2)
        return cls(components, nodes, comment=comment)
예제 #7
0
    def add_card(cls, card, comment=''):
        """
        Adds a GMSPC card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        conid = integer(card, 1, 'sid')
        component = parse_components(card, 2, 'components')
        entity = string(card, 3, 'entity')
        entity_id = integer(card, 4, 'entity_id')
        return GMSPC(conid, component, entity, entity_id, comment=comment)
예제 #8
0
    def add_card(cls, card, comment=''):
        """
        Adds a SPCAX card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        conid = integer(card, 1, 'conid')
        rid = integer(card, 2, 'rid')
        hid = integer(card, 3, 'hid')
        c = parse_components(card, 4, 'c')
        d = double(card, 5, 'd')
        return SPCAX(conid, rid, hid, c, d, comment=comment)
예제 #9
0
    def add_card(cls, card, comment=''):
        """
        Adds an EIGR card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card

        """
        sid = integer(card, 1, 'sid')
        method = string_or_blank(card, 2, 'method', 'LAN')

        f1 = double_or_blank(card, 3, 'f1')
        f2 = double_or_blank(card, 4, 'f2')
        ne = integer_or_blank(card, 5, 'ne')

        if method not in cls.allowed_methods:
            msg = 'method=%s; allowed_methods=[%s]' % (
                method, ', '.join(cls.allowed_methods))
            raise ValueError(msg)

        if method == 'SINV':
            nd = integer_or_blank(card, 6, 'nd', 600)
        elif method == 'INV':
            ne = integer(card, 5, 'ne')
            nd = integer_or_blank(card, 6, 'nd', 3 * ne)
        elif method in ['GIV', 'MGIV', 'HOU', 'MHOU']:
            nd = integer_or_blank(card, 6, 'nd', 0)
        else:
            nd = integer(card, 6, 'nd')
        crit = double_or_blank(card, 8, 'crit')
        norm = string_or_blank(card, 9, 'norm', 'MASS')

        if norm == 'POINT':
            G = integer(card, 10, 'G')
            C = parse_components(card, 11, 'C')
        else:
            G = blank(card, 10, 'G')
            C = blank(card, 11, 'C')
        assert len(card) <= 12, f'len(EIGR card) = {len(card):d}\ncard={card}'
        return EIGR(sid, method, f1, f2, ne, nd,
                    crit=crit, norm=norm, G=G, C=C, comment=comment)
예제 #10
0
    def add_card(cls, card, comment=''):
        """
        Adds a CSET1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        if integer_string_or_blank(card, 2, 'C') == 'ALL':
            components = '123456'
        else:
            components = parse_components(card, 1, 'components')

        ids = []
        id_count = 1
        for ifield in range(2, len(card)):
            idi = integer_or_string(card, ifield, 'ID%i' % id_count)
            ids.append(idi)
            id_count += 1
        return CSET1(ids, components, comment=comment)
예제 #11
0
    def add_card(cls, card, comment=''):
        """
        Adds a USET card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        name = string(card, 1, 'name')
        components = []
        ids = []

        nsets = (len(card) - 1) // 2
        for iset in range(nsets):
            i = iset * 2 + 2
            idi = integer(card, i, 'node_id' + str(iset))
            component = parse_components(card, i + 1, 'component' + str(iset))
            components.append(component)
            ids.append(idi)
        return USET(name, components, ids, comment=comment)
예제 #12
0
    def test_components(self):
        # single ints
        val = parse_components(BDFCard([0]), 0, 'field')
        self.assertEqual(val, '0')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        with self.assertRaises(SyntaxError):
            val = parse_components(BDFCard(['-1']), 0, 'field')
예제 #13
0
    def add_card(cls, card, comment=''):
        """
        Adds an EIGC card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        sid = integer(card, 1, 'sid')
        method = string(card, 2, 'method')
        assert method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM', 'DET'], (
            'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM, DET' % method)

        norm = string_or_blank(card, 3, 'norm', 'MAX')
        if norm == 'POINT':
            grid = integer(card, 4, 'G')
            component = parse_components(card, 5, 'C')
        else:
            grid = blank(card, 4, 'G')
            component = blank(card, 5, 'C')

        epsilon = double_or_blank(card, 6, 'epsilon')
        neigenvalues = integer_double_string_or_blank(card, 7, 'ND0/neigenvalues')

        # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ
        fields = [interpret_value(field) for field in card[9:]]

        #-------CLAN--------------
        mblkszs = []
        iblkszs = []
        ksteps = []
        NJIs = []
        #-------CLAN--------------

        #-------HESS--------------
        alphaAjs = []
        alphaBjs = []
        omegaAjs = []
        omegaBjs = []
        mblkszs = []
        iblkszs = []
        ksteps = []
        LJs = []
        NEJs = []
        NDJs = []
        #-------HESS--------------

        #-------ISRR--------------
        shift_r1 = 0.0
        shift_i1 = 0.0
        isrr_flag = 0
        nd1 = None
        #-------ISRR--------------
        nfields = len(fields)
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1
        #if nrows == 0:
            #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (
                #nfields, card, fields)
            #raise RuntimeError(msg)

        if method == 'CLAN':
            alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(nrows, card)
        elif method in ['HESS', 'INV', 'DET']:  # HESS, INV
            alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs = cls._load_hess_inv(
                nrows, method, card)
        elif method == 'ISRR':
            shift_r1, shift_i1, isrr_flag, nd1 = cls._load_isrr(nrows, card)
        else:
            msg = 'invalid EIGC method...method=%r' % method
            raise RuntimeError(msg)
        #assert card.nfields() < 8, 'card = %s' % card
        return EIGC(sid, method, grid, component, epsilon, neigenvalues,
                    norm, # common
                    mblkszs, iblkszs, ksteps, NJIs, # CLAN
                    alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs, # HESS/INV
                    shift_r1, shift_i1, isrr_flag, nd1, # ISRR
                    comment=comment)
예제 #14
0
    def add_card(cls, card, comment=''):
        """
        Adds a RBE3 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        refgrid = integer(card, 3, 'refgrid')
        refc = components_or_blank(card, 4, 'refc')

        fields = [
            field.upper() if isinstance(field, string_types) else field
            for field in card[5:]
        ]
        ioffset = 5
        iwt_max = len(fields) + ioffset
        try:
            ialpha = fields.index('ALPHA') + ioffset
            iwt_max = ialpha  # the index to start parsing UM
            ium_stop = ialpha  # the index to stop  parsing UM
        except ValueError:
            ialpha = None
            ium_stop = iwt_max

        try:
            ium = fields.index('UM') + ioffset
            iwt_max = ium
        except ValueError:
            ium = None

        i = ioffset
        n = 1
        weights = []
        comps = []
        Gijs = []
        while i < iwt_max:
            Gij = []
            wtname = 'wt' + str(n)
            wt = double_or_blank(card, i, wtname)
            if wt is not None:
                cname = 'c' + str(n)
                compi = components_or_blank(card, i + 1, cname)

                #print("%s=%s %s=%s" % (wtname, wt, cname, compi))
                i += 2
                gij = 0

                j = 0
                while isinstance(gij, int) and i < iwt_max:
                    j += 1
                    gij_name = 'g%s,%s' % (n, j)
                    gij = integer_double_or_blank(card, i, gij_name)
                    if isinstance(gij, float):
                        break
                    #print("%s = %s" % (gij_name, gij))
                    if gij is not None:
                        Gij.append(gij)
                    i += 1
                assert compi is not None
                assert len(Gij) > 0, Gij
                assert Gij[0] is not None, Gij
                weights.append(wt)
                comps.append(compi)
                Gijs.append(Gij)
                #print('----finished a group=%r----' % weight_cg_group)
            else:
                i += 1

        Gmi = []
        Cmi = []
        if ium:
            #print('UM = %s' % card.field(ium))  # UM
            i = ium + 1
            n = 1
            #print("i=%s iUmStop=%s" % (i, iUmStop))
            for j in range(i, ium_stop, 2):

                gm_name = 'gm' + str(n)
                cm_name = 'cm' + str(n)
                gmi = integer_or_blank(card, j, gm_name)
                if gmi is not None:
                    cmi = parse_components(card, j + 1, cm_name)
                    #print("gmi=%s cmi=%s" % (gmi, cmi))
                    Gmi.append(gmi)
                    Cmi.append(cmi)

        if ialpha:
            alpha = double_or_blank(card, ialpha + 1, 'alpha')
        else:
            #: thermal expansion coefficient
            alpha = 0.0
        return RBE3(eid,
                    refgrid,
                    refc,
                    weights,
                    comps,
                    Gijs,
                    Gmi=Gmi,
                    Cmi=Cmi,
                    alpha=alpha,
                    comment=comment)