Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Dec 15, 2023
1 parent 788c723 commit 67faded
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pyNastran/converters/nastran/gui/results_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ def _fill_op2_centroidal_stress(self, cases: Cases, model: OP2,
log: SimpleLogger) -> int:
"""Creates the time accurate stress objects"""
icase = icase_old
#ncases_old = len(cases)
#assert icase_old == ncases_old
#icasei = icase_old
log = model.log
nastran_settings: NastranSettings = self.settings.nastran_settings
Expand Down Expand Up @@ -749,6 +751,7 @@ def _fill_op2_centroidal_stress(self, cases: Cases, model: OP2,
log.error(str(e))
#assert icase >= icasei
#icasei = icase
#assert len(cases) == icase

if nastran_settings.composite_plate_stress:
try:
Expand All @@ -760,6 +763,7 @@ def _fill_op2_centroidal_stress(self, cases: Cases, model: OP2,
log.error(str(e))
#assert icase >= icasei
#icasei = icase
#assert len(cases) == icase

if nastran_settings.rod_stress:
try:
Expand Down
8 changes: 5 additions & 3 deletions pyNastran/converters/nastran/gui/stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ def get_composite_plate_stress_strains(eids: np.ndarray,
helper method for _fill_op2_time_centroidal_stress.
Gets the stress/strain for each layer.
"""
icase0 = icase
#assert len(cases) == icase
#icase0 = icase
subcase_id = key[0]

if is_stress:
Expand All @@ -761,8 +762,8 @@ def get_composite_plate_stress_strains(eids: np.ndarray,
'CQUADR' : model.cquadr_composite_strain,
}

for cases in case_map.values():
for case_key, case in cases.items():
for res_cases in case_map.values():
for case_key, case in res_cases.items():
if case_key != key or key in keys_map:
continue
keys_map[key] = KeyMap(case.subtitle, case.label,
Expand Down Expand Up @@ -902,6 +903,7 @@ def get_composite_plate_stress_strains(eids: np.ndarray,
form_name2 = f'{element_type} Composite Plate {word}: {method} ({layer_name})'
form_names.append(form_name2)
icase += 1
#assert len(cases) == icase
return icase

def get_solid_stress_strains(eids: np.ndarray,
Expand Down
21 changes: 21 additions & 0 deletions pyNastran/converters/nastran/test_nastran_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ def __init__(self, inputs=None):
NastranIO.__init__(self)
self.build_fmts(['nastran'], stop_on_failure=True)

def write_result_cases(self):
case_id0 = 0
for case_id, (result_case, flag) in self.result_cases.items():
if hasattr(result_case, 'headers'):
if result_case.headers:
print(case_id, flag, result_case.headers)
else:
print(case_id, flag, result_case.__class__.__name__, result_case.methods)
elif hasattr(result_case, 'header'):
print(case_id, flag, result_case.header)
else:
raise RuntimeError(result_case)
assert case_id == case_id0, (case_id, case_id0)
case_id0 += 1

PKG_PATH = pyNastran.__path__[0]
STL_PATH = os.path.join(PKG_PATH, 'converters', 'stl')
MODEL_PATH = os.path.join(PKG_PATH, '..', 'models')
Expand Down Expand Up @@ -178,6 +193,8 @@ def test_solid_shell_bar_02(self):
test.load_nastran_geometry(bdf_filename)
test.load_nastran_results(op2_filename)
assert len(test.models['main'].elements) > 0
#test.write_result_cases()
assert len(test.result_cases) == 694, len(test.result_cases)

test.on_rcycle_results()
test.on_update_legend(
Expand Down Expand Up @@ -448,6 +465,10 @@ def test_aero_op2(self):
#test.load_nastran_geometry(bdf_filename)
test.load_nastran_geometry(op2_filename)
test.load_nastran_results(op2_filename)
#test.write_result_cases()

#print(test.result_cases[154])
#print(test.result_cases[160])
assert len(test.result_cases) == 236, len(test.result_cases)
#print(test.result_cases)

Expand Down
2 changes: 1 addition & 1 deletion pyNastran/op2/op2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ def get_key_order(self) -> list[NastranKey]:
superelement_adaptivity_index, pval_step) # str
if key not in keys3:
#print('adding ', key)
assert key in used_keys, key
#assert key in used_keys, key
keys3.append(key)
if len(keys3) == 0:
self.log.warning('No results...\n' + self.get_op2_stats(short=True))
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/op2/op2_interface/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, subtitle: str,
def __repr__(self) -> str:
msg = 'KeyMap:\n'
if self.subtitle:
msg += f' subtitle: {subtitle.label!r}\n'
msg += f' subtitle: {self.subtitle!r}\n'
if self.label:
msg += f' label: {self.label!r}\n'
if self.superelement_adaptivity_index:
Expand Down

0 comments on commit 67faded

Please sign in to comment.