Skip to content

Commit f057587

Browse files
author
Steve Doyle
committed
updates from main
1 parent e084fd7 commit f057587

File tree

22 files changed

+794
-287
lines changed

22 files changed

+794
-287
lines changed

pyNastran/bdf/bdf.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
CPLSTS3, CPLSTS4, CPLSTS6, CPLSTS8,
9191
SNORM,)
9292

93-
from .cards.properties.shell import PSHELL, PCOMP, PCOMPG, PSHEAR, PLPLANE, PPLANE, PTRSHL
93+
from .cards.properties.shell import PSHELL, PCOMP, PCOMPG, PSHEAR, PLPLANE, PPLANE, PGPLSN, PTRSHL
9494
from .cards.elements.acoustic import (
9595
CHACAB, CAABSF, CHACBR, PACABS, PAABSF, PACBAR,
9696
ACMODL, PMIC, ACPLNW, AMLREG, MATPOR, MICPNT)
@@ -251,7 +251,7 @@
251251
PBAR | PBARL | PBEAM | PBRSECT |
252252
PBEAML | PBCOMP | PBMSECT |
253253
PBEND | PBEAM3 |
254-
PSHEAR | PPLANE |
254+
PSHEAR | PPLANE | PGPLSN |
255255
PSHELL | PCOMP | PCOMPG |
256256
PSOLID | PLSOLID | PCOMPS | PCOMPLS |
257257
PWELD
@@ -722,7 +722,7 @@ def __init__(self, debug: str | bool | None=True,
722722

723723
## properties
724724
'PMASS',
725-
'PELAS', 'PGAP', 'PFAST', 'PWELD', 'PLPLANE', 'PPLANE',
725+
'PELAS', 'PGAP', 'PFAST', 'PWELD', 'PLPLANE', 'PPLANE', 'PGPLSN',
726726
'PBUSH', 'PBUSH1D', 'PBUSH2D',
727727
'PDAMP', 'PDAMP5',
728728
'PROD', 'PBAR', 'PBARL', 'PBEAM', 'PTUBE', 'PBCOMP', 'PBRSECT', 'PBEND',
@@ -1928,8 +1928,9 @@ def get_bdf_cards(self, bulk_data_lines: list[str],
19281928

19291929
for iline_bulk, line in enumerate(bulk_data_lines):
19301930
ifile_iline = bulk_data_ilines[iline_bulk, :]
1931-
#print(iline_bulk, ifile_iline, line)
1932-
#print(' backup=%r' % backup_comment)
1931+
# print(iline_bulk, ifile_iline)
1932+
# print(iline_bulk, ifile_iline, line)
1933+
# print(' backup={backup_comment!r}')
19331934
comment = ''
19341935
if '$' in line:
19351936
line, comment = line.split('$', 1)
@@ -2600,6 +2601,7 @@ def add_card(cls, card: BDFCard, comment: str=''):
26002601
'CPLSTS6': (CPLSTS6, add_methods.add_element_object),
26012602
'CPLSTS8': (CPLSTS8, add_methods.add_element_object),
26022603
'PPLANE': (PPLANE, add_methods.add_property_object),
2604+
'PGPLSN': (PGPLSN, add_methods.add_property_object),
26032605

26042606
'CSHEAR': (CSHEAR, add_methods.add_element_object),
26052607
'PSHEAR': (PSHEAR, add_methods.add_property_object),
@@ -5263,33 +5265,33 @@ def read_bdf(bdf_filename: Optional[PathLike]=None, validate: bool=True,
52635265
save_file_structure=save_file_structure,
52645266
encoding=encoding)
52655267

5266-
#if 0:
5267-
### TODO: remove all the extra methods
5268-
5269-
#keys_to_suppress = []
5270-
#method_names = model.object_methods(keys_to_skip=keys_to_suppress)
5271-
5272-
#methods_to_remove = [
5273-
#'_process_card', 'read_bdf', 'disable_cards', 'set_dynamic_syntax',
5274-
#'create_card_object', 'create_card_object_fields', 'create_card_object_list',
5275-
5276-
#'set_as_msc',
5277-
#'set_as_nx',
5278-
5279-
#'pop_parse_errors',
5280-
##'pop_xref_errors',
5281-
#'set_error_storage',
5282-
#'is_reject',
5283-
#]
5284-
#for method_name in method_names:
5285-
#if method_name not in methods_to_remove + keys_to_suppress:
5286-
##print(method_name)
5287-
#pass
5288-
#else:
5289-
### TODO: doesn't work...
5290-
##delattr(model, method_name)
5291-
#pass
5292-
#model.get_bdf_stats()
5268+
# if 0:
5269+
# ## TODO: remove all the extra methods
5270+
#
5271+
# keys_to_suppress = []
5272+
# method_names = model.object_methods(keys_to_skip=keys_to_suppress)
5273+
#
5274+
# methods_to_remove = [
5275+
# '_process_card', 'read_bdf', 'disable_cards', 'set_dynamic_syntax',
5276+
# 'create_card_object', 'create_card_object_fields', 'create_card_object_list',
5277+
#
5278+
# 'set_as_msc',
5279+
# 'set_as_nx',
5280+
#
5281+
# 'pop_parse_errors',
5282+
# #'pop_xref_errors',
5283+
# 'set_error_storage',
5284+
# 'is_reject',
5285+
# ]
5286+
# for method_name in method_names:
5287+
# if method_name not in methods_to_remove + keys_to_suppress:
5288+
# #print(method_name)
5289+
# pass
5290+
# else:
5291+
# ## TODO: doesn't work...
5292+
# #delattr(model, method_name)
5293+
# pass
5294+
# model.get_bdf_stats()
52935295
return model
52945296

52955297

pyNastran/bdf/bdf_interface/add_card.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from pyNastran.bdf.cards.elements.acoustic import (
5656
CHACAB, CAABSF, CHACBR, PACABS, PAABSF, PACBAR,
5757
ACMODL, ACPLNW, AMLREG, PMIC, MICPNT, MATPOR)
58-
from pyNastran.bdf.cards.properties.shell import PSHELL, PCOMP, PCOMPG, PSHEAR, PLPLANE, PPLANE
58+
from pyNastran.bdf.cards.properties.shell import PSHELL, PCOMP, PCOMPG, PSHEAR, PLPLANE, PPLANE, PGPLSN
5959
from pyNastran.bdf.cards.elements.bush import CBUSH, CBUSH1D, CBUSH2D
6060
from pyNastran.bdf.cards.properties.bush import (
6161
PBUSH, PBUSH1D, PBUSHT, PBUSH2D, PBUSH_OPTISTRUCT)
@@ -338,6 +338,8 @@
338338
'CPLSTS8': CPLSTS8,
339339
'PPLANE': PPLANE,
340340

341+
'PGPLSN': PGPLSN,
342+
341343
'CSHEAR': CSHEAR,
342344
'PSHEAR': PSHEAR,
343345

@@ -3804,10 +3806,10 @@ def add_mathp(self, mid: int,
38043806
return mat
38053807

38063808
def add_mats1(self, mid: int, nl_type: str,
3807-
h, hr, yf, limit1, limit2,
3809+
h, hr, yf, limit1, limit2, strmeas: str | None=None,
38083810
tid: int=0, comment: str='') -> MATS1:
38093811
"""Creates a MATS1 card"""
3810-
mat = MATS1(mid, nl_type, h, hr, yf, limit1, limit2,
3812+
mat = MATS1(mid, nl_type, h, hr, yf, limit1, limit2, strmeas,
38113813
tid=tid, comment=comment)
38123814
self._add_methods.add_material_dependence_object(mat)
38133815
return mat
@@ -7193,6 +7195,14 @@ def add_pplane(self, pid: int, mid: int, t: float=0.0, nsm: float=0.0,
71937195
self._add_methods.add_property_object(prop)
71947196
return prop
71957197

7198+
def add_pgplsn(self, pid: int, mid: int, cgid: int, t: float,
7199+
kn: float | int=0., kr1: float | int=0., kr2: float | int=0.,
7200+
comment: str='') -> PGPLSN:
7201+
"""Creates a PGPLSN card"""
7202+
prop = PGPLSN(pid, mid, cgid=cgid, t=t, kn=kn, kr1=kr1, kr2=kr2, comment=comment)
7203+
self._add_methods.add_property_object(prop)
7204+
return prop
7205+
71967206
def add_cplstn3(self, eid, pid, nids, theta=0.0, comment='') -> CPLSTN3:
71977207
"""Creates a CPLSTN4 card"""
71987208
elem = CPLSTN3(eid, pid, nids, theta=theta, comment=comment)

pyNastran/bdf/bdf_interface/add_methods.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,13 @@ def add_coord_object(self, coord: Coord, # CORD3G
906906
if key not in model.coords:
907907
model.coords[key] = coord
908908
model._type_to_id_map[coord.type].append(key)
909-
elif coord == model.coords[key]:
910-
model.log.warning(f'replacing equivalent coord:\n{coord}')
909+
return
910+
911+
tag = _get_tag(model, coord, model.coords[key])
912+
if coord == model.coords[key]:
913+
model.log.warning(f'replacing equivalent coord {key}:{tag}\n{coord}')
911914
elif allow_overwrites:
912-
model.log.warning(f'replacing coord:\n{model.coords[key]}with:\n{coord}')
915+
model.log.warning(f'replacing coord{key}:{tag}\n{model.coords[key]}with:\n{coord}')
913916
model.coords[key] = coord
914917
# already handled
915918
#model._type_to_id_map[prop.type].append(key)
@@ -1863,15 +1866,18 @@ def add_object_to_dict(model: BDF, key: int,
18631866
if key not in obj_dict:
18641867
obj_dict[key] = obj
18651868
model._type_to_id_map[obj.type].append(key)
1866-
elif obj == obj_dict[key]:
1867-
model.log.warning(f'replacing equivalent {obj_name}:\n{obj}')
1869+
return
1870+
1871+
tag = _get_tag(model, obj, obj_dict[key])
1872+
if obj == obj_dict[key]:
1873+
model.log.warning(f'replacing equivalent {obj_name} {key}:{tag}\n{obj}')
18681874
elif allow_overwrites:
1869-
model.log.warning(f'replacing {obj_name}:\n{obj_dict[key]}with:\n{obj}')
1875+
model.log.warning(f'replacing {obj_name} {key}:{tag}\n{obj_dict[key]}with:\n{obj}')
18701876
obj_dict[key] = obj
18711877
# already handled
18721878
#model._type_to_id_map[prop.type].append(key)
18731879
else:
1874-
model.log.error(f'duplicate {obj_name} {key}:\n{obj_dict[key]}with:\n{obj}')
1880+
model.log.error(f'duplicate {obj_name} {key}:{tag}\n{obj_dict[key]}with:\n{obj}')
18751881
# duplicate_list.append(obj)
18761882
# if model._stop_on_duplicate_error:
18771883
# model.pop_parse_errors()
@@ -1919,16 +1925,35 @@ def add_object_to_dict_no_dupes(model: BDF, key: int, obj_name: str,
19191925
if key not in obj_dict:
19201926
obj_dict[key] = obj
19211927
model._type_to_id_map[obj.type].append(key)
1922-
elif obj == obj_dict[key]:
1923-
model.log.warning(f'replacing equivalent {obj_name}:\n{obj}')
1928+
return
1929+
1930+
tag = _get_tag(model, obj, obj_dict[key])
1931+
if obj == obj_dict[key]:
1932+
model.log.warning(f'replacing equivalent {obj_name} {key}:{tag}\n{obj}')
19241933
elif allow_overwrites:
1925-
model.log.warning(f'replacing {obj_name}:\n{obj_dict[key]}with:\n{obj}')
1934+
model.log.warning(f'replacing {obj_name} {key}:{tag}\n{obj_dict[key]}\nwith:\n{obj}')
19261935
obj_dict[key] = obj
19271936
# already handled
19281937
#model._type_to_id_map[prop.type].append(key)
19291938
else:
1930-
model.log.error(f'duplicate {obj_name} {key}:\n{obj_dict[key]}with:\n{obj}')
1939+
model.log.error(f'duplicate {obj_name} {key}:{tag}\n{obj_dict[key]}\n{obj}')
19311940
duplicate_list.append(obj)
19321941
if model._stop_on_duplicate_error:
19331942
model.pop_parse_errors()
19341943
#raise RuntimeError('pid=%s\nold_prop=\n%snew_prop=\n%s' % (prop.pid, model.properties[key], prop))
1944+
1945+
1946+
def _get_tag(model: BDF, obj1: BaseCard, obj2: BaseCard) -> str:
1947+
"""get a list of files where things are duplicated"""
1948+
if not model.save_file_structure:
1949+
return ''
1950+
ifile1 = obj1.ifile
1951+
ifile2 = obj2.ifile
1952+
filename1 = model.active_filenames[ifile1]
1953+
filename2 = model.active_filenames[ifile2]
1954+
tag = (
1955+
f'\n'
1956+
f'file1: {filename1}\n'
1957+
f'file2: {filename2}'
1958+
)
1959+
return tag

pyNastran/bdf/bdf_interface/attributes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
'PBEAM3',
200200

201201
# 2d
202-
'PLPLANE', 'PPLANE',
202+
'PLPLANE', 'PPLANE', 'PGPLSN',
203203
'PSHELL', 'PCOMP', 'PCOMPG', 'PSHEAR',
204204
'PSOLID', 'PLSOLID', 'PVISC', 'PRAC2D', 'PRAC3D',
205205
'PCOMPS', 'PCOMPLS',
@@ -333,8 +333,8 @@
333333
'dphases': ['DPHASE'],
334334
'nlparms': ['NLPARM'],
335335
'nlpcis': ['NLPCI'],
336-
'tsteps': ['TSTEP'],
337-
'tstepnls': ['TSTEPNL', 'TSTEP1'],
336+
'tsteps': ['TSTEP', 'TSTEP1'],
337+
'tstepnls': ['TSTEPNL'],
338338
'transfer_functions': ['TF'],
339339
'delays': ['DELAY'],
340340
'rotors': ['ROTORG', 'ROTORD'],
@@ -1208,12 +1208,12 @@ def type_slot_str(self) -> str:
12081208

12091209
html_msg.append(dash_plus)
12101210

1211-
#for card_group, card_types in sorted(self._slot_to_type_map.items()):
1212-
#html_msg.append('| %s | %s |' % (card_group, ', '.join(card_types)))
1213-
1214-
#html_msg.append(
1215-
#fmt_plus % ('-'*(nchars + 2), '-'*(nline + 2))
1216-
#)
1211+
# for card_group, card_types in sorted(self._slot_to_type_map.items()):
1212+
# html_msg.append('| %s | %s |' % (card_group, ', '.join(card_types)))
1213+
#
1214+
# html_msg.append(
1215+
# fmt_plus % ('-'*(nchars + 2), '-'*(nline + 2))
1216+
# )
12171217
msg = ''.join(html_msg)
12181218
return msg
12191219

pyNastran/bdf/cards/aero/static_loads.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
string_or_blank,
2424
)
2525
if TYPE_CHECKING: # pragma: no cover
26-
from pyNastran.bdf.bdf import BDF
26+
from pyNastran.bdf.bdf import BDF, SUPORT, SUPORT1, AESURF, AEPARM, AELINK
2727
from pyNastran.bdf.bdf_interface.bdf_card import BDFCard
2828

2929

@@ -656,7 +656,7 @@ class TRIM(BaseCard):
656656
1: 'sid', 2: 'mach', 3: 'q', 8: 'aeqr',
657657
}
658658

659-
def _get_field_helper(self, n):
659+
def _get_field_helper(self, n: int):
660660
"""
661661
Gets complicated parameters on the TRIM card
662662
@@ -781,9 +781,13 @@ def validate(self):
781781
len(self.labels), len(self.uxs), str(self.labels), str(self.uxs))
782782
raise RuntimeError(msg)
783783

784-
def verify_trim(self, suport, suport1,
785-
aestats, aeparms, aelinks,
786-
aesurf, xref=True):
784+
def verify_trim(self,
785+
suport: list[SUPORT],
786+
suport1: SUPORT1,
787+
aestats: dict[int, AESTAT],
788+
aeparms: dict[str, AEPARM],
789+
aelinks: dict[int, AELINK],
790+
aesurf: dict[str, AESURF], xref=True):
787791
"""
788792
Magic function that makes TRIM cards not frustrating.
789793
@@ -938,39 +942,39 @@ def verify_trim(self, suport, suport1,
938942
raise RuntimeError(msg)
939943

940944
# TODO: this doesn't work for multiple subcases
941-
#ntotal_suport_dofs = nsuport_dofs, nsuport1_dofs
942-
#ndelta = ntrim - nsuport_dofs - nsuport1_dofs - naesurf
943-
#if ndelta != 0:
944-
#msg = 'ntrim - nsuport_dofs - nsuport1_dofs - naesurf = ndelta = %s; ndelta != 0\n' % ndelta
945-
#msg += 'ntrim=%s nsuport_dofs=%s nsuport1_dofs=%s naesurfs=%s' % (
946-
#ntrim, nsuport_dofs, nsuport1_dofs, naesurf)
947-
#raise RuntimeError(msg)
948-
949-
#ndelta = (naestat + naesurf + naeparm + ntrim_aesurf) - (ntrim + naelink + nsuport_dofs + nsuport1_dofs)
950-
#if ndelta != 0:
951-
#msg = (
952-
#'(naestat + naesurf + naeparm + ntrim_aesurf) - '
953-
#'(ntrim + naelink + nsuport_dofs + nsuport1_dofs) = ndelta = %s; ndelta != 0\n'
954-
#'naestat=%s naesurf=%s naeparm=%s ntrim_aesurfs=%s\n'
955-
#'ntrim=%s naelink=%s nsuport_dofs=%s nsuport1_dofs=%s' % (
956-
#ndelta,
957-
#naestat, naesurf, naeparms, ntrim_aesurf,
958-
#ntrim, naelink, nsuport_dofs, nsuport1_dofs))
945+
# ntotal_suport_dofs = nsuport_dofs, nsuport1_dofs
946+
# ndelta = ntrim - nsuport_dofs - nsuport1_dofs - naesurf
947+
# if ndelta != 0:
948+
# msg = 'ntrim - nsuport_dofs - nsuport1_dofs - naesurf = ndelta = %s; ndelta != 0\n' % ndelta
949+
# msg += 'ntrim=%s nsuport_dofs=%s nsuport1_dofs=%s naesurfs=%s' % (
950+
# ntrim, nsuport_dofs, nsuport1_dofs, naesurf)
951+
# raise RuntimeError(msg)
952+
#
953+
# ndelta = (naestat + naesurf + naeparm + ntrim_aesurf) - (ntrim + naelink + nsuport_dofs + nsuport1_dofs)
954+
# if ndelta != 0:
955+
# msg = (
956+
# '(naestat + naesurf + naeparm + ntrim_aesurf) - '
957+
# '(ntrim + naelink + nsuport_dofs + nsuport1_dofs) = ndelta = %s; ndelta != 0\n'
958+
# 'naestat=%s naesurf=%s naeparm=%s ntrim_aesurfs=%s\n'
959+
# 'ntrim=%s naelink=%s nsuport_dofs=%s nsuport1_dofs=%s' % (
960+
# ndelta,
961+
# naestat, naesurf, naeparms, ntrim_aesurf,
962+
# ntrim, naelink, nsuport_dofs, nsuport1_dofs))
959963

960964
nplus = (naestat + naesurf + naeparm)
961965
nminus = ntrim + naelink + nsuport_dofs + nsuport1_dofs
962966

963967
ndelta = nplus - nminus + 0*2*ntrim_aesurfs
964968
if ndelta != 0:
965-
#msg = (
966-
#'(naestat + naesurf + naeparm) - (ntrim + ntrim_aesurf? + naelink + '
967-
#'nsuport_dofs + nsuport1_dofs) = ndelta = %s; ndelta != 0\n'
968-
#'naestat=%s naesurf=%s naeparm=%s ntrim=%s ntrim_aesurf=%s '
969-
#'naelink=%s nsuport_dofs=%s nsuport1_dofs=%s\n' % (
970-
#ndelta,
971-
#naestat, naesurf, naeparm, ntrim, ntrim_aesurf,
972-
#naelink, nsuport_dofs, nsuport1_dofs)
973-
#)
969+
# msg = (
970+
# '(naestat + naesurf + naeparm) - (ntrim + ntrim_aesurf? + naelink + '
971+
# 'nsuport_dofs + nsuport1_dofs) = ndelta = %s; ndelta != 0\n'
972+
# 'naestat=%s naesurf=%s naeparm=%s ntrim=%s ntrim_aesurf=%s '
973+
# 'naelink=%s nsuport_dofs=%s nsuport1_dofs=%s\n' % (
974+
# ndelta,
975+
# naestat, naesurf, naeparm, ntrim, ntrim_aesurf,
976+
# naelink, nsuport_dofs, nsuport1_dofs)
977+
# )
974978
msg = (
975979
'Invalid trim state (ndelta != 0):\n'
976980
f' (naestat + naesurf + naeparm + 0*2*ntrim_aesurf?) = ({naestat} + {naesurf} + {naeparm} + 0*2*{ntrim_aesurf}) = {nplus}\n'

0 commit comments

Comments
 (0)