def add_card(cls, card, comment=''): """ Adds a QVECT card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') q0 = double(card, 2, 'q0') t_source = double_or_blank(card, 3, 't_source') ce = integer_or_blank(card, 4, 'ce', 0) vector_tableds = [ integer_double_or_blank(card, 5, 'e1_tabled1', 0.0), integer_double_or_blank(card, 6, 'e2_tabled2', 0.0), integer_double_or_blank(card, 7, 'e3_tabled3', 0.0), ] control_id = integer_or_blank(card, 8, 'control_id', 0) i = 1 eids = [] for ifield in range(9, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) assert eid != 0, card i += 1 elements = expand_thru_by(eids) return QVECT(sid, q0, elements, t_source=t_source, ce=ce, vector_tableds=vector_tableds, control_id=control_id, comment=comment)
def add_card(cls, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) points = set(expand_thru(fields)) return cls(points, comment=comment)
def add_card(cls, card, comment=''): """ Adds a NSM1/NSML1 card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') nsm_type = string(card, 2, 'Type') value = double(card, 3, 'value') # TODO: doesn't support 1 THRU 11 BY 2 ids = [] _id = 1 nfields = len(card) if nfields == 5: id1 = integer_or_string(card, 4, 'ID_1') if id1 != 'ALL' and not isinstance(id1, int): msg = ( '*ID_1 = %r (field #4) on card must be an integer or ALL.\n' 'card=%s' % (id1, card)) raise SyntaxError(msg) ids = id1 else: # we'll handle expansion in the init ids = card[4:] return cls(sid, nsm_type, value, ids, comment=comment)
def test_integer_or_string(self): # out of range with self.assertRaises(SyntaxError): integer_or_string(BDFCard([1.]), 1, 'field') self.assertEqual(1000, integer_or_string(BDFCard([1000]), 0, 'field')) self.assertEqual(1000, integer_or_string(BDFCard(['1000']), 0, 'field')) self.assertEqual('CAT', integer_or_string(BDFCard(['cat']), 0, 'field')) self.assertEqual('CAT', integer_or_string(BDFCard([' cat ']), 0, 'field')) with self.assertRaises(SyntaxError): integer_or_string(BDFCard(['1b']), 0, 'field') with self.assertRaises(SyntaxError): integer_or_string(BDFCard(['1+2']), 0, 'field')
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment #: Identifiers of grids points. (Integer > 0) self.IDs = [] if string_or_blank(card, 2, 'C') == 'ALL': self.components = '123456' else: self.components = components(card, 1, 'components') IDs2 = [] ii = 1 for ifield in range(2, len(card)): integer_or_string(card, ifield, 'ID' % ii) ii += 1 self.IDs = expand_thru(IDs2)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') qFlux = double(card, 2, 'qFlux') eids = [] j = 1 for i in range(3, len(card)): eid = integer_or_string(card, i, 'eid%i' % j) eids.append(eid) j += 1 return QBDY1(sid, qFlux, eids, comment=comment)
def add(self, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) ex = expand_thru(fields) ex = set(ex) self.spoint.update(ex) self._comments.append(comment) self.n = len(self.spoint)
def add_card(self, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) ex = expand_thru(fields) ex = set(ex) self.spoint.update(ex) self._comments.append(comment) self.n = len(self.spoint)
def add_card(cls, card, comment=''): seid = integer(card, 1, 'seid') comp = integer(card, 2, 'comp') nids = [] i = 3 nfields = len(card) for ifield in range(3, nfields): idi = integer_or_string(card, ifield, 'ID%i' % i) nids.append(idi) i += 1 assert len(card) >= 3, f'len(RELEASE card) = {len(card):d}\ncard={card}' return RELEASE(seid, comp, nids, comment=comment)
def add_card(cls, card, comment=''): if integer_string_or_blank(card, 2, 'C') == 'ALL': components = '123456' else: components = fcomponents(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)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') qvol = double(card, 2, 'qvol') control_point = integer_or_blank(card, 3, 'control_id', 0) i = 1 eids = [] for ifield in range(4, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) i += 1 elements = expand_thru_by(eids) return QVOL(sid, qvol, control_point, elements, comment=comment)
def add_card(cls, card, comment=''): """ Adds a SPOINT/EPOINT card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ points = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) points.append(field) return cls(points, comment=comment)
def add_card(cls, card, comment=''): """ Adds a QBDY1 card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') qflux = double(card, 2, 'qflux') eids = [] j = 1 for i in range(3, len(card)): eid = integer_or_string(card, i, 'eid%i' % j) eids.append(eid) j += 1 return QBDY1(sid, qflux, eids, comment=comment)
def add_card(cls, card, comment=''): """ Adds a QVOL card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') qvol = double(card, 2, 'qvol') control_point = integer_or_blank(card, 3, 'control_id', 0) i = 1 eids = [] for ifield in range(4, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) i += 1 elements = expand_thru_by(eids) return QVOL(sid, qvol, control_point, elements, comment=comment)
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)
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)
def test_integer_string_or_blank(self): # integer self.check_integer(integer_string_or_blank) # float #print type(integer_string_or_blank(BDFCard(['4.0']), 0, 'field')) with self.assertRaises(SyntaxError): integer_string_or_blank(BDFCard([3.0]), 0, 'field') with self.assertRaises(SyntaxError): integer_string_or_blank(BDFCard(['4.0']), 0, 'field') with self.assertRaises(SyntaxError): integer_string_or_blank(BDFCard(['5.']), 0, 'field') with self.assertRaises(SyntaxError): integer_string_or_blank(BDFCard(['1b']), 0, 'field') # string self.assertEqual( 'LOAD', integer_string_or_blank(BDFCard(['load']), 0, 'field')) self.assertEqual(1000, integer_or_string(BDFCard([1000]), 0, 'field')) # blank integer_string_or_blank(BDFCard([' ']), 0, 'field') integer_string_or_blank(BDFCard([None]), 0, 'field')
def add_card(cls, card, comment=''): set_id = integer_or_string(card, 1, 'set_id') n = integer_or_blank(card, 2, 'n', 0) assert len(card) <= 3, 'len(SENQSET card) = %i\ncard=%s' % (len(card), card) return SENQSET(set_id, n, comment=comment)
def test_integer_or_string(self): # out of range with self.assertRaises(SyntaxError): integer_or_string(BDFCard([1.]), 1, 'field')
def add_card(cls, card, comment=''): set_id = integer_or_string(card, 1, 'set_id') n = integer_or_blank(card, 2, 'n', 0) assert len( card) <= 3, f'len(SENQSET card) = {len(card):d}\ncard={card}' return SENQSET(set_id, n, comment=comment)