Skip to content

Commit

Permalink
various minor gui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Nov 12, 2024
1 parent 8b48c70 commit 1fe79df
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ htmlcov
*.exe
*.whl
*.dll
*.log
*.rar
*.out
*.log
Expand All @@ -25,7 +24,6 @@ htmlcov
*.pdf
*.h5
*.gz
*.json

# pyInstaller building
#*.qm
Expand Down
4 changes: 2 additions & 2 deletions pyNastran/bdf/cards/properties/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NSMx(Property):
#: Set points to either Property entries or Element entries.
#: Properties are:
valid_properties = [
'PSHELL', 'PCOMP', 'PBAR', 'PBARL', 'PBEAM', 'PBEAML', 'PBCOMP',
'PSHELL', 'PCOMP', 'PCOMPG', 'PBAR', 'PBARL', 'PBEAM', 'PBEAML', 'PBCOMP',
'PROD', 'CONROD', 'PBEND', 'PSHEAR', 'PTUBE', 'PCONEAX', 'PRAC2D',
'ELEMENT', 'PDUM8',
]
Expand Down Expand Up @@ -147,7 +147,7 @@ def write_card(self, size: int=8, is_double: bool=False) -> str:
class NSM1x(Property):
"""Common class for NSM1 and NSML1"""
valid_properties = [
'PSHELL', 'PCOMP', 'PBAR', 'PBARL', 'PBEAM', 'PBEAML', 'PBCOMP',
'PSHELL', 'PCOMP', 'PCOMPG', 'PBAR', 'PBARL', 'PBEAM', 'PBEAML', 'PBCOMP',
'PROD', 'CONROD', 'PBEND', 'PSHEAR', 'PTUBE', 'PCONEAX', 'PRAC2D',
'ELEMENT',
]
Expand Down
40 changes: 28 additions & 12 deletions pyNastran/bdf/mesh_utils/cmd_line/create_flutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:

from docopt import docopt
import pyNastran
options = '[-o OUT_BDF_FILENAME] [--size SIZE | --clean] [--sid SID]'
msg = (
'Usage:\n'
# SWEEP_UNIT
# CONST_TYPEs = [mach, alt]

# CONST_TYPE = mach
#' bdf flutter gui\n'
' bdf flutter UNITS eas EAS1 EAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [-o OUT_BDF_FILENAME] [--size SIZE | --clean]\n'
' bdf flutter UNITS tas TAS1 TAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] [-o OUT_BDF_FILENAME] [--size SIZE | --clean]\n'
' bdf flutter UNITS alt ALT1 ALT2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] [-o OUT_BDF_FILENAME] [--size SIZE | --clean]\n'
f' bdf flutter UNITS eas EAS1 EAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT {options}\n'
f' bdf flutter UNITS tas TAS1 TAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] {options}\n'
f' bdf flutter UNITS alt ALT1 ALT2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] {options}\n'

# CONST_TYPE = alt
#' bdf flutter UNITS eas EAS1 EAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [-o OUT_BDF_FILENAME] [--size SIZE] [--clean]\n'
#' bdf flutter UNITS tas TAS1 TAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] [-o OUT_BDF_FILENAME] [--size SIZE | --clean]\n'
' bdf flutter UNITS mach MACH1 MACH2 N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] [-o OUT_BDF_FILENAME] [--size SIZE | --clean]\n'
#' bdf flutter UNITS eas EAS1 EAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT {options}\n'
#' bdf flutter UNITS tas TAS1 TAS2 SWEEP_UNIT N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] {options}\n'
' bdf flutter UNITS mach MACH1 MACH2 N CONST_TYPE CONST_VAL CONST_UNIT [--eas_limit EAS EAS_UNITS] {options}\n'

' bdf flutter -h | --help\n'
' bdf flutter -v | --version\n'
Expand All @@ -67,16 +68,18 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:
' -o OUT, --output OUT_BDF_FILENAME path to output BDF/DAT/NAS file (default=flutter_cards.inc)\n'
' --size SIZE size of the BDF (8/16; default=16)\n'
' --clean writes a BDF with at least 1 whitespace in an FLFACT field (for readability)\n'
' --sid SID updates the flutter ID\n'
'\n'

'Info:\n'
' -h, --help show this help message and exit\n'
" -v, --version show program's version number and exit\n"
'\n'
'Examples:\n'
' bdf flutter english_in tas .1 800. ft/s 101 alt 2500 m\n'
' bdf flutter english_in mach .05 0.5 101 alt 2500\n'
' bdf flutter english_in mach .05 0.5 101 alt 2500 m --eas_limit 300 knots --out flutter_cards_temp.inc --size 16\n'
' bdf flutter english_in eas 1 800. knots 101 mach 0.8 na\n'
' bdf flutter english_in tas .1 800. ft/s 101 alt 2500 m\n'
' bdf flutter english_in mach .05 0.5 101 alt 2500\n'
' bdf flutter english_in mach .05 0.5 101 alt 2500 m --eas_limit 300 knots --out flutter_cards_temp.inc --size 16\n'
)
filter_no_args(msg, argv, quiet=quiet)

