コード例 #1
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLEM3 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        tid = integer(card, 1, 'tid')
        x1 = double(card, 2, 'x1')
        x2 = double(card, 3, 'x2')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLEM3', xy)
        return TABLEM3(tid, x1, x2, x, y, comment=comment)
コード例 #2
0
ファイル: bdf_tables.py プロジェクト: watkinrt/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        RandomTable.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
            self.yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double_or_string(card, n, 'x' + str(i + 1))
                y = double_or_string(card, n + 1, 'y' + str(i + 1))
                if x == 'SKIP' or y == 'SKIP':
                    continue
                xy += [x, y]
            string(card, nfields, 'ENDT')
            is_data = False
        else:
            self.tid = data[0]
            self.xaxis = self.map_axis(data[1])
            self.yaxis = self.map_axis(data[2])
            xy = data[3:]
            is_data = True
        assert self.xaxis in ['LINEAR', 'LOG'], 'xaxis=%r' % (self.xaxis)
        assert self.yaxis in ['LINEAR', 'LOG'], 'yaxis=%r' % (self.yaxis)
        self.parse_fields(xy, nrepeated=2, is_data=is_data)
コード例 #3
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLED1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            xi = double_or_string(card, n, 'x' + str(i + 1))
            yi = double_or_string(card, n + 1, 'y' + str(i + 1))
            if xi == 'SKIP' or yi == 'SKIP':
                continue
            xy.append([xi, yi])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLED1', xy)
        return TABLED1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
コード例 #4
0
ファイル: bdf_tables.py プロジェクト: watkinrt/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double_or_string(card, n, 'x' + str(i + 1))
                y = double_or_string(card, n + 1, 'y' + str(i + 1))
                if x == 'SKIP' or y == 'SKIP':
                    continue
                xy += [x, y]
            string(card, nfields, 'ENDT')
            is_data = False
        else:
            self.tid = data[0]
            xy = data[1:]
            is_data = True
        self.parse_fields(xy, nrepeated=2, is_data=is_data)
コード例 #5
0
    def test_double_or_string(self):
        """tests the double_or_string function"""
        # out of range
        with self.assertRaises(SyntaxError):
            double_or_string(BDFCard([1.]), 1, 'field')
        self.assertEqual(1.e-9, double_or_string(BDFCard(['1-9']), 0, 'field'))
        self.assertEqual(1.e+9, double_or_string(BDFCard(['1+9']), 0, 'field'))

        self.check_double(double_or_string)
        self.check_string(double_or_string, check_dash=False)
コード例 #6
0
ファイル: bdf_tables.py プロジェクト: saullocastro/pyNastran
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLEST', xy)
        return TABLEST(tid, x, y, comment=comment)
コード例 #7
0
def read_table(card, table_id, table_type):
    """common method for reading tables that handles SKIP"""
    nfields = len(card) - 1
    nterms = (nfields - 9) // 2
    if nterms < 0:
        raise SyntaxError('%r card is too short' % table_type)

    xy = []
    for i in range(nterms):
        n = 9 + i * 2
        if card.field(n) == 'ENDT':
            break
        xi = double_or_string(card, n, 'x' + str(i + 1))
        yi = double_or_string(card, n + 1, 'y' + str(i + 1))
        if xi == 'SKIP' or yi == 'SKIP':
            continue
        xy.append([xi, yi])
    string(card, nfields, 'ENDT')
    x, y = make_xy(table_id, table_type, xy)
    return x, y
コード例 #8
0
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLEST', xy)
        return TABLEST(tid, x, y, comment=comment)
コード例 #9
0
ファイル: bdf_tables.py プロジェクト: saullocastro/pyNastran
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            xi = double_or_string(card, n, 'x' + str(i + 1))
            yi = double_or_string(card, n + 1, 'y' + str(i + 1))
            if xi == 'SKIP' or yi == 'SKIP':
                continue
            xy.append([xi, yi])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLED1', xy)
        return TABLED1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
コード例 #10
0
ファイル: bdf_tables.py プロジェクト: marcinch18/pyNastran
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        Type = integer_or_blank(card, 2, 'Type', 1)

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        xy = np.array(xy)
        x = xy[:, 0]
        y = xy[:, 1]
        return TABLES1(tid, Type, x, y, comment=comment)
コード例 #11
0
ファイル: bdf_tables.py プロジェクト: marcinch18/pyNastran
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        x1 = double(card, 2, 'x1')
        x2 = double(card, 3, 'x2')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy += [x, y]
        string(card, nfields, 'ENDT')
        xy = np.array(xy)
        x = xy[:, 0]
        y = xy[:, 1]
        return TABLEM3(tid, x1, x2, x, y, comment=comment)
コード例 #12
0
ファイル: bdf_tables.py プロジェクト: hurlei/pyNastran
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        xy = np.array(xy, dtype='float64')
        x = xy[:, 0]
        y = xy[:, 1]
        return TABRND1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
コード例 #13
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLED5 card from ``BDF.add_card(...)``

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

        """
        table_id = integer(card, 1, 'tid')

        nfields = len(card) - 1
        nterms = nfields - 9
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xs = []
        table_ids = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            table_id = integer_or_string(card, n + 1, 'table_id' + str(i + 1))
            if x == 'SKIP' or table_id == 'SKIP':
                continue
            xs.append(x)
            table_ids.append(table_id)
        string(card, nfields, 'ENDT')
        return TABLED5(table_id, xs, table_ids, comment=comment)
コード例 #14
0
 def test_double_or_string(self):
     # out of range
     with self.assertRaises(SyntaxError):
         double_or_string(BDFCard([1.]), 1, 'field')
コード例 #15
0
 def test_double_or_string(self):
     # out of range
     with self.assertRaises(SyntaxError):
         double_or_string(BDFCard([1.]), 1, 'field')
     self.assertEqual(1.e-9, double_or_string(BDFCard(['1-9']), 0, 'field'))
     self.assertEqual(1.e+9, double_or_string(BDFCard(['1+9']), 0, 'field'))
コード例 #16
0
 def test_double_or_string(self):
     # out of range
     with self.assertRaises(SyntaxError):
         double_or_string(BDFCard([1.]), 1, 'field')
     self.assertEqual(1.e-9, double_or_string(BDFCard(['1-9']), 0, 'field'))
     self.assertEqual(1.e+9, double_or_string(BDFCard(['1+9']), 0, 'field'))