本文整理汇总了Python中pyNastran.bdf.field_writer_8.print_card_8函数的典型用法代码示例。如果您正苦于以下问题:Python print_card_8函数的具体用法?Python print_card_8怎么用?Python print_card_8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_card_8函数的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_8(fields1), print_card_8(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: write_card
def write_card(self, size=8, is_double=False):
msg = '\n$' + '-' * 80
msg += '\n$ %s Matrix %s\n' % ('DMI', self.name)
list_fields = ['DMI', self.name, 0, self.form, self.tin,
self.tout, None, self.nRows, self.nCols]
if size == 8:
msg += print_card_8(list_fields)
#elif is_double:
#msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
#msg += self.print_card(list_fields,size=16,isD=False)
if self.is_complex():
for (gci, gcj, reali, imagi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
list_fields = ['DMI', self.name, gcj, gci, reali, imagi]
if size == 8:
msg += print_card_8(list_fields)
elif is_double:
msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
else:
for (gci, gcj, reali) in zip(self.GCi, self.GCj, self.Real):
list_fields = ['DMI', self.name, gcj, gci, reali]
if size == 8:
msg += print_card_8(list_fields)
elif is_double:
msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
return msg
示例3: _write_nodes_symmetric
def _write_nodes_symmetric(self, outfile, size=8, is_double=False, plane='xz'):
"""
Writes the NODE-type cards
Parameters
----------
self : BDF()
the BDF object
.. warning :: doesn't consider coordinate systems;
it could, but you'd need 20 new coordinate systems
.. warning :: doesn't mirror SPOINTs, EPOINTs
"""
if self.spoints:
msg = []
msg.append('$SPOINTS\n')
msg.append(self.spoints.write_card(size, is_double))
outfile.write(''.join(msg))
if self.epoints:
msg = []
msg.append('$EPOINTS\n')
msg.append(self.epoints.write_card(size, is_double))
outfile.write(''.join(msg))
plane = plane.strip().lower()
if plane == 'xz':
iy = 4
elif plane == 'xy':
iy = 5
elif plane == 'yz':
iy = 3
else:
raise NotImplementedError(plane)
if self.nodes:
msg = []
msg.append('$NODES\n')
if self.gridSet:
msg.append(self.gridSet.print_card(size))
nid_offset = max(self.nodes.keys())
if self.is_long_ids:
print_card_long = print_card_double if is_double else print_card_16
for (unused_nid, node) in sorted(iteritems(self.nodes)):
repr_fields = node.repr_fields()
msg.append(print_card_long(repr_fields))
repr_fields = node.repr_fields()
# grid, nid, cp, x, y, z
repr_fields[1] += nid_offset
repr_fields[iy] *= -1.0
msg.append(print_card_long(repr_fields))
else:
for (unused_nid, node) in sorted(iteritems(self.nodes)):
repr_fields = node.repr_fields()
msg.append(print_card_8(repr_fields))
repr_fields = node.repr_fields()
# grid, nid, cp, x, y, z
repr_fields[1] += nid_offset
repr_fields[iy] *= -1.0
msg.append(print_card_8(repr_fields))
outfile.write(''.join(msg))
示例4: cart3d_to_nastran_filename
def cart3d_to_nastran_filename(cart3d_filename, bdf_filename, log=None, debug=False):
"""
Converts a Cart3D file to Nastran format.
Parameters
----------
cart3d_filename : str
path to the input Cart3D file
bdf_filename : str
path to the output BDF file
log : log / None
log : a logger object
None : a log will be defined
debug : bool
True/False (used if log is not defined)
"""
cart3d = Cart3D(log=log, debug=debug)
cart3d.read_cart3d(cart3d_filename)
nodes = cart3d.nodes
elements = cart3d.elements
regions = cart3d.regions
#bdf = BDF()
#bdf.nodes = cart3d.nodes
#bdf.elements = cart3d.elements
#bdf.write_bdf(bdf_filename)
#return
f = open(bdf_filename, 'wb')
f.write('CEND\n')
f.write('BEGIN BULK\n')
f.write('$Nodes\n')
i = 0
nid = 1
cid = 0
for node in nodes:
card = print_card_16(['GRID', nid, cid] + list(node))
f.write(card)
nid += 1
eid = 1
f.write('$Elements\n')
for (n1, n2, n3), pid in zip(elements, regions):
card = print_card_8(['CTRIA3', eid, pid, n1, n2, n3])
f.write(card)
eid += 1
t = 0.1
E = 1e7
nu = 0.3
f.write('$Properties\n')
for pid in unique(regions):
mid = pid
card = print_card_8(['PSHELL', pid, mid, t])
f.write(card)
card = print_card_8(['MAT1', mid, E, None, nu])
f.write(card)
f.write('ENDDATA\n')
f.close()
示例5: stl_to_nastran_filename
def stl_to_nastran_filename(stl_filename, bdf_filename,
nnodes_offset=0, nelements_offset=0,
pid=100, mid=200,
size=8, is_double=False,
log=None):
model = STLReader(log=log)
model.read_stl(stl_filename)
nid = nnodes_offset + 1
cid = None
load_id = 10
nodal_normals = model.get_normals_at_nodes(model.elements)
bdf = open(bdf_filename, 'wb')
bdf.write('CEND\n')
#bdf.write('LOAD = %s\n' % load_id)
bdf.write('BEGIN BULK\n')
nid2 = 1
magnitude = 100.
if size == 8:
print_card = print_card_8
elif size == 16:
if is_double:
print_card = print_card_16
else:
print_card = print_card_double
for x, y, z in model.nodes:
card = ['GRID', nid, cid, x, y, z]
bdf.write(print_card_16(card))
#nx, ny, nz = nodal_normals[nid2 - 1]
#card = ['FORCE', load_id, nid, cid, magnitude, nx, ny, nz]
#bdf.write(print_card_8(card))
nid += 1
nid2 += 1
eid = nelements_offset + 1
for (n1, n2, n3) in (model.elements + (nnodes_offset + 1)):
card = ['CTRIA3', eid, pid, n1, n2, n3]
bdf.write(print_card_8(card))
eid += 1
t = 0.1
card = ['PSHELL', pid, mid, t]
bdf.write(print_card_8(card))
E = 1e7
G = None
nu = 0.3
card = ['MAT1', mid, E, G, nu]
bdf.write(print_card_8(card))
bdf.write('ENDDATA\n')
bdf.close()
示例6: write_card
def write_card(self, size=8, is_double=False):
"""
.. todo:: support double precision
"""
msg = '\n$' + '-' * 80
msg += '\n$ %s Matrix %s\n' % (self.type, self.name)
list_fields = [self.type, self.name, 0, self.ifo, self.tin,
self.tout, self.polar, None, self.ncols]
if size == 8:
msg += print_card_8(list_fields)
else:
msg += print_card_16(list_fields)
if self.is_complex():
if self.is_polar():
for (GCi, GCj, reali, complexi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
magi = sqrt(reali**2 + complexi**2)
if reali == 0.0:
phasei = 0.0
else:
phasei = degrees(atan2(complexi, reali))
list_fields = [self.type, self.name, GCj[0], GCj[1],
None, GCi[0], GCi[1], magi, phasei]
if size == 8:
msg += print_card_8(list_fields)
elif is_double:
msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
else:
for (GCi, GCj, reali, complexi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
list_fields = [self.type, self.name, GCj[0], GCj[1],
None, GCi[0], GCi[1], reali, complexi]
if size == 8:
msg += print_card_8(list_fields)
elif is_double:
msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
else:
for (GCi, GCj, reali) in zip(self.GCi, self.GCj, self.Real):
list_fields = [self.type, self.name, GCj[0], GCj[1],
None, GCi[0], GCi[1], reali, None]
if size == 8:
msg += print_card_8(list_fields)
elif is_double:
msg += print_card_double(list_fields)
else:
msg += print_card_16(list_fields)
return msg
示例7: __repr__
def __repr__(self):
thru_fields = collapse_thru(self.ids)
#list_fields = ['SESET', self.seid]
cards = []
while 'THRU' in thru_fields:
ithru = thru_fields.index('THRU')
card = print_card_8(['SESET', self.seid] +
thru_fields[ithru - 1:ithru + 2])
cards.append(card)
thru_fields = thru_fields[0:ithru - 1]+thru_fields[ithru + 2:]
if thru_fields:
card = print_card_8(['SESET', self.seid] + thru_fields)
cards.append(card)
return ''.join(cards)
示例8: convert_ugrid2d_to_nastran
def convert_ugrid2d_to_nastran(bdf_filename, nodes, tris, quads,
cp=2000, pid=2000, mid=2000,
axis_order=None,
nid_start=1, eid_start=1, punch=True):
if axis_order is not None:
nodes = deepcopy(nodes[:, axis_order])
with open(bdf_filename, 'wb') as bdf_file:
if not punch:
bdf_file.write('CEND\n')
bdf_file.write('BEGIN BULK\n')
cp = None
#card = ['CORD2R', cp, 0] + [0., 0., 0.] + [0., 0., 1.] + [1., 0., 0.]
#f.write(print_card_8(card))
nid = nid_start
for xi, yi, zi in nodes:
# yes I'm aware...x is the axial distance
# y/z are the x/y plane
card = ['GRID', nid, cp, xi, yi, zi]
bdf_file.write(print_card_8(card))
nid += 1
t = 0.1
card = ['PSHELL', pid, mid, t]
bdf_file.write(print_card_8(card))
E = 3.0E7
G = None
nu = 0.3
card = ['MAT1', mid, E, G, nu]
bdf_file.write(print_card_8(card))
eid = eid_start
for n1, n2, n3 in tris + nid_start:
card = ['CTRIA3', eid, pid, n1, n2, n3]
bdf_file.write(print_int_card(card))
eid += 1
for n1, n2, n3, n5 in quads + nid_start:
card = ['CQUAD4', eid, pid, n1, n2, n3, n5]
bdf_file.write(print_int_card(card))
eid += 1
if not punch:
bdf_file.write('ENDDATA\n')
示例9: write_card
def write_card(self, f, size=8, is_double=False):
#.. todo:: collapse the IDs
if self.n:
spoint = list(self.spoint)
spoint.sort()
card = ['SPOINT'] + collapse_thru(spoint)
f.write(print_card_8(card))
示例10: write_card
def write_card(self, size=8, is_double=False):
skin = []
if self.is_skin:
skin = ['SKIN']
# checked in NX 2014 / MSC 2005.1
return self.comment + print_card_8(['SET1', self.sid] + skin + self.get_ids())
示例11: write_card
def write_card(self, bdf_file, size=8):
card = ['NLPCI', self.nlpci_id, self.Type, self.minalr,
self.maxalr, self.scale, None, self.desiter, self.mxinc]
if size == 8:
bdf_file.write(print_card_8(card))
else:
bdf_file.write(print_card_16(card))
示例12: write_card
def write_card(self, f, size=8, is_double=False):
if self.n:
card = ['GRDSET', None, self.cp, None, None, None, self.cd, self.seid]
if size == 8:
f.write(print_card_8(card))
else:
f.write(print_card_16(card))
示例13: write_card
def write_card(self, f, size=8):
card = ['SPCADD', self.spc_id] + self.spc_ids
#print "card = ", card
if size == 8:
f.write(print_card_8(card))
else:
f.write(print_card_16(card))
示例14: write_card
def write_card(self, f, size=8):
for comp, nodes in iteritems(self.components):
card = ['SPC1', self.constraint_id, comp] + list(nodes)
if size == 8:
f.write(print_card_8(card))
else:
f.write(print_card_16(card))
示例15: write_card
def write_card(self, bdf_file, size=8):
card = ['SPCADD', self.spc_id] + self.spc_ids
#print("card = ", card)
if size == 8:
bdf_file.write(print_card_8(card))
else:
bdf_file.write(print_card_16(card))