Skip to content

Commit

Permalink
gui:
Browse files Browse the repository at this point in the history
 - removing DisplacementResults in favor of DisplacementResults2
 - fixing results clear bug

op2:
 - fixing forces being dropped
  • Loading branch information
SteveDoyle2 committed Dec 2, 2024
1 parent 114b9a9 commit b3a2d5b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 87 deletions.
104 changes: 31 additions & 73 deletions pyNastran/converters/nastran/gui/results_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from pyNastran.femutils.utils import safe_norm
from pyNastran.gui.gui_objects.gui_result import GuiResult, GuiResultIDs
from pyNastran.gui.gui_objects.displacements import (
DisplacementResults, ForceTableResults) #, TransientElementResults
#DisplacementResults,
ForceTableResults) #, TransientElementResults
from pyNastran.op2.result_objects.stress_object import (
_get_nastran_header,
get_rod_stress_strain,
Expand Down Expand Up @@ -1467,20 +1468,14 @@ def _fill_nastran_ith_displacement(result, resname: str,
3: {'title': 'M_', 'corner': 'M_'},
}
if deflects:
if use_new_sidebar_objects:
nastran_res2 = DisplacementResults2(
subcase_idi, node_ids, xyz_cid0, case,
title=resname,
t123_offset=t123_offset,
dim_max=dim_max,
data_format='%g', nlabels=None, labelsize=None,
ncolors=None, colormap='', set_max_min=False,
uname=resname)
if use_old_sidebar_objects:
nastran_res = DisplacementResults(subcase_idi, titles, headers,
xyz_cid0, t123, tnorm,
scales,
uname=resname)
nastran_res2 = DisplacementResults2(
subcase_idi, node_ids, xyz_cid0, case,
title=resname,
t123_offset=t123_offset,
dim_max=dim_max,
data_format='%g', nlabels=None, labelsize=None,
ncolors=None, colormap='', set_max_min=False,
uname=resname)

for itime in range(ntimes):
# mode = 2; freq = 75.9575 Hz
Expand All @@ -1491,52 +1486,30 @@ def _fill_nastran_ith_displacement(result, resname: str,
case.superelement_adaptivity_index,
case.pval_step)

if use_old_sidebar_objects:
tnorm_abs_max = get_tnorm_abs_max(case, t123, tnorm, itime)
scale = dim_max
if tnorm_abs_max > 0.0:
scale = dim_max / tnorm_abs_max * 0.10
scales.append(scale)
titles.append(title1)
headers.append(f'{title1}: {header}')

# fill the case
cases[icase] = (nastran_res, (itime, title1)) # do I keep this???
formii: Form = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1

if use_new_sidebar_objects:
headers2.append(header)
cases[icase] = (nastran_res2, (itime, title1)) # do I keep this???
formii: Form = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1
headers2.append(header)
cases[icase] = (nastran_res2, (itime, title1)) # do I keep this???
formii: Form = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1

#if name == 'Displacement':
# Displacement; itime=361 time=3.61 tnorm=1.46723
#print('dmax = ', max(dmax))
#pass
else:
dim_max = 1.0
if use_old_sidebar_objects:
nastran_res = ForceTableResults(subcase_idi, titles, headers,
t123, tnorm,
scales, #deflects=deflects,
uname=resname)

methods_txyz_rxyz = ['Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz']
if use_new_sidebar_objects:
nastran_res2 = ForceResults2(
subcase_idi, node_ids, xyz_cid0, case,
title=resname,
t123_offset=t123_offset,
methods_txyz_rxyz=methods_txyz_rxyz,
index_to_base_title_annotation=force_index_to_base_title_annotation,
dim_max=dim_max,
data_format='%g', nlabels=None, labelsize=None,
ncolors=None, colormap='', set_max_min=False,
uname=resname)
nastran_res2 = ForceResults2(
subcase_idi, node_ids, xyz_cid0, case,
title=resname,
t123_offset=t123_offset,
methods_txyz_rxyz=methods_txyz_rxyz,
index_to_base_title_annotation=force_index_to_base_title_annotation,
dim_max=dim_max,
data_format='%g', nlabels=None, labelsize=None,
ncolors=None, colormap='', set_max_min=False,
uname=resname)
for itime in range(ntimes):
dt = case._times[itime]
header = _get_nastran_header(case, dt, itime)
Expand All @@ -1547,27 +1520,12 @@ def _fill_nastran_ith_displacement(result, resname: str,

#tnorm_abs_max = get_tnorm_abs_max(case, t123, tnorm, itime)
#tnorm_abs_max = tnorm.max()
if use_old_sidebar_objects:
scale = 1.
scales.append(scale)
titles.append(title1)
headers.append(f'{title1}: {header}')
# fill data
cases[icase] = (nastran_res, (itime, title1)) # do I keep this???
formii = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1

if use_new_sidebar_objects:
headers2.append(header)
cases[icase] = (nastran_res2, (itime, title1)) # do I keep this???
formii: Form = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1
if use_old_sidebar_objects:
nastran_res.save_defaults()
if use_new_sidebar_objects:
nastran_res2.headers = headers2
headers2.append(header)
cases[icase] = (nastran_res2, (itime, title1)) # do I keep this???
formii: Form = (title1, icase, [])
form_dict[(key, itime)].append(formii)
icase += 1
nastran_res2.headers = headers2
return icase

def _fill_nastran_temperatures(cases: Cases, model: OP2,
Expand Down
8 changes: 4 additions & 4 deletions pyNastran/converters/nastran/nastran_to_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def save_nastran_results(gui: NastranGUI,
point_data, cell_data, log)
continue

elif isinstance(case, DisplacementResults):
_save_displacement_results(icase, case, key, index_name, used_titles,
point_data, cell_data, log)
continue
# elif isinstance(case, DisplacementResults):
# _save_displacement_results(icase, case, key, index_name, used_titles,
# point_data, cell_data, log)
# continue

elif isinstance(case, SimpleTableResults):
_save_simple_table_results(icase, case, key, index_name, used_titles,
Expand Down
18 changes: 11 additions & 7 deletions pyNastran/converters/nastran/test_nastran_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
from pyNastran.gui.qt_files.gui_attributes import IS_CUTTING_PLANE

from pyNastran.gui.gui_objects.gui_result import GuiResult, NormalResult, GridPointForceResult
from pyNastran.gui.gui_objects.displacements import DisplacementResults, ForceTableResults, ElementalTableResults
from pyNastran.gui.gui_objects.displacements import (
#DisplacementResults,
ForceTableResults, ElementalTableResults)

from pyNastran.converters.nastran.gui.result_objects.simple_table_results import SimpleTableResults
from pyNastran.converters.nastran.gui.result_objects.layered_table_results import LayeredTableResults
Expand All @@ -52,7 +54,7 @@
from pyNastran.converters.nastran.gui.result_objects.plate_stress_results import PlateStrainStressResults2
from pyNastran.converters.nastran.gui.result_objects.solid_stress_results import SolidStrainStressResults2

RED = (1., 0., 0.)
RED_FLOAT = (1., 0., 0.)


class NastranGUI(NastranIO, FakeGUIMethods):
Expand Down Expand Up @@ -138,7 +140,8 @@ def validate_result_object_methods(self):
res.get_annotation(itime, res_name)
elif isinstance(res, GridPointForceResult):
pass
elif isinstance(res, (DisplacementResults, ForceTableResults)): # ElementalTableResults
elif isinstance(res, ForceTableResults):
# DisplacementResults, , ElementalTableResults
res.get_annotation(itime, res_name)
res.get_arrow_scale(itime, res_name)
#res.get_case_flag(itime, res_name)
Expand Down Expand Up @@ -312,7 +315,7 @@ def test_settings(self):
test.settings.update_coord_scale(coord_scale=None, render=True)
test.settings.set_background_color_to_white(render=True)

color = RED
color = RED_FLOAT
opacity = 0.4
test.settings.set_background_color(color, render=True)
test.settings.set_background_color2(color, render=True)
Expand Down Expand Up @@ -822,8 +825,8 @@ def test_solid_bending_missing_nodes(self):

def test_beam_modes_01(self):
"""CBAR/CBEAM - PARAM,POST,-1"""
bdf_filename = os.path.join(MODEL_PATH, 'beam_modes', 'beam_modes.dat')
op2_filename = os.path.join(MODEL_PATH, 'beam_modes', 'beam_modes_m1.op2')
bdf_filename = MODEL_PATH / 'beam_modes' / 'beam_modes.dat'
op2_filename = MODEL_PATH / 'beam_modes' / 'beam_modes_m1.op2'

test = NastranGUI()
test.load_nastran_geometry(bdf_filename)
Expand Down Expand Up @@ -1045,7 +1048,7 @@ def test_bwb_gui(self):
#nplate_force=0
)
assert nresults == 85, (len(test.result_cases), nresults) # -95
asdf
raise RuntimeError(nresults)

test.group_actions.create_groups_by_property_id()
test.group_actions.create_groups_by_visible_result(nlimit=50)
Expand Down Expand Up @@ -1981,6 +1984,7 @@ def get_nreal_nresults(test,
if not nastran_settings.strain_energy:
nstrain_energy = 0
ntables = (
# *2 is for translation/rotation
nspc_force + nmpc_force + nload_vectors +
ndisplacement + neigenvectors) * 2

Expand Down
9 changes: 9 additions & 0 deletions pyNastran/gui/menus/results_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

SHOW_NAME_MAIN = False
SHOW_CASE_SPINNER = False
SPINNER_READ_ONLY = 'QSpinBox {background-color: lightblue;}'

SkippableSpinBox = QSpinBox
#class SkippableSpinBox(QSpinBox):
Expand Down Expand Up @@ -382,6 +383,9 @@ def set_output_checkbox(self,
self.vector_checkbox.setChecked(is_checked_vector)

def hide_dev(self):
#self.case_spinner_label
#self.case_spinner.setReadOnly(True)
self.case_spinner.setStyleSheet(SPINNER_READ_ONLY)
objs = [
self.case_spinner_label, self.case_spinner,
self.deflection_label, self.deflection_edit,
Expand Down Expand Up @@ -722,6 +726,11 @@ def on_apply(self):
index_list_b = [0]
self.update_vtk_window(keys_a, index_list_b)

#self._update_case = False
#self.case_spinner.setValue(icase)
#self._update_case = True
#self.case_spinner.setValue(icase)

def update_vtk_window(self,
key_a: int,
keys_b: list[int]) -> None:
Expand Down
2 changes: 2 additions & 0 deletions pyNastran/gui/qt_files/gui_qt_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def get_subtitle_label(self, subcase_id: int) -> tuple[str, str]:

def on_clear_results(self, show_msg: bool=True) -> None:
"""clears the model of all results"""
if self.icase == -1:
return
(obj, (i, resname)) = self.result_cases[self.icase]
unused_location = obj.get_location(i, resname)

Expand Down
4 changes: 2 additions & 2 deletions pyNastran/gui/test/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

from pyNastran.gui.arg_handling import (
INPUT_FORMAT_TO_EXTENSION, OUTPUT_FORMAT_TO_EXTENSION)
INPUT_FORMAT_TO_EXTENSION['nastran].append('.dat')
#INPUT_FORMAT_TO_EXTENSION['tecplot].append('.dat')
INPUT_FORMAT_TO_EXTENSION['nastran'].append('.dat')
#INPUT_FORMAT_TO_EXTENSION['tecplot'].append('.dat')


#pkg_path = pyNastran.__path__[0]
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/op2/tables/oef_forces/oef.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def _read_oef1_loads(self, data: bytes, ndata: int):
"""Reads the OEF1 table; stores the element forces/heat flux."""
op2 = self.op2
#self._apply_oef_ato_crm_psd_rms_no('') # TODO: just testing
if op2._results.is_not_saved('forces'):
if op2._results.is_not_saved('force'):
return ndata

prefix, postfix = self.get_oef_prefix_postfix()
Expand Down

0 comments on commit b3a2d5b

Please sign in to comment.