本文整理汇总了Python中pyNastran.bdf.fieldWriter.print_card函数的典型用法代码示例。如果您正苦于以下问题:Python print_card函数的具体用法?Python print_card怎么用?Python print_card使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_card函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_fields
def assert_fields(card1, card2):
try:
fields1 = wipe_empty_fields(card1.repr_fields())
fields2 = wipe_empty_fields(card2.repr_fields())
except:
print("card1 = \n%s" % (card1))
print("card2 = \n%s" % (card2))
raise
if len(fields1) != len(fields2):
msg = ('len(fields1)=%s len(fields2)=%s\n%r\n%r\n%s\n%s'
% (len(fields1), len(fields2), fields1, fields2,
print_card(fields1), print_card(fields2)))
raise RuntimeError(msg)
for (i, field1, field2) in zip(count(), fields1, fields2):
value1a = print_field(field1)
value2a = print_field(field2)
if value1a != value2a:
value1 = print_field(interpret_value(value1a))
value2 = print_field(interpret_value(value2a))
if value1 != value2:
msg = 'value1 != value2\n'
msg += ('cardName=%s ID=%s i=%s field1=%r field2=%r value1=%r '
'value2=%r\n%r\n%r' % (fields1[0], fields1[1], i,
field1, field2, value1, value2,
fields1, fields2))
raise RuntimeError(msg)
示例2: test_pbar_01
def test_pbar_01(self):
fields = [u'PBAR', 1510998, 1520998, 0.0, 4.9000000000000006e-14, 4.9000000000000006e-14, 0.0, 0.0, None, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, None, None, 0.0]
card = print_card(fields)
#print(card)
card = print_card(fields)
lines = card.split('\n')
card = bdf.process_card(lines)
card2 = BDFCard(card)
with self.assertRaises(AssertionError): # A=0, I12=0, K1=0
pbar = PBAR(card2)
示例3: test_pbar_01
def test_pbar_01(self):
fields = [u'PBAR', 1510998, 1520998, 0.0, 4.9000000000000006e-14, 4.9000000000000006e-14, 0.0, 0.0, None, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, None, None, 0.0]
card = print_card(fields)
#print(card)
card = print_card(fields)
lines = card.split('\n')
card = bdf.process_card(lines)
card2 = BDFCard(card)
pbar = PBAR(card2)
self.assertEqual(pbar.A, 0.), pbar.A
self.assertEqual(pbar.i12, 0.), pbar.i12
self.assertEqual(pbar.K1, None), pbar.K1
self.assertEqual(pbar.K2, None), pbar.K2
示例4: write_bdf
def write_bdf(self, f, size=8, element_ids=None):
assert self.n > 0, self.n
if self.n:
if element_ids is None:
i = arange(self.n)
else:
i = searchsorted(self.element_id, element_ids)
cid = [cid if cid != 0 else '' for cid in self.coord_id]
X0 = [x if x != 0.0 else '' for x in self.x[i, 0]]
X1 = [x if x != 0.0 else '' for x in self.x[i, 1]]
X2 = [x if x != 0.0 else '' for x in self.x[i, 2]]
Mass = [x if x != 0.0 else '' for x in self.mass[i]]
I0 = [x if x != 0.0 else '' for x in self.I[i, 0]]
I1 = [x if x != 0.0 else '' for x in self.I[i, 1]]
I2 = [x if x != 0.0 else '' for x in self.I[i, 2]]
I3 = [x if x != 0.0 else '' for x in self.I[i, 3]]
I4 = [x if x != 0.0 else '' for x in self.I[i, 4]]
I5 = [x if x != 0.0 else '' for x in self.I[i, 5]]
for (eid, nid, cid, mass, x0, x1, x2, i0, i1, i2, i3, i4, i5) in zip(self.element_id[i], self.node_id[i],
cid, Mass, X0, X1, X2, I0, I1, I2, I3, I4, I5):
card = ['CONM2', eid, nid, cid, mass, x0, x1, x2,
None, i0, i1, i2, i3, i4, i5]
f.write(print_card(card))
示例5: test_pbeam_03
def test_pbeam_03(self):
lines =['PBEAM,39,6,2.9,3.5,5.97',
' , , ,2.0,-4.0',
' ,YES,1.0,5.3,56.2,78.6',
' , , ,2.5,-5.0',
' , , ,1.1, ,2.1,,0.21',
' , , , , ,0.5,,0.0',]
card = bdf.process_card(lines)
#print print_card(card)
card = BDFCard(card)
#print "card =", card
card2 = PBEAM(card)
fields = card2.rawFields()
msg = print_card(fields)
#print msg
lines_expected = ['PBEAM 39 6 2.9 3.5 5.97 0. 0. 0.',
' 0. 0. 2. -4. 0. 0. 0. 0.',
' YES 1. 5.3 56.2 78.6 56.2 0. 0.',
' 0. 0. 0. 2.5 -5. 0. 0. 0.',
' 1. 1. 1.1 0. 2.1 2.1 .21 .21',
' 0. 0. 0. 0. .5 .5 0. 0.',]
lines_actual = msg.rstrip().split('\n')
msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
self.assertEqual(len(lines_actual), len(lines_expected), msg)
for actual, expected in zip(lines_actual, lines_expected):
self.assertEqual(actual, expected)
示例6: _test_pbeam_07
def _test_pbeam_07(self):
lines = ['PBEAM 100 100 1.00 10. 1.0 +Z1',
'+Z1 NO 1.0 +Z4',
'+Z4 0.0 0.0',]
card = bdf.process_card(lines)
#print(print_card(card))
card = BDFCard(card)
#print("card =", card)
#with self.assertRaises(RuntimeError): # temporary RuntimeError
card2 = PBEAM(card)
if 0:
fields = card2.rawFields()
msg = print_card(fields)
#print(msg)
lines_actual = msg.rstrip().split('\n')
msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
self.assertEqual(len(lines_actual), len(lines_expected), msg)
for actual, expected in zip(lines_actual, lines_expected):
msg = 'actual = %r\n' % actual
msg += 'expected = %r' % expected
self.assertEqual(actual, expected, msg)
示例7: test_pbeam_06
def test_pbeam_06(self):
lines =['PBEAM 1 1 1. 60. 1. PBEAM1',
'+BEAM1 5. -5. PBEAM2',
'+BEAM2 YES 1. 2. 240. PBEAM3',
'+BEAM3 10. -10. PBEAM4',
'+BEAM4 -.666667',]
card = bdf.process_card(lines)
#print(print_card(card))
card = BDFCard(card)
#print("card =", card)
card2 = PBEAM(card)
fields = card2.rawFields()
msg = print_card(fields)
#print(msg)
lines_expected = ['PBEAM 1 1 1. 60. 1. 0. 0. 0.',
' 5. 0. -5. 0. 0. 0. 0. 0.',
' YES 1. 2. 240. 0. 240. 0. 0.',
' 0. 10. 0. -10. 0. 0. 0. 0.',
' 1. 1.-.666667 0. 0. 0. 0. 0.',
' 0. 0. 0. 0. 0. 0. 0. 0.',
]
#print('\n'.join(lines_expected))
lines_actual = msg.rstrip().split('\n')
msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
self.assertEqual(len(lines_actual), len(lines_expected), msg)
for actual, expected in zip(lines_actual, lines_expected):
msg = 'actual = %r\n' % actual
msg += 'expected = %r' % expected
self.assertEqual(actual, expected, msg)
示例8: test_pbeam_05
def test_pbeam_05(self):
lines =['PBEAM,39,6,2.9,3.5,5.97',
' , , ,2.0,-4.0',]
card = bdf.process_card(lines)
#print(print_card(card))
card = BDFCard(card)
#print("card =", card)
card2 = PBEAM(card)
fields = card2.rawFields()
msg = print_card(fields)
#print(msg)
lines_expected = ['PBEAM 39 6 2.9 3.5 5.97 0. 0. 0.',
' 0. 0. 2. -4. 0. 0. 0. 0.',
' 1. 1. 0. 0. 0. 0. 0. 0.',
' 0. 0. 0. 0. 0. 0. 0. 0.',]
lines_actual = msg.rstrip().split('\n')
msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
self.assertEqual(len(lines_actual), len(lines_expected), msg)
for actual, expected in zip(lines_actual, lines_expected):
msg = 'actual = %r\n' % actual
msg += 'expected = %r' % expected
self.assertEqual(actual, expected, msg)
示例9: write
def write(self, f=None, eids=None):
msg = []
size = 8
for i in xrange(self._ncquad4):
eid = self.eid[i]
pid = self.pid[i]
zOffset = self.zOffset[i]
TFlag = self.TFlag[i]
thetaMcid = self.thetaMcid[i]
T1, T2, T3, T4 = self.T[i]
zOffset = set_blank_if_default(zOffset, 0.0)
TFlag = set_blank_if_default(TFlag, 0)
thetaMcid = set_blank_if_default(thetaMcid, 0.0)
T1 = set_blank_if_default(T1, 1.0)
T2 = set_blank_if_default(T2, 1.0)
T3 = set_blank_if_default(T3, 1.0)
T4 = set_blank_if_default(T4, 1.0)
fields = (['CQUAD4', eid, pid] + self.nodes[i] +
[thetaMcid, zOffset, None, TFlag, T1, T2, T3, T4])
msg.append(print_card(fields))
return ''.join(msg)
示例10: write_bdf
def write_bdf(self, f, size=8, property_ids=None):
"""
Writes the PSHELL properties.
:param self: the PSHELL object
:param f: file object
:param size: the bdf field size (8/16; default=8)
:param property_ids: the property_ids to write (default=None -> all)
"""
if self.n:
i = self.get_index(property_ids)
Mid2 = [midi if midi > 0 else '' for midi in self.material_id2[i]]
Mid3 = [midi if midi > 0 else '' for midi in self.material_id3[i]]
Mid4 = [midi if midi > 0 else '' for midi in self.material_id4[i]]
Nsm = ['' if nsmi == 0.0 else nsmi for nsmi in self.nsm[i]]
Tst = ['' if tsti == 0.833333 else tsti for tsti in self.tst[i]]
TwelveIt3 = ['' if tw == 1.0 else tw for tw in self.twelveIt3[i]]
to2 = self.thickness[i] / 2
Z1 = ['' if z1i == -to2[j] else z1i for j, z1i in enumerate(self.z1[i])]
Z2 = ['' if z2i == to2[j] else z2i for j, z2i in enumerate(self.z2[i])]
for (pid, mid, t, mid2, twelveIt3, mid3, tst, nsm, z1, z2, mid4) in zip(
self.property_id[i], self.material_id[i], self.thickness[i], Mid2,
TwelveIt3, Mid3, Tst, Nsm, Z1, Z2, Mid4):
card = ['PSHELL', pid, mid, t, mid2, twelveIt3, mid3,
tst, nsm, z1, z2, mid4]
f.write(print_card(card, size=size))
示例11: write_bdf
def write_bdf(self, f, size=8, lids=None):
if self.n:
for (lid, nid, cid, mag, xyz) in izip(
self.load_id, self.node_id, self.coord_id, self.mag, self.xyz):
card = ['MOMENT', lid, nid, cid, mag, xyz[0], xyz[1], xyz[2] ]
f.write(print_card(card))
示例12: write_bdf
def write_bdf(self, f, size=8):
if self.n:
for constraint in self.constraints:
card = ['MPC', self.constraint_id]
for (G, C, A) in constraint:
card += [G, C, A]
f.write(print_card(card))
示例13: test_rbe1_02
def test_rbe1_02(self):
lines = ['RBE1 1001 1000 123456',
' UM 1002 123 1003 123 1004 123',
' 1005 123 1006 123 1008 123',
' 1009 123 1010 123 1011 123',
' 1012 123',]
card = bdf.process_card(lines)
#print(print_card(card))
card = BDFCard(card)
#print(card)
card2 = RBE1(card)
fields = card2.rawFields()
msg = print_card(fields).rstrip()
#print(msg)
lines_expected = ['RBE1 1001 1000 123456',
' UM 1002 123 1003 123 1004 123',
' 1005 123 1006 123 1008 123',
' 1009 123 1010 123 1011 123',
' 1012 123',]
lines_actual = msg.rstrip().split('\n')
msg = '\n%s\n\n%s\n' % ('\n'.join(lines_expected), msg)
msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
self.assertEqual(len(lines_actual), len(lines_expected), msg)
for actual, expected in zip(lines_actual, lines_expected):
self.assertEqual(actual, expected)
示例14: write_bdf
def write_bdf(self, f, size=8):
if self.n:
for dof, node_ids in sorted(self.components.iteritems()):
card = ['SPC', self.constraint_id]
for node_id in node_ids:
card += [node_id, dof, 0.0]
f.write(print_card(card))
示例15: __repr__
def __repr__(self):
"""
Prints a card in the simplest way possible
(default values are left blank).
"""
comment = self.comment
list_fields = self.repr_fields()
try:
return comment + print_card(list_fields, size=8)
except:
try:
return comment + print_card(list_fields, size=16)
except:
print('problem printing %s card' % self.type)
print("list_fields = ", list_fields)
raise