Skip to content

Commit

Permalink
added plotel flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Nov 4, 2024
1 parent 1c3e80e commit 81ac906
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
6 changes: 3 additions & 3 deletions models/bwb/bwb_saero.bdf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ PARAM,WTMASS,0.00259
PARAM,BAILOUT,-1
PARAM,PRTMAXIM,YES
PARAM,POST,-1
PLOTEL,1,2356,7996
PLOTEL3,2,2356,7996,20032
PLOTEL4,3,2356,7996,20032,10342
PLOTEL,2,2356,1002
PLOTEL3,10,2356,7996,20032
PLOTEL4,20,2356,7996,20032,10342
GRID 1001 742.959 270. 89.4568
GRID 1002 762.586 270. 91.2146
GRID 1003 782.242 270. 92.6235
Expand Down
53 changes: 29 additions & 24 deletions pyNastran/converters/nastran/gui/nastran_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1976,27 +1976,14 @@ def _build_plotels(self, model: BDF) -> None:
nplotels = len(model.plotels)
if not nplotels: # pragma: no cover
return

gui: MainWindow = self.gui
nastran_settings: NastranSettings = gui.settings.nastran_settings
if not nastran_settings.is_plotel:
return

log = model.log
lines = []
tris = []
quads = []
for eid, element in sorted(model.plotels.items()):
etype = element.type
node_ids = element.node_ids
if etype == 'PLOTEL':
lines.append(node_ids)
elif etype == 'PLOTEL3':
tris.append(node_ids)
#n1, n2, n3 = node_ids
#lines.append([n1, n3])
#lines.append([n1, n2])
#lines.append([n2, n3])
elif etype == 'PLOTEL4':
quads.append(node_ids)
else: # pragma: no cover
log.warning(f'skipping {etype} eid={eid}')
lines, tris, quads = plotels_to_groups(model)
color = nastran_settings.plotel_color

elements_list = []
etypes_list = []
Expand All @@ -2018,13 +2005,10 @@ def _build_plotels(self, model: BDF) -> None:
representation = 'surface'

name = 'plotel'
nastran_settings: NastranSettings = self.settings.nastran_settings
color = nastran_settings.plotel_color
gui.create_alternate_vtk_grid(
name, color=color, line_width=2, opacity=0.8,
point_size=5, representation=representation,
is_visible=True)

is_visible=False)
alt_grid: vtkUnstructuredGrid = gui.alt_grids[name]
vtk_points: vtkPoints = alt_grid.GetPoints()

Expand All @@ -2045,7 +2029,6 @@ def _build_plotels(self, model: BDF) -> None:
#gui.follower_nodes[name] = unids

xyz_cid0 = gui.scale_length(xyz_cid0)
#vtk_points.SetNumberOfPoints(nnodes)
vtk_points = numpy_to_vtk_points(xyz_cid0, points=vtk_points)
alt_grid.SetPoints(vtk_points)

Expand Down Expand Up @@ -3874,3 +3857,25 @@ def __init__(self, node_id: np.ndarray, data: np.ndarray):
nnode = len(node_id)
self.node_gridtype = np.zeros((nnode, 2), dtype='int32')
self.data = data.reshape(1, nnode, 3)


def plotels_to_groups(model: BDF) -> tuple[
list[tuple[int, int, int]],
list[tuple[int, int, int]],
list[tuple[int, int, int, int]]]:
log = model.log
lines = []
tris = []
quads = []
for eid, element in sorted(model.plotels.items()):
etype = element.type
node_ids = element.node_ids
if etype == 'PLOTEL':
lines.append(node_ids)
elif etype == 'PLOTEL3':
tris.append(node_ids)
elif etype == 'PLOTEL4':
quads.append(node_ids)
else: # pragma: no cover
log.warning(f'skipping {etype} eid={eid}')
return lines, tris, quads
1 change: 1 addition & 0 deletions pyNastran/gui/gui_objects/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
'nastran_is_shell_mcids',
'nastran_is_rbe',
'nastran_is_aero',
'nastran_is_plotel',

'nastran_displacement', 'nastran_velocity',
'nastran_acceleration', 'nastran_eigenvector', 'nastran_temperature',
Expand Down
7 changes: 7 additions & 0 deletions pyNastran/gui/menus/preferences/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def __init__(self, data, win_parent=None):
self._nastran_is_shell_mcids = data['nastran_is_shell_mcids']
self._nastran_is_rbe = data['nastran_is_rbe']
self._nastran_is_aero = data['nastran_is_aero']
self._nastran_is_plotel = data['nastran_is_plotel']

self._nastran_stress = data['nastran_stress']
self._nastran_plate_stress = data['nastran_plate_stress']
Expand Down Expand Up @@ -440,6 +441,10 @@ def _set_widgets_nastran(self):
self.nastran_is_aero_checkbox.setToolTip('Create aero panel (CAERO/SPLINE/SET) visualization')
self.nastran_is_aero_checkbox.setChecked(self._nastran_is_aero)

self.nastran_is_plotel_checkbox = QCheckBox('PLOTELs')
self.nastran_is_plotel_checkbox.setToolTip('Create PLOTELs')
self.nastran_is_plotel_checkbox.setChecked(self._nastran_is_plotel)

self.nastran_create_coords_checkbox = QCheckBox('Coords')
self.nastran_create_coords_checkbox.setChecked(self._nastran_create_coords)

Expand Down Expand Up @@ -886,6 +891,7 @@ def _get_grid_nastran_layout(self) -> QGridLayout:
grid_nastran.addWidget(self.nastran_is_3d_bars_update_checkbox, irow, 2)
irow += 1
grid_nastran.addWidget(self.nastran_is_mass_update_checkbox, irow, 0)
grid_nastran.addWidget(self.nastran_is_plotel_checkbox, irow, 1)
return grid_nastran

def _get_grid_nastran_results_layout(self) -> QGridLayout:
Expand Down Expand Up @@ -975,6 +981,7 @@ def _set_nastran_connections(self):
self.nastran_create_coords_checkbox.clicked.connect(partial(on_nastran, self, 'create_coords'))
self.nastran_is_shell_mcids_checkbox.clicked.connect(partial(on_nastran, self, 'is_shell_mcids'))
self.nastran_is_aero_checkbox.clicked.connect(partial(on_nastran, self, 'is_aero'))
self.nastran_is_plotel_checkbox.clicked.connect(partial(on_nastran, self, 'is_plotel'))
self.nastran_is_rbe_checkbox.clicked.connect(partial(on_nastran, self, 'is_rbe'))
self.nastran_is_constraints_checkbox.clicked.connect(partial(on_nastran, self, 'is_constraints'))

Expand Down

0 comments on commit 81ac906

Please sign in to comment.