def test_grid_03(self): model = BDF(debug=False) nid = 1 cp = 2 cd = 0 ps = '' seid = 0 card_count = { 'GRID': 2, } model = BDF(debug=False) model.allocate(card_count) nodes = model.grid data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid]) data2 = BDFCard(['GRID', nid + 1, cp, 0., 0., 0., cd, ps, seid]) data3 = BDFCard(['GRID', nid + 2, cp, 0., 0., 0., cd, ps, seid]) nodes.add(data1) nodes.add(data2) nodes.resize(3, refcheck=False) #print('nodes.node_id = %s' % nodes.node_id) nodes.add(data3) f = StringIO() nodes.write_card(f, size=8, write_header=False)
def test_grid_04(self): model = BDF(debug=False) nid = 1 cp = 2 cd = 0 ps = '' seid = 0 card_count = { 'GRID': 2, } model = BDF(debug=False) model.allocate(card_count) nodes = model.grid data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid]) data2 = BDFCard(['GRID', nid + 1, cp, 0., 0., 0., cd, ps, seid]) data3 = BDFCard(['GRID', nid + 2, cp, 0., 0., 0., cd, ps, seid]) data4 = BDFCard(['GRID', nid + 3, cp, 0., 0., 0., cd, ps, seid]) nodes.add(data1) nodes.add(data2) nodes.resize(4, refcheck=False) #print('nodes.node_id = %s' % nodes.node_id) nodes.add(data3) self.assertEqual(len(nodes.node_id), 4) self.assertEqual(nodes.n, 4) self.assertEqual(nodes.i, 3) nodes.shrink(refcheck=False) #print('nodes.node_id = %s' % nodes.node_id) self.assertEqual(len(nodes.node_id), 3) self.assertEqual(nodes.n, 3) self.assertEqual(nodes.i, 3) nodes.resize(4, refcheck=False) nodes.add(data4) self.assertEqual(len(nodes.node_id), 4) self.assertEqual(nodes.n, 4) self.assertEqual(nodes.i, 4) f = StringIO() nodes.write_card(f, size=8, write_header=False) #print(f.getvalue()) nodes.resize(2, refcheck=False) self.assertEqual(len(nodes.node_id), 2) self.assertEqual(nodes.n, 2) self.assertEqual(nodes.i, 2) f = StringIO() nodes.write_card(f, size=8, write_header=False)
def test_grid_02(self): model = BDF(debug=False) nid = 1 cp = 2 cd = 0 ps = '' seid = 0 card_count = { 'GRID': 2, } model = BDF(debug=False) model.allocate(card_count) nodes = model.grid data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid]) data2 = BDFCard(['GRID', nid + 1, cp, 0., 0., 0., cd, ps, seid]) nodes.add(data1) nodes.add(data2) f = StringIO() nodes.write_card(f, size=8, write_header=False)
def test_ctetra_01(self): model = BDF(debug=False) lines = ['CTETRA,85,22,201,202,203,205'] card = model._process_card(lines) card = BDFCard(card) size = 8 f = StringIO() hexa = CTETRA4(model) hexa.allocate(1) hexa.add(card) hexa.write_card(f, size) #card.raw_fields() print(f.getvalue())
def test_chexa_01(self): model = BDF(debug=False) lines = ['CHEXA,85,22,201,202,203,205,206,207,+PN2', '+PN2,209,210'] card = model._process_card(lines) card = BDFCard(card) size = 8 f = StringIO() hexa = CHEXA8(model) hexa.allocate(1) hexa.add(card) hexa.write_card(f, size) #card.raw_fields() print(f.getvalue())
def test_cpenta_01(self): model = BDF(debug=False) lines = ['CPENTA,85,22,201,202,203,205,206,207'] card = model._process_card(lines) card = BDFCard(card) size = 8 f = StringIO() penta = CPENTA6(model) penta.allocate(1) penta.add(card) penta.write_card(f, size) #card.raw_fields() print(f.getvalue())
def test_ctetra_02(self): model = BDF(debug=False) lines = ['CTETRA,85,22,201,202,203,205,206,207,+PN2', '+PN2,209,210,217'] card = model.process_card(lines) card = BDFCard(card) size = 8 f = StringIO() hexa = CTETRA10(model) hexa.allocate(1) hexa.add(card) hexa.write_card(f, size) #card.rawFields() print(f.getvalue())
def test_cpenta_02(self): model = BDF(debug=False) lines = ['CPENTA,85,22,201,202,203,205,206,207,+PN2', '+PN2,209,210,217, , , ,213,214,218'] card = model.process_card(lines) card = BDFCard(card) size = 8 f = StringIO() penta = CPENTA15(model) penta.allocate(1) penta.add(card) penta.write_card(f, size) #card.rawFields() print(f.getvalue())
def test_grid_01(self): nid = 1 cp = 2 cd = 0 ps = '' seid = 0 card_count = { 'GRID': 1, } model = BDF(debug=False) model.allocate(card_count) data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid]) nodes = model.grid nodes.add(data1) #print(n1) f = StringIO() nodes.write_card(f, size=8, write_header=False) nodes.write_card(f, size=16, write_header=False) nodes.write_card(f, size=16, is_double=True, write_header=False) # small field f = StringIO() nodes.write_card(f, size=8, write_header=False) msg = f.getvalue() card = 'GRID 1 2 0. 0. 0.\n' self.assertCardEqual(msg, card) # large field f = StringIO() nodes.write_card(f, size=16, write_header=False) card = ( 'GRID* 1 2 0. 0.\n' '* 0.\n') msg = f.getvalue() self.assertCardEqual(msg, card)
def test_spoint_01(self): model = BDF(debug=False) card_count = { 'SPOINT': 2, } model = BDF(debug=False) model.allocate(card_count) spoints = model.spoint data1 = BDFCard(['SPOINT', 1, 2]) data2 = BDFCard(['SPOINT', 4, 5]) data3 = BDFCard(['SPOINT', 10, 20]) data4 = BDFCard(['SPOINT', 30, 'THRU', 40]) spoints.add(data1) spoints.add(data2) f = StringIO() spoints.write_card(f, size=8) #print('spoints %s' % f.getvalue()) self.assertEqual(len(spoints), 4) self.assertEqual(spoints.n, 4) spoints.add(data3) f = StringIO() spoints.write_card(f, size=8) #print('spoints %s' % f.getvalue()) self.assertEqual(len(spoints), 6) self.assertEqual(spoints.n, 6) spoints.add(data4) f = StringIO() spoints.write_card(f, size=16) #print('spoints %s' % f.getvalue()) self.assertEqual(len(spoints), 17) self.assertEqual(spoints.n, 17) spoints.add(data4) f = StringIO() spoints.write_card(f, size=16) #print('spoints %s' % f.getvalue()) self.assertEqual(spoints.max(), 40) self.assertEqual(spoints.min(), 1) self.assertEqual(spoints.n, 17) if 1 in spoints: pass else: raise RuntimeError('invalid catch') if 29 in spoints: raise RuntimeError('invalid catch') data5 = BDFCard(['SPOINT', 50, 'THRU', 55, 59, '61', 'THRU', '64']) spoints.add(data5) f = StringIO() spoints.write_card(f, size=16) #print('spoints %s' % f.getvalue()) self.assertEqual(spoints.max(), 64) self.assertEqual(spoints.min(), 1) self.assertEqual(spoints.n, 28) spoints.remove([1, 2, 64]) #self.assertRaises(KeyError, spoints.remove([1, 2])) f = StringIO() spoints.write_card(f, size=16) #print('spoints %s' % f.getvalue()) self.assertEqual(spoints.n, 25)