Skip to content

Commit

Permalink
OP2 Geom
Browse files Browse the repository at this point in the history
 - fixing PCONV (NX), GRID (cid < 0), SPCD
  • Loading branch information
SteveDoyle2 committed Jul 26, 2016
1 parent 9c193c4 commit b281772
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pyNastran/bdf/cards/test/all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pyNastran.bdf.cards.test.test_loads import TestLoads
from pyNastran.bdf.cards.test.test_materials import TestMaterials
from pyNastran.bdf.cards.test.test_other import TestOther
#from pyNastran.bdf.cards.test.test_optimization import TestOpt
from pyNastran.bdf.cards.test.test_optimization import TestOpt
from pyNastran.bdf.cards.test.test_rigid import TestRigid
from pyNastran.bdf.cards.test.test_springs import TestSprings
from pyNastran.bdf.cards.test.test_solids import TestSolids
Expand Down
8 changes: 6 additions & 2 deletions pyNastran/op2/op2.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,24 @@ def build_dataframe(self):
obj.build_dataframe()
obj.object_methods()
except:
self.log.error(obj)
self.log.error('build_dataframe is broken for %s' % class_name)
raise
#raise
continue
if obj.is_sort2():
self.log.warning(obj)
self.log.warning('build_dataframe is not supported for %s - SORT2' % class_name)
continue
try:
obj.build_dataframe()
except NotImplementedError:
self.log.warning(obj)
self.log.warning('build_dataframe is broken for %s' % class_name)
#raise
except:
self.log.error(obj)
self.log.error('build_dataframe is broken for %s' % class_name)
raise
#raise
#if i >= nbreak:
#return

Expand Down
43 changes: 38 additions & 5 deletions pyNastran/op2/tables/geom/ept.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def _add_op2_property(self, prop):
self.add_property(prop, allow_overwrites=True)
#print(str(prop)[:-1])

def _add_pconv(self, prop):
if prop.pconid > 100000000:
raise RuntimeError('bad parsing...%s' % str(prop))
self.add_convection_property(prop)

# HGSUPPR

def _read_nsm(self, data, n):
Expand Down Expand Up @@ -435,24 +440,52 @@ def _read_pconeax(self, data, n):
return len(data)

def _read_pconv(self, data, n):
"""common method for reading PCONVs"""
n = self._read_dual_card(data, n, self._read_pconv_nx, self._read_pconv_msc,
'PCONV', self._add_pconv)
return n

def _read_pconv_nx(self, data, n):
"""
(11001,110,411)- Record 25
(11001,110,411)- NX version
"""
ntotal = 16 # 4*4
s = Struct(b(self._endian + '3if'))
nentries = (len(data) - n) // ntotal
assert (len(data) - n) % ntotal == 0
props = []
for i in range(nentries):
out = s.unpack(data[n:n+ntotal])
(pconid, mid, form, expf) = out
ftype = tid = chlen = gidin = ce = e1 = e2 = e3 = None
data_in = (pconid, mid, form, expf, ftype, tid, chlen,
gidin, ce, e1, e2, e3)

prop = PCONV.add_op2_data(data_in)
props.append(prop)
n += ntotal
return n, props

def _read_pconv_msc(self, data, n):
"""
(11001,110,411)- MSC version - Record 25
"""
ntotal = 56 # 14*4
s = Struct(b(self._endian + '3if 4i fii 3f'))
nentries = (len(data) - n) // ntotal
assert (len(data) - n) % ntotal == 0
props = []
for i in range(nentries):
out = s.unpack(data[n:n+ntotal])
(pconid, mid, form, expf, ftype, tid, undef1, undef2, chlen,
gidin, ce, e1, e2, e3) = out
data_in = (pconid, mid, form, expf, ftype, tid, chlen,
gidin, ce, e1, e2, e3)
gidin, ce, e1, e2, e3)

prop = PCONV.add_op2_data(data_in)
self._add_op2_property(prop)
props.append(prop)
n += ntotal
self.card_count['PCONV'] = nentries
return n
return n, props