Expand All @@ -89,7 +92,7 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:
data = cmd_line_gui()
else:
argv = [str(arg) for arg in argv]
cmd = ' '.join(argv[1:])
cmd = 'bdf ' + ' '.join(argv[1:])
data = docopt(msg, version=ver, argv=argv[1:])

if not quiet: # pragma: no cover
Expand All @@ -99,6 +102,10 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:
if data['--size']:
size = _int(data, '--size')

sid = 1
if data['--sid']:
sid = _int(data, '--sid')

units_out = data['UNITS']
if units_out.lower() not in UNITS_MAP: # pragma: no cover
raise NotImplementedError(units_out)
Expand Down Expand Up @@ -157,6 +164,7 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:
const_type, const_value, const_unit,
eas_limit=eas_limit, eas_units=eas_units,
units_out=units_out,
sid=sid,
size=size, clean=clean,
bdf_filename_out=bdf_filename_out,
comment=cmd)
Expand All @@ -166,7 +174,8 @@ def cmd_line_create_flutter(argv=None, quiet: bool=False) -> None:
def create_flutter(log: SimpleLogger,
sweep_method: str, value1: float, value2: float, sweep_unit: str, npoints: int,
const_type: str, const_value: float, const_unit: str,
eas_limit=1_000_000, eas_units: str='m/s',
sid: int=1,
eas_limit: float=1_000_000.0, eas_units: str='m/s',
units_out: str='si',
size: int=8,
clean: bool=False,
Expand Down Expand Up @@ -194,34 +203,40 @@ def create_flutter(log: SimpleLogger,

sweep_unit = sweep_unit.lower()
values = np.linspace(value1, value2, num=npoints)
dvalue1 = values[1] - values[0]
if sweep_method == 'alt':
assert sweep_unit in ALT_UNITS, f'sweep_unit={sweep_unit!r}; allowed={ALT_UNITS}'
alts = convert_altitude(values, sweep_unit, alt_units)
unit2 = alt_units

elif sweep_method == 'mach':
machs = values
unit2 = 'na'
elif sweep_method == 'eas':
eass = values
eas_units = sweep_unit
unit2 = eas_units
#assert sweep_unit in VELOCITY_UNITS, f'sweep_unit={sweep_unit!r}; allowed={VELOCITY_UNITS}'
#eass = convert_velocity(eass, sweep_unit, velocity_units)

elif sweep_method == 'tas':
assert sweep_unit in VELOCITY_UNITS, f'sweep_unit={sweep_unit!r}; allowed={VELOCITY_UNITS}'
tass = convert_velocity(values, sweep_unit, velocity_units)
unit2 = velocity_units
elif sweep_method == 'alt':
assert sweep_unit in ALT_UNITS, f'sweep_unit={sweep_unit!r}; allowed={ALT_UNITS}'
alts = convert_altitude(values, sweep_unit, alt_units)
unit2 = alt_units
else: # pragma: no cover
raise NotImplementedError(sweep_method)
dvalue2 = values[1] - values[0]

#------------------------------------------------------------------
from pyNastran.bdf.bdf import BDF
model = BDF(log=log)
model.set_error_storage(nparse_errors=100, stop_on_parsing_error=True,
nxref_errors=100, stop_on_xref_error=False)
flutter_method = 'PKNL'
sid = 1

flfact_density = sid + 1
flfact_mach = sid + 2
Expand All @@ -238,6 +253,7 @@ def create_flutter(log: SimpleLogger,
eas_units = eas_units_default

log.info(f'sweep_method={sweep_method!r}')
log.debug(f' d{sweep_unit} = {dvalue1!r} {sweep_unit} = {dvalue2!r} {unit2}')
log.debug(f' alt_units={alt_units!r}')
log.debug(f' velocity_units={velocity_units!r}')
log.debug(f' density_units={density_units!r}')
Expand Down
27 changes: 24 additions & 3 deletions pyNastran/converters/nastran/gui/nastran_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ def load_nastran_geometry_unvectorized(self, bdf_filename: str,
xyz_cid0, nid_cp_cd = self.get_xyz_in_coord(model, cid=0, fdtype='float32')
xyz_cid0 = gui.scale_length(xyz_cid0)
dim_max = self._points_to_vtkpoints_coords(model, xyz_cid0)
self.node_ids = nid_cp_cd[:, 0]
self.node_ids = nid_cp_cd[:, 0]
else:
self.node_ids = np.zeros(0, dtype='int32')

#-----------------------------------------------------------------------
nconm2 = _create_masses(
Expand All @@ -627,12 +629,14 @@ def load_nastran_geometry_unvectorized(self, bdf_filename: str,
#-----------------------------------------------------------------------
j = 0
nid_map = gui.nid_map
idtype = nid_cp_cd.dtype
idtype = self.node_ids.dtype
self.element_ids = np.zeros(0, dtype='int32')
nid_to_pid_map, icase, cases, form = self.map_elements(
xyz_cid0, nid_cp_cd, nid_map, model, j, dim_max,
plot=plot, xref_loads=xref_loads)

create_monpnt(self, model, xyz_cid0, nid_cp_cd)
if xyz_cid0 is not None:
create_monpnt(self, model, xyz_cid0, nid_cp_cd)
self._create_aero(model, box_id_to_caero_element_map, cs_box_ids,
caero_points, ncaeros_points, ncaero_sub_points,
has_control_surface)
Expand Down Expand Up @@ -862,6 +866,8 @@ def _create_splines(self, model: BDF,
# 3/5/7/... - spline points
# 2/4/6/... - spline panels
iaero = 2
nsplines = 0
all_structure_points_list = []
for spline_id, spline in sorted(model.splines.items()):
# SPLINE2 -> spline2
# SPLINE3_ZONEA -> spline3
Expand All @@ -879,6 +885,8 @@ def _create_splines(self, model: BDF,
else:
structure_points = setg_ref.get_ids()

all_structure_points_list.extend(structure_points)
nsplines += 1
try:
aero_box_ids = spline.aero_element_ids
except Exception:
Expand Down Expand Up @@ -914,6 +922,19 @@ def _create_splines(self, model: BDF,
stored_msg.append(stored_msgi)
if stored_msgi2:
stored_msg.append(stored_msgi2)

all_structure_points = np.unique(all_structure_points_list)
if nsplines > 1:
grid_name = 'all_spline_points'
gui.create_alternate_vtk_grid(
grid_name, color=BLUE_FLOAT, opacity=1.0, point_size=5,
representation='point', is_visible=False)
msg = f', which is required by {grid_name!r}'
stored_msgi = self._add_nastran_nodes_to_grid(
grid_name, all_structure_points, model, msg, store_msg=True)
if stored_msgi:
stored_msg.append(stored_msgi)

if stored_msg:
model.log.warning('\n' + '\n'.join(stored_msg))

Expand Down
2 changes: 1 addition & 1 deletion pyNastran/f06/f06_matrix_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _read_f06_matrices(f06_file: TextIO,
matrices['MHH'] = np.diag(Mhh[isort])
matrices['BHH'] = np.diag(Bhh[isort])
matrices['KHH'] = np.diag(Khh[isort])
del line_strip, Mhh, Bhh, Khh
del Mhh, Bhh, Khh

if line.startswith('0 TABLE'):
table_name, table, line, i = _read_table(f06_file, line, i, log)
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/gui/gui_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ def _finish_results_io2(self, model_name: str,
#eids = np.arange(172)
#eids = []
#self.hide_elements_mask(eids)
if self.element_ids is None:
if self.element_ids is None or len(self.element_ids) == 0:
self.element_ids = np.array([], dtype='int32')
elements_pound = 1
else:
Expand Down

0 comments on commit 1fe79df

Please sign in to comment.