diff --git a/pyNastran/dev/bdf_vectorized3/bdf.py b/pyNastran/dev/bdf_vectorized3/bdf.py index eacd077b3..5089a1501 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf.py +++ b/pyNastran/dev/bdf_vectorized3/bdf.py @@ -136,8 +136,10 @@ from pyNastran.bdf.cards.dmig import DMIG, DMI, DMIJ, DMIK, DMIJI, DMIG_UACCEL, DTI, DTI_UNITS, DMIAX #from .bdf.cards.elements.thermal import BDYOR #from .cards.thermal.loads import (TEMPB3, TEMPRB) -#from .cards.thermal.thermal import (CHBDYE, CHBDYG, CHBDYP, PCONV, PCONVM, - #PHBDY, CONV, CONVM, TEMPBC) +from pyNastran.dev.bdf_vectorized3.cards.elements.thermal import ( + CHBDYE, CHBDYG, CHBDYP, PCONV, PCONVM, + PHBDY, CONV, CONVM, # TEMPBC, +) #from .cards.thermal.radiation import RADM, RADBC, RADCAV, RADLST, RADMTX, VIEW, VIEW3D from pyNastran.bdf.cards.bdf_tables import ( TABLED1, TABLED2, TABLED3, TABLED4, @@ -751,9 +753,9 @@ def __init__(self, debug: Union[str, bool, None]=True, # temperature cards 'TEMP', 'TEMPD', # 'TEMPB3', 'TEMPAX', 'QBDY1', 'QBDY2', 'QBDY3', 'QHBDY', - #'CHBDYE', 'CHBDYG', 'CHBDYP', 'BDYOR', - #'PCONV', 'PCONVM', 'PHBDY', - 'RADBC', # 'CONV', + 'CHBDYE', 'CHBDYG', 'CHBDYP', 'BDYOR', + 'PCONV', 'PCONVM', 'PHBDY', + 'RADBC', 'CONV', 'RADM', # 'VIEW', 'VIEW3D', # TODO: not validated #'RADCAV', ## radcavs @@ -912,7 +914,7 @@ def __init__(self, debug: Union[str, bool, None]=True, #'RADLST', 'RADMTX', #'RADBND', #'TEMPP1', #'TEMPRB', - #'CONVM', + 'CONVM', ## ??? #'PANEL', 'SWLDPRM', #'CWELD', 'PWELD', @@ -2496,17 +2498,17 @@ def add_card(cls, card, comment=''): #'PACBAR': (PACBAR, add_methods._add_acoustic_property_object), # thermal elements - #'CHBDYE': partial(self._prepare_card, self.chbdye), - #'CHBDYG': partial(self._prepare_card, self.chbdyg), - #'CHBDYP': partial(self._prepare_card, self.chbdyp), - #'PHBDY': partial(self._prepare_card, self.phbdy), + 'CHBDYE': partial(self._prepare_card, self.chbdye), + 'CHBDYG': partial(self._prepare_card, self.chbdyg), + 'CHBDYP': partial(self._prepare_card, self.chbdyp), + 'PHBDY': partial(self._prepare_card, self.phbdy), #'TEMPRB' : (TEMPRB, add_methods._add_thermal_load_object), #'TEMPB3' : (TEMPB3, add_methods._add_thermal_load_object), - #'CONV': partial(self._prepare_card, self.conv), - #'PCONV': partial(self._prepare_card, self.pconv), - #'CONVM': partial(self._prepare_card, self.convm), - #'PCONVM': partial(self._prepare_card, self.pconvm), + 'CONV': partial(self._prepare_card, self.conv), + 'PCONV': partial(self._prepare_card, self.pconv), + 'CONVM': partial(self._prepare_card, self.convm), + 'PCONVM': partial(self._prepare_card, self.pconvm), # static loads 'LOAD' : partial(self._prepare_card, self.load), diff --git a/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py b/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py index e1d32a604..fc327451d 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py +++ b/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py @@ -5172,7 +5172,7 @@ def add_view3d(self, icavity, gitb=4, gips=4, cier=4, error_tol=0.1, def add_pconv(self, pconid, mid=None, form=0, expf=0.0, ftype=0, tid=None, chlen=None, gidin=None, ce=0, e1=None, e2=None, e3=None, - comment: str='') -> PCONV: + comment: str='') -> int: """ Creates a PCONV card @@ -5207,15 +5207,15 @@ def add_pconv(self, pconid, mid=None, form=0, expf=0.0, ftype=0, tid=None, a comment for the card """ - prop = PCONV(pconid, mid=mid, - form=form, expf=expf, ftype=ftype, - tid=tid, chlen=chlen, gidin=gidin, - ce=ce, e1=e1, e2=e2, e3=e3, comment=comment) - self._add_methods._add_convection_property_object(prop) + prop = self.pconv.add( + pconid, mid=mid, + form=form, expf=expf, ftype=ftype, + tid=tid, chlen=chlen, gidin=gidin, + ce=ce, e1=e1, e2=e2, e3=e3, comment=comment) return prop def add_pconvm(self, pconid, mid, coef, form=0, flag=0, - expr=0.0, exppi=0.0, exppo=0.0, comment: str='') -> PCONVM: + expr=0.0, exppi=0.0, exppo=0.0, comment: str='') -> int: """ Creates a PCONVM card @@ -5244,9 +5244,9 @@ def add_pconvm(self, pconid, mid, coef, form=0, flag=0, a comment for the card """ - prop = PCONVM(pconid, mid, coef, form=form, flag=flag, - expr=expr, exppi=exppi, exppo=exppo, comment=comment) - self._add_methods._add_convection_property_object(prop) + prop = self.pconvm.add( + pconid, mid, coef, form=form, flag=flag, + expr=expr, exppi=exppi, exppo=exppo, comment=comment) return prop def add_radset(self, cavity_ids: list[int], comment: str='') -> int: diff --git a/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py b/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py index b099e80a2..bf872a689 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py +++ b/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py @@ -55,7 +55,7 @@ from pyNastran.dev.bdf_vectorized3.cards.elements.mass import CONM1, CONM2 from pyNastran.dev.bdf_vectorized3.cards.elements.cmass import PMASS, CMASS1, CMASS2, CMASS3, CMASS4 from pyNastran.dev.bdf_vectorized3.cards.elements.nsm import NSMADD, NSM, NSM1, NSML, NSML1 -#from pyNastran.dev.bdf_vectorized3.cards.elements.thermal import CHBDYE, CHBDYP, CHBDYG, CONV, PCONV, CONVM, PCONVM, PHBDY +from pyNastran.dev.bdf_vectorized3.cards.elements.thermal import CHBDYE, CHBDYP, CHBDYG, CONV, PCONV, CONVM, PCONVM, PHBDY from pyNastran.dev.bdf_vectorized3.cards.elements.plot import PLOTEL, PLOTEL3, PLOTEL4, PLOTEL6, PLOTEL8 from pyNastran.dev.bdf_vectorized3.cards.loads.static_loads import ( @@ -439,20 +439,20 @@ def __init__(self): self.nsml1 = NSML1(self) # thermal - #self.bdyor = None - #self.chbdye = CHBDYE(self) - #self.chbdyp = CHBDYP(self) - #self.chbdyg = CHBDYG(self) - #self.phbdy = PHBDY(self) + self.bdyor = None + self.chbdye = CHBDYE(self) + self.chbdyp = CHBDYP(self) + self.chbdyg = CHBDYG(self) + self.phbdy = PHBDY(self) #self.chacab = CHACAB(self) #self.chacbr = CHACBR(self) # thermal boundary conditions - #self.conv = CONV(self) - #self.pconv = PCONV(self) - #self.convm = CONVM(self) - #self.pconvm = PCONVM(self) + self.conv = CONV(self) + self.pconv = PCONV(self) + self.convm = CONVM(self) + self.pconvm = PCONVM(self) # loads self.load = LOAD(self) @@ -925,16 +925,16 @@ def nonstructural_mass_cards(self) -> list[Any]: @property def thermal_element_cards(self) -> list[Any]: thermal_elements = [ - #self.chbdye, self.chbdyg, self.chbdyp, self.phbdy, + self.chbdye, self.chbdyg, self.chbdyp, self.phbdy, ] return thermal_elements @property def thermal_boundary_condition_cards(self) -> list[Any]: boundary_conditions = [ - #self.conv, self.pconv, - #self.convm, self.pconvm, - #self.tempbc, + self.conv, self.pconv, + self.convm, self.pconvm, + self.tempbc, self.radbc, self.radm, self.radset, ] return boundary_conditions @@ -1647,7 +1647,7 @@ def quality(self, cards_to_read: Optional[Set[str]]=None): cards_to_read : set[str] cards that won't be included in element_ids """ - assert len(self.grid), 'No grids' + #assert len(self.grid), 'No grids' # list of elements that have no quality results NO_QUALITY = { 'CELAS1', 'CELAS2', 'CELAS3', 'CELAS4', diff --git a/pyNastran/dev/bdf_vectorized3/bdf_interface/write_mesh.py b/pyNastran/dev/bdf_vectorized3/bdf_interface/write_mesh.py index 8dec4d155..8432cba2e 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf_interface/write_mesh.py +++ b/pyNastran/dev/bdf_vectorized3/bdf_interface/write_mesh.py @@ -772,22 +772,22 @@ def _write_thermal(self, bdf_file: TextIOLike, size: int=8, is_double: bool=Fals is_thermal = any([card.n > 0 for card in model.thermal_element_cards]) if is_thermal: bdf_file.write('$THERMAL_ELEMENTS\n') - bdf_file.write(model.chbdye.write(size=size)) - bdf_file.write(model.chbdyp.write(size=size)) - bdf_file.write(model.chbdyg.write(size=size)) - bdf_file.write(model.phbdy.write(size=size)) + model.chbdye.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.chbdyp.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.chbdyg.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.phbdy.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) is_thermal = any([card.n > 0 for card in model.thermal_boundary_condition_cards]) - if is_thermal and 0: - bdf_file.write(model.conv.write(size=size)) - bdf_file.write(model.pconv.write(size=size)) - bdf_file.write(model.convm.write(size=size)) - bdf_file.write(model.pconvm.write(size=size)) + if is_thermal: + model.conv.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.pconv.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.convm.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.pconvm.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) - bdf_file.write(model.tempbc.write(size=size)) - bdf_file.write(model.radbc.write(size=size)) - bdf_file.write(model.radm.write(size=size)) - bdf_file.write(model.radset.write(size=size)) + model.radbc.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.radm.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.radset.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.tempbc.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) def _write_thermal_materials(self, bdf_file: TextIOLike, size: int=8, is_double: bool=False, @@ -829,12 +829,12 @@ def _write_aero_control(self, bdf_file: TextIOLike, #for (unused_id, aecomp) in sorted(model.aecomps.items()): #bdf_file.write(aecomp.write_card(size, is_double)) - bdf_file.write(model.aeparm.write(size, is_double)) - bdf_file.write(model.aestat.write(size, is_double)) - bdf_file.write(model.aesurf.write(size, is_double)) - bdf_file.write(model.aesurfs.write(size, is_double)) - bdf_file.write(model.aefact.write(size=size)) - bdf_file.write(model.aelink.write(size=size)) + model.aeparm.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.aestat.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.aesurf.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.aesurfs.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.aefact.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) + model.aelink.write_file(bdf_file, size=size, is_double=is_double, write_card_header=False) def _write_static_aero(self, bdf_file: TextIOLike, size: int=8, is_double: bool=False, diff --git a/pyNastran/dev/bdf_vectorized3/cards/elements/shell.py b/pyNastran/dev/bdf_vectorized3/cards/elements/shell.py index a70330bcb..4a3653949 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/elements/shell.py +++ b/pyNastran/dev/bdf_vectorized3/cards/elements/shell.py @@ -669,21 +669,28 @@ def write_file_8(self, bdf_file: TextIOLike, element_id = array_str(self.element_id, size=size) property_id = array_str(self.property_id, size=size) nodes_ = array_str(self.nodes, size=size) - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip_longest(element_id, property_id, nodes_, self.theta, - self.mcid, self.zoffset, self.tflag, self.T): + zoffsets = array_default_float(self.zoffset, default=0., size=size, is_double=False) + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size, is_double=False) + + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip_longest(element_id, property_id, nodes_, theta_mcids, + zoffsets, self.tflag, self.T): row1 = [eid, pid] + nodes.tolist() T1, T2, T3 = T - if np.isnan(theta): - theta_mcid = '%8d' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8d' % mcid + #else: + #theta_mcid = print_field_8(theta) row2_data0 = [theta_mcid, zoffset, # actually part of line 1 tflag, T1, T2, T3] - if row2_data0 == [0.0, 0.0, 0, 1.0, 1.0, 1.0]: + if row2_data0 == ['', '', + 0, 1.0, 1.0, 1.0]: msg = 'CTRIA3 %8s%8s%8s%8s%8s\n' % tuple(row1) else: - zoffset = set_blank_if_default(zoffset, 0.0) + #zoffset = set_blank_if_default(zoffset, 0.0) tflag = set_blank_if_default(tflag, 0) #theta_mcid = self._get_theta_mcid_repr() @@ -702,40 +709,42 @@ def write_file_8(self, bdf_file: TextIOLike, def write_file_16(self, bdf_file: TextIOLike, is_double: bool=False, write_card_header: bool=False) -> None: - size = 16 + size = 8 + blank_str = ' ' * 16 + #from pyNastran.bdf.field_writer import print_card_8 element_id = array_str(self.element_id, size=size) property_id = array_str(self.property_id, size=size) nodes_ = array_str(self.nodes, size=size) + tflags = array_default_int(self.tflag, default=0, size=size) + zoffsets = array_default_float(self.zoffset, default=0.0, size=size, is_double=False) + Ts = array_default_float(self.T, default=1.0, size=size, is_double=False) + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, size=size, is_double=False) + headers = self.card_headers(size=size) if write_card_header: bdf_file.write(print_card_16_comment(headers)) - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip_longest( - element_id, property_id, nodes_, self.theta, - self.mcid, self.zoffset, self.tflag, self.T): + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip_longest( + element_id, property_id, nodes_, theta_mcids, zoffsets, tflags, Ts): row1 = [eid, pid] + nodes.tolist() T1, T2, T3 = T - if np.isnan(theta): - theta_mcid = '%8d' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8d' % mcid + #else: + #theta_mcid = print_field_8(theta) row2_data0 = [theta_mcid, zoffset, # actually part of line 1 tflag, T1, T2, T3] - if row2_data0 == [0.0, 0.0, 0, 1.0, 1.0, 1.0]: + #if row2_data0 == [0.0, 0.0, 0, 1.0, 1.0, 1.0]: + if row2_data0 == ['', '', '', blank_str, blank_str, blank_str]: msg = ( 'CTRIA3* %16s%16s%16s%16s\n' '* %16s\n') % tuple(row1) else: - zoffset = set_blank_if_default(zoffset, 0.0) - tflag = set_blank_if_default(tflag, 0) - #theta_mcid = self._get_theta_mcid_repr() - - T1 = set_blank_if_default(T1, 1.0) - T2 = set_blank_if_default(T2, 1.0) - T3 = set_blank_if_default(T3, 1.0) - - row2_data = [theta_mcid, zoffset, tflag, T1, T2, T3] + row2_data = [theta_mcid, zoffset, '', + '', tflag, T1, T2, T3] list_fields = ['CTRIA3'] + row1 + row2_data msg = print_card_16(list_fields) bdf_file.write(msg) @@ -992,17 +1001,22 @@ def write_file(self, bdf_file: TextIOLike, element_ids = array_str(self.element_id, size=size) property_ids = array_str(self.property_id, size=size) nodes = array_str(self.nodes, size=size) - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip_longest( - element_ids, property_ids, nodes, self.theta, - self.mcid, self.zoffset, self.tflag, self.T): + + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size) + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip_longest( + element_ids, property_ids, nodes, theta_mcids, + self.zoffset, self.tflag, self.T): if np.all(np.isnan(T)): T1 = T2 = T3 = None else: T1, T2, T3 = T - if np.isnan(theta): - theta_mcid = '%8d' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8d' % mcid + #else: + #theta_mcid = print_field_8(theta) #+--------+-------+-------+----+----+----+------------+---------+ #| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | @@ -1145,6 +1159,7 @@ def parse_cards(self) -> None: element_id[icard] = eid property_id[icard] = pid nodes[icard, :] = nids + #assert zoffseti is not None, zoffseti zoffset[icard] = zoffseti tflag[icard] = tflagi if isinstance(theta_mcid, float): @@ -1206,13 +1221,11 @@ def _setup_write(self, size: int=8) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.all(np.isnan(self.T)) ) - # turns mcids into theta_mcids - mcids = array_default_int(self.mcid, default=-1, size=size) - thetas = array_default_float(self.theta, default=0.0, size=size) + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size, is_double=False) no_zoffset = np.all(np.isnan(self.zoffset)) - itheta = (mcids == '') - mcids[itheta] = thetas[itheta] - theta_mcids = mcids no_theta_mcid = np.all(theta_mcids == '') #CQUAD4 307517 105 247597 262585 262586 247591 -1 0.0 @@ -1296,45 +1309,45 @@ def write_file_16(self, bdf_file: TextIOLike, headers = self.card_headers(size=16) if write_card_header: bdf_file.write(print_card_16_comment(headers)) - element_id, property_id, remove_tflag, no_zoffset, mcids, no_mcid = self._setup_write(size=16) + (element_id, property_id, remove_tflag, + no_zoffset, theta_mcids, no_theta_mcid) = self._setup_write(size=16) if remove_tflag: - if no_zoffset and no_mcid: + if no_zoffset and no_theta_mcid: for eid, pid, nodes in zip_longest(element_id, property_id, self.nodes): data = ['CQUAD4', eid, pid] + nodes.tolist() bdf_file.write(print_card(data)) elif no_zoffset: - for eid, pid, nodes, theta, mcid in zip(element_id, property_id, self.nodes, self.theta, mcids): - data = ['CQUAD4', eid, pid, nodes[0], nodes[1], nodes[2], nodes[3], mcid] + for eid, pid, nodes, theta_mcid in zip(element_id, property_id, self.nodes, theta_mcids): + data = ['CQUAD4', eid, pid, nodes[0], nodes[1], nodes[2], nodes[3], theta_mcid] bdf_file.write(print_card(data)) - elif no_mcid: - for eid, pid, nodes, theta, zoffset in zip(element_id, property_id, self.nodes, self.theta, self.zoffset): + elif no_theta_mcid: + for eid, pid, nodes, zoffset in zip(element_id, property_id, self.nodes, self.zoffset): zoffset_str = '' if np.isnan(zoffset) else print_field_16(zoffset) data = ['CQUAD4', eid, pid, nodes[0], nodes[1], nodes[2], nodes[3], '', zoffset] bdf_file.write(print_card(data)) else: - for eid, pid, nodes, theta, mcid, zoffset in zip(element_id, property_id, self.nodes, self.theta, mcids, self.zoffset): + for eid, pid, nodes, theta_mcid, zoffset in zip(element_id, property_id, self.nodes, theta_mcids, self.zoffset): zoffset_str = '' if np.isnan(zoffset) else print_field_16(zoffset) data = ['CQUAD4', eid, pid, nodes[0], nodes[1], nodes[2], nodes[3], mcid, zoffset_str] bdf_file.write(print_card(data)) else: - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip(element_id, property_id, self.nodes, self.theta, - mcids, self.zoffset, self.tflag, self.T): + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip(element_id, property_id, self.nodes, theta_mcids, + self.zoffset, self.tflag, self.T): #zoffset = '' if np.isnan(zoffset) else zoffset T1, T2, T3, T4 = T - if np.isnan(theta): - theta_mcid = '%8s' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8s' % mcid + #else: + #theta_mcid = print_field_8(theta) row2_data = [theta_mcid, zoffset, # actually part of line 1 tflag, T1, T2, T3, T4] - if row2_data == [0.0, 0.0, 0, 1.0, 1.0, 1.0, 1.0]: + if row2_data == ['', 0.0, 0, 1.0, 1.0, 1.0, 1.0]: data = [eid, pid] + nodes.tolist() msg = ('CQUAD4* %16s%16s%16d%16d\n' '* %16d%16d\n' % tuple(data)) #return self.comment + msg else: - #theta_mcid = self._get_theta_mcid_repr() zoffset = set_blank_if_default(zoffset, 0.0) tflag = set_blank_if_default(tflag, 0) T1 = set_blank_if_default(T1, 1.0) @@ -1893,27 +1906,31 @@ def write_file(self, bdf_file: TextIOLike, #) element_ids = array_str(self.element_id, size=size) property_ids = array_str(self.property_id, size=size) - nodes_ = array_default_int(self.nodes, default=0, size=size) - mcids = array_default_int(self.mcid, default=-1, size=size) + nodes_ = array_default_int(self.nodes, default=0, size=size).tolist() + #mcids = array_default_int(self.mcid, default=-1, size=size) #no_zoffset = np.all(np.isnan(self.zoffset)) #no_mcid = np.all(mcids == '') - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip_longest( - element_ids, property_ids, nodes_, self.theta, - mcids, self.zoffset, self.tflag, self.T): + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size) + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip_longest( + element_ids, property_ids, nodes_, theta_mcids, + self.zoffset, self.tflag, self.T): zoffset = '' if np.isnan(zoffset) else zoffset T1, T2, T3 = T - if np.isnan(theta): - theta_mcid = '%8s' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8s' % mcid + #else: + #theta_mcid = print_field_8(theta) zoffset = set_blank_if_default(zoffset, 0.0) tflag = set_blank_if_default(tflag, 0) T1 = set_blank_if_default(T1, 1.0) T2 = set_blank_if_default(T2, 1.0) T3 = set_blank_if_default(T3, 1.0) - nodes2 = [None if node == 0 else node for node in nodes] - list_fields = (['CTRIA6', eid, pid] + nodes2 + + #nodes2 = [None if node == 0 else node for node in nodes] + list_fields = (['CTRIA6', eid, pid] + nodes + [theta_mcid, zoffset, T1, T2, T3, tflag]) bdf_file.write(print_card(list_fields)) return @@ -2231,15 +2248,19 @@ def write_file(self, bdf_file: TextIOLike, #no_zoffset = np.all(np.isnan(self.zoffset)) #no_mcid = np.all(mcids == '') #CQUAD4 307517 105 247597 262585 262586 247591 -1 0.0 - for eid, pid, nodes, theta, mcid, zoffset, tflag, T in zip_longest( - element_id, property_id, self.nodes, self.theta, - mcids, self.zoffset, self.tflag, self.T): + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size) + for eid, pid, nodes, theta_mcid, zoffset, tflag, T in zip_longest( + element_id, property_id, self.nodes, theta_mcids, + self.zoffset, self.tflag, self.T): zoffset = '' if np.isnan(zoffset) else zoffset T1, T2, T3, T4 = T - if np.isnan(theta): - theta_mcid = '%8s' % mcid - else: - theta_mcid = print_field_8(theta) + #if np.isnan(theta): + #theta_mcid = '%8s' % mcid + #else: + #theta_mcid = print_field_8(theta) zoffset = set_blank_if_default(zoffset, 0.0) tflag = set_blank_if_default(tflag, 0) @@ -2434,17 +2455,22 @@ def set_used(self, used_dict: dict[str, np.ndarray]) -> None: def write_file(self, bdf_file: TextIOLike, size: int=8, is_double: bool=False, write_card_header: bool=False) -> None: + print_card, size = get_print_card_size(size, self.max_id) element_ids = array_str(self.element_id, size=size) property_ids = array_str(self.property_id, size=size) nodes = array_default_int(self.nodes, default=0, size=size) mcids = array_default_int(self.mcid, default=-1, size=size) - for eid, pid, nodesi, theta, mcid in zip_longest(element_ids, property_ids, nodes, - self.theta, mcids): - if np.isnan(theta): - theta_mcid = '%8s' % mcid - else: - theta_mcid = print_field_8(theta) + theta_mcids = combine_int_float_array( + self.mcid, self.theta, + int_default=-1, float_default=0.0, + size=size) + for eid, pid, nodesi, theta_mcid in zip_longest(element_ids, property_ids, nodes, + theta_mcids): + #if np.isnan(theta): + #theta_mcid = '%8s' % mcid + #else: + #theta_mcid = print_field_8(theta) #nodes2 = ['' if node is None else '%8d' % node for node in nodes[4:]] #data = [eid, pid] + nodes[:4].tolist() + nodes2 + [theta_mcid] @@ -2680,3 +2706,15 @@ def _save_quad(element: CQUAD4 | CQUADR, element.tflag = tflag element.T = T element.n = nelements + +def combine_int_float_array(int_array, + float_array, + int_default: int, + float_default: float, + size: int=8, is_double: bool=False) -> np.ndarray: + mcids = array_default_int(int_array, default=-1, size=size) + thetas = array_default_float(float_array, default=0.0, size=size) + itheta = (mcids == '') + mcids[itheta] = thetas[itheta] + theta_mcids = mcids + return theta_mcids diff --git a/pyNastran/dev/bdf_vectorized3/cards/elements/shell_properties.py b/pyNastran/dev/bdf_vectorized3/cards/elements/shell_properties.py index d88bc1739..afe7430a8 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/elements/shell_properties.py +++ b/pyNastran/dev/bdf_vectorized3/cards/elements/shell_properties.py @@ -1594,9 +1594,10 @@ def add(self, pid: int, global_ply_ids: list[int], mids: list[int], thicknesses: list[float], thetas=None, souts=None, nsm: float=0.0, sb: float=0.0, ft: str='', - tref: float=0.0, ge: float=0.0, lam=None, z0=None, + tref: float=0.0, ge: float=0.0, lam: str='', z0=None, comment: str='') -> int: lam = lam if lam is not None else '' + ft = ft if ft is not None else '' z0 = z0 if z0 is not None else np.nan nlayers = len(thicknesses) @@ -1613,31 +1614,6 @@ def add(self, pid: int, self.n += 1 return self.n - 1 - def __apply_slice__(self, prop: PCOMPG, i: np.ndarray) -> None: # ignore[override] - prop.n = len(i) - prop.property_id = self.property_id[i] - prop.z0 = self.z0[i] - prop.nsm = self.nsm[i] - prop.shear_bonding = self.shear_bonding[i] - - # 'HILL' for the Hill theory. - # 'HOFF' for the Hoffman theory. - # 'TSAI' for the Tsai-Wu theory. - # 'STRN' for the Maximum Strain theory. - prop.failure_theory = self.failure_theory[i] - prop.tref = self.tref[i] - prop.ge = self.ge[i] - prop.lam = self.lam[i] - - ilayer = self.ilayer # [i, :] - prop.material_id = hslice_by_idim(i, ilayer, self.material_id) - prop.sout = hslice_by_idim(i, ilayer, self.sout) - prop.theta = hslice_by_idim(i, ilayer, self.theta) - prop.thickness = hslice_by_idim(i, ilayer, self.thickness) - prop.global_ply_id = hslice_by_idim(i, ilayer, self.global_ply_id) - prop.nlayer = self.nlayer[i] - - def add_card(self, card: BDFCard, comment: str='') -> int: pid = integer(card, 1, 'pid') # z0 will be calculated later @@ -1790,6 +1766,30 @@ def _save(self, property_id, nsm, shear_bonding, failure_theory, tref, ge, lam, self.sout = sout self.theta = theta + def __apply_slice__(self, prop: PCOMPG, i: np.ndarray) -> None: # ignore[override] + prop.n = len(i) + prop.property_id = self.property_id[i] + prop.z0 = self.z0[i] + prop.nsm = self.nsm[i] + prop.shear_bonding = self.shear_bonding[i] + + # 'HILL' for the Hill theory. + # 'HOFF' for the Hoffman theory. + # 'TSAI' for the Tsai-Wu theory. + # 'STRN' for the Maximum Strain theory. + prop.failure_theory = self.failure_theory[i] + prop.tref = self.tref[i] + prop.ge = self.ge[i] + prop.lam = self.lam[i] + + ilayer = self.ilayer # [i, :] + prop.material_id = hslice_by_idim(i, ilayer, self.material_id) + prop.sout = hslice_by_idim(i, ilayer, self.sout) + prop.theta = hslice_by_idim(i, ilayer, self.theta) + prop.thickness = hslice_by_idim(i, ilayer, self.thickness) + prop.global_ply_id = hslice_by_idim(i, ilayer, self.global_ply_id) + prop.nlayer = self.nlayer[i] + def set_used(self, used_dict: dict[str, np.ndarray]) -> None: used_dict['material_id'].append(self.material_id) diff --git a/pyNastran/dev/bdf_vectorized3/cards/loads/thermal_loads.py b/pyNastran/dev/bdf_vectorized3/cards/loads/thermal_loads.py index 525c1b511..b04a57908 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/loads/thermal_loads.py +++ b/pyNastran/dev/bdf_vectorized3/cards/loads/thermal_loads.py @@ -11,7 +11,9 @@ from pyNastran.bdf.bdf_interface.assign_type import ( integer, double, string, integer_or_blank, double_or_blank, string_or_blank, - integer_or_string, fields, integer_types, float_types) + integer_or_string, fields, + #integer_types, + float_types) from pyNastran.bdf.cards.utils import wipe_empty_fields from pyNastran.dev.bdf_vectorized3.bdf_interface.geom_check import geom_check diff --git a/pyNastran/dev/bdf_vectorized3/cards/monitor.py b/pyNastran/dev/bdf_vectorized3/cards/monitor.py index bb81a5201..0d5442882 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/monitor.py +++ b/pyNastran/dev/bdf_vectorized3/cards/monitor.py @@ -4,7 +4,7 @@ from typing import Optional, TYPE_CHECKING import numpy as np -#from pyNastran.utils.numpy_utils import integer_types, cast_ints +from pyNastran.utils.numpy_utils import integer_types # , cast_ints #from pyNastran.bdf.field_writer_8 import print_card_8, set_blank_if_default #from pyNastran.bdf.field_writer_16 import print_card_16 # , print_scientific_16, print_field_16 #from pyNastran.bdf.field_writer_double import print_scientific_double @@ -394,6 +394,8 @@ def add(self, name: str, label: str, axes: str, if cd is None: # ew can do this because this is MSC-specific cd = cp + elem_set = 0 if elem_set is None else elem_set + assert isinstance(elem_set, integer_types), elem_set self.cards.append((name, label, axes, grid_set, elem_set, xyz, cp, cd, xflag, comment)) self.n += 1 diff --git a/pyNastran/dev/bdf_vectorized3/cards/optimization.py b/pyNastran/dev/bdf_vectorized3/cards/optimization.py index 13906e6fe..4dd3b41c8 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/optimization.py +++ b/pyNastran/dev/bdf_vectorized3/cards/optimization.py @@ -1057,7 +1057,7 @@ def parse_cards(self) -> None: attb_type[icard] = 'f' attb_float[icard] = attbi - if response_typei == 'WEIGHT' and attii in ([], ['ALL']): + if response_typei in {'WEIGHT', 'VOLUME'} and attii in ([], ['ALL']): attii = [-1] natti = len(attii) @@ -1247,7 +1247,7 @@ def write_file(self, bdf_file: TextIOLike, size: int=8, if atti_type == 'i': atti_list = atti_ints[iatti0:iatti1].tolist() - if response_type == 'WEIGHT' and len(atti_list) == 1 and self.atti_int[iatti0] == -1: + if response_type in {'WEIGHT', 'VOLUME'} and len(atti_list) == 1 and self.atti_int[iatti0] == -1: atti_list = ['ALL'] elif atti_type == 'f': atti_list = atti_floats[iatti0:iatti1].tolist() diff --git a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_sets.py b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_sets.py index a94f987ce..8f0c14c3c 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_sets.py +++ b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_sets.py @@ -43,8 +43,10 @@ def test_monpnt(self): grid_set = 43 elem_set = 44 - model.add_monpnt3(name, label, axes, grid_set, elem_set, - xyz, cp=0, cd=None, + model.add_monpnt3(name, label, axes, grid_set, + xyz, + elem_set=elem_set, + cp=0, cd=None, xflag=None, comment='monpnt3') #monpnt3.raw_fields() monpnt3.validate() @@ -533,6 +535,7 @@ def test_secset(self): nids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] for nid in nids: model.add_grid(nid, [float(nid), 0., 0.]) + model.setup() secset.validate() secset.write() save_load_deck(model) @@ -561,6 +564,7 @@ def test_seqset(self): nids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] for nid in nids: model.add_grid(nid, [float(nid), 0., 0.]) + model.setup() seqset.validate() seqset.write() save_load_deck(model) diff --git a/pyNastran/dev/bdf_vectorized3/mesh_utils/bdf_equivalence.py b/pyNastran/dev/bdf_vectorized3/mesh_utils/bdf_equivalence.py index cb02016f9..377f48c6d 100644 --- a/pyNastran/dev/bdf_vectorized3/mesh_utils/bdf_equivalence.py +++ b/pyNastran/dev/bdf_vectorized3/mesh_utils/bdf_equivalence.py @@ -386,6 +386,8 @@ def update_cards(model: BDF, # time/freq/random loads 'TLOAD1', 'TLOAD2', 'RLOAD1', 'RLOAD2', 'RANDPS', 'ACSRCE', 'DLOAD', 'LSEQ', + # not supported + 'SEBSET', 'SECSET', 'SEQSET', } | no_equiv_cards grid = model.grid ids = np.unique(grid.node_id) diff --git a/pyNastran/dev/bdf_vectorized3/mesh_utils/forces_moments.py b/pyNastran/dev/bdf_vectorized3/mesh_utils/forces_moments.py index 845204d4b..20131dee7 100644 --- a/pyNastran/dev/bdf_vectorized3/mesh_utils/forces_moments.py +++ b/pyNastran/dev/bdf_vectorized3/mesh_utils/forces_moments.py @@ -37,5 +37,7 @@ def get_temperatures_array(model: BDF, loadcase_id: int, if len(uspoint_id): ispoint = np.searchsorted(spoint_id, uspoint_id) itemp = np.searchsorted(temp.node_id, uspoint_id) - spoint_temps[ispoint] = temp.temperature[itemp] + temperaturei = temp.temperature[itemp] + assert len(ispoint) == len(itemp) + spoint_temps[ispoint] = temperaturei return temperature diff --git a/pyNastran/dev/bdf_vectorized3/test/test_bdf.py b/pyNastran/dev/bdf_vectorized3/test/test_bdf.py index 0caad82d4..be5c3945f 100644 --- a/pyNastran/dev/bdf_vectorized3/test/test_bdf.py +++ b/pyNastran/dev/bdf_vectorized3/test/test_bdf.py @@ -1177,7 +1177,7 @@ def run_fem1(fem1: BDFs, bdf_model: str, out_model: str, raise DisabledCardError(f'card={card!r} has been disabled') #fem1.geom_check(geom_check=True, xref=False) - if run_mass and not is_nominal: + if run_mass and not is_nominal and len(fem1.grid): fem1.length() fem1.area() fem1.volume()