def _read_pconvm(self, data, n): # 26
self.log.debug('skipping PCONVM in EPT\n')
Expand Down
5 changes: 3 additions & 2 deletions pyNastran/op2/tables/geom/geom1.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ def _read_grid(self, data, n): # 21.8 sec, 18.9
#self.nodes[nid] = node
#self.add_node(node)
else:
self.log.debug("*nid=%s cp=%s x1=%-5.2f x2=%-5.2f x3=%-5.2f cd=%-2s ps=%s seid=%s" %
(nid, cp, x1, x2, x3, cd, ps, seid))
self.log.debug('*nid=%s cp=%s x1=%-5.2f x2=%-5.2f x3=%-5.2f cd=%-2s ps=%s '
'seid=%s' % (nid, cp, x1, x2, x3, cd, ps, seid))
node = GRID(nid, cp, np.array([x1, x2, x3]), cd, ps, seid)
self.reject_cards.append(str(node))
n += ntotal
return n
Expand Down
10 changes: 6 additions & 4 deletions pyNastran/op2/tables/geom/geom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,14 +914,16 @@ def _read_dual_card(self, data, n, nx_read, msc_read, card_name, add_method):
n0 = n
if self.is_nx:
try:
n, elements = self.nx_read(data, n)
n, elements = nx_read(data, n)
except AssertionError:
n, elements = self.msc_read(data, n0)
#raise
n, elements = msc_read(data, n0)
else:
try:
n, elements = self.msc_read(data, n)
n, elements = msc_read(data, n)
except AssertionError:
n, elements = self.nx_read(data, n0)
#raise
n, elements = nx_read(data, n0)

nelements = len(elements)
for elem in elements:
Expand Down
26 changes: 13 additions & 13 deletions pyNastran/op2/tables/geom/geom4.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,18 @@ def _read_spcadd(self, data, n):

def _read_spcd(self, data, n):
"""common method for reading SPCDs"""
self._read_dual_card(data, n, self._read_spcd_nx, self._read_spcd_msc,
'SPCD', self.add_load)
#if self.is_nx:
#n = self._read_spcd_nx(data, n)
#else:
#n = self._read_spcd_msc(data, n)
n = self._read_dual_card(data, n, self._read_spcd_nx, self._read_spcd_msc,
'SPCD', self.add_load)
return n

def _read_spcd_nx(self, data, n):
"""SPCD(5110,51,256) - NX specific"""
s = Struct(b(self._endian + '3ifi'))
s = Struct(b(self._endian + '3if'))
ntotal = 16 # 4*4
nentries = (len(data) - n) // ntotal
assert nentries > 0, nentries
assert (len(data) - n) % ntotal == 0
loads = []
for i in range(nentries):
edata = data[n:n + ntotal]
#self.show_data(edata)
Expand All @@ -407,16 +406,18 @@ def _read_spcd_nx(self, data, n):
if self.is_debug_file:
self.binary_debug.write(' SPCD=%s\n' % str(out))
constraint = SPCD.add_op2_data([sid, ID, c, dx])
self.add_load(constraint)
loads.append(constraint)
n += ntotal
self.card_count['SPCD'] = nentries
return n
return n, loads

def _read_spcd_msc(self, data, n):
"""SPCD(5110,51,256) - MSC specific - Record 47"""
s = Struct(b(self._endian + '4ifi'))
ntotal = 20 # 5*4
nentries = (len(data) - n) // ntotal
assert nentries > 0, nentries
assert (len(data) - n) % ntotal == 0
loads = []
for i in range(nentries):
edata = data[n:n + ntotal]
#self.show_data(edata)
Expand All @@ -426,10 +427,9 @@ def _read_spcd_msc(self, data, n):
if self.is_debug_file:
self.binary_debug.write(' SPCD=%s\n' % str(out))
constraint = SPCD.add_op2_data([sid, ID, c, dx])
self.add_load(constraint)
loads.append(constraint)
n += ntotal
self.card_count['SPCD'] = nentries
return n
return n, loads

def _read_spcde(self, data, n):
self.log.debug('skipping SPCDE in GEOM4\n')
Expand Down

0 comments on commit b281772

Please sign in to comment.