Skip to content

Commit

Permalink
bdf_vectorized3:
Browse files Browse the repository at this point in the history
 - fixing overflow test
 - adding RBAR1
  • Loading branch information
SteveDoyle2 committed Oct 6, 2023
1 parent ef33236 commit 3a5eccf
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pyNastran/dev/bdf_vectorized3/bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def __init__(self, debug: Union[str, bool, None]=True,
#'CTRSHL', 'CQUAD1',

## rigid_elements
'RBAR', #'RBAR1',
'RBAR', 'RBAR1',
'RBE1', 'RBE2', 'RBE3', 'RROD', # 'RSPLINE', 'RSSCON',

## plotels
Expand Down Expand Up @@ -2608,7 +2608,7 @@ def add_card(cls, card, comment=''):

# rigid elements
'RBAR': partial(self._prepare_card, self.rbar),
#'RBAR1': partial(self._prepare_card, self.rbar1), # not supported
'RBAR1': partial(self._prepare_card, self.rbar1),
'RBE1': partial(self._prepare_card, self.rbe1),
'RBE2': partial(self._prepare_card, self.rbe2),
'RBE3': partial(self._prepare_card, self.rbe3),
Expand Down
7 changes: 3 additions & 4 deletions pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@
from pyNastran.dev.bdf_vectorized3.cards.coord import COORD
from pyNastran.dev.bdf_vectorized3.cards.constraints import SPC, SPC1, SPCADD, MPC, MPCADD
from pyNastran.dev.bdf_vectorized3.cards.elements.rigid import (
RBAR,
#RBAR1,
RBAR, RBAR1,
RROD,
RBE1, RBE2, RBE3,
#RSSCON,
Expand Down Expand Up @@ -457,7 +456,7 @@ def __init__(self):

# rigid elements
self.rbar = RBAR(self)
#self.rbar1 = RBAR1(self) # not supported
self.rbar1 = RBAR1(self)
self.rbe1 = RBE1(self)
self.rbe2 = RBE2(self)
self.rbe3 = RBE3(self)
Expand Down Expand Up @@ -778,7 +777,7 @@ def dynamic_cards(self) -> list[Any]:
@property
def rigid_element_cards(self) -> list[Any]:
rigid_elements = [
self.rbar, # self.rbar1,
self.rbar, self.rbar1,
self.rrod,
self.rbe1, self.rbe2, self.rbe3,
#self.rsscon,
Expand Down
1 change: 1 addition & 0 deletions pyNastran/dev/bdf_vectorized3/bdf_interface/write_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ def _write_rigid_elements(self, bdf_file: TextIOLike,
model.rrod.write_file(bdf_file, size=size, is_double=is_double)
#bdf_file.write(model.rrod1.write(size=size))
model.rbar.write_file(bdf_file, size=size, is_double=is_double)
model.rbar1.write_file(bdf_file, size=size, is_double=is_double)
model.rbe1.write_file(bdf_file, size=size, is_double=is_double)
model.rbe2.write_file(bdf_file, size=size, is_double=is_double)
model.rbe3.write_file(bdf_file, size=size, is_double=is_double)
Expand Down
118 changes: 117 additions & 1 deletion pyNastran/dev/bdf_vectorized3/cards/elements/rigid.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def parse_cards(self) -> None:
self.cards = []

def _save(self, element_id, nodes, independent_dof, dependent_dof, alpha, tref):
if len(self.element_id):
asdf
nelements = len(element_id)
self.element_id = element_id
self.nodes = nodes
Expand Down Expand Up @@ -266,6 +268,8 @@ def parse_cards(self) -> None:
self.cards = []

def _save(self, element_id, nodes, cm, alpha) -> None:
if len(self.element_id):
asdf
nelements = len(element_id)
assert element_id.min() > 0, element_id
assert nodes.min() > 0, nodes
Expand Down Expand Up @@ -306,6 +310,116 @@ def geom_check(self, missing: dict[str, np.ndarray]):
#node=(nid, all_nodes))


class RBAR1(RigidElement):
"""
+-------+-----+----+----+-----+-------+
| 1 | 2 | 3 | 4 | 5 | 6 |
+=======+=====+====+====+=====+=======+
| RBAR1 | EID | GA | GB | CB | ALPHA |
+-------+-----+----+----+-----+-------+
| RBAR1 | 5 | 1 | 2 | 123 | 6.5-6 |
+-------+-----+----+----+-----+-------+
"""
def __init__(self, model: BDF):
super().__init__(model)
self.element_id = np.array([])

def add(self, eid: int, nids: list[int],
cb: str='123456', alpha: float=0.0, comment: str='') -> int:
#if cma is None or cma == '':
#cma = 0
#else:
#cma = int(cma)

#if cmb is None or cmb == '':
#cmb = 0
#else:
#cmb = int(cmb)
self.cards.append((eid, nids, cb, alpha, comment))
self.n += 1
return self.n

def add_card(self, card: BDFCard, comment: str='') -> int:
"""
Adds a RBAR1 card from ``BDF.add_card(...)``
Parameters
----------
card : BDFCard()
a BDFCard object
comment : str; default=''
a comment for the card
"""
eid = integer(card, 1, 'eid')
ga = integer(card, 2, 'ga')
gb = integer(card, 3, 'gb')
cb = components_or_blank(card, 4, 'cb', default='123456')
alpha = double_or_blank(card, 5, 'alpha', default=0.0)
assert len(card) <= 6, f'len(RBAR1 card) = {len(card):d}\ncard={card}'
#return RBAR1(eid, [ga, gb], cb, alpha=alpha, comment=comment)
self.cards.append((eid, [ga, gb], cb, alpha, comment))
self.n += 1
return self.n

@RigidElement.parse_cards_check
def parse_cards(self) -> None:
ncards = len(self.cards)
element_id = np.zeros(ncards, dtype='int32')
nodes = np.zeros((ncards, 2), dtype='int32')
dependent_dof = np.zeros(ncards, dtype='int32')
#independent_dof = np.zeros((ncards, 2), dtype='int32')
#tref = np.zeros(ncards, dtype='float64')
alpha = np.zeros(ncards, dtype='float64')

for icard, card in enumerate(self.cards):
(eid, nodesi, cb, alphai, comment) = card
element_id[icard] = eid
nodes[icard, :] = nodesi
dependent_dof[icard] = cb
alpha[icard] = alphai
#self.tref[icard] = tref
self._save(element_id, nodes, dependent_dof, alpha)
self.cards = []

def _save(self, element_id, nodes, cb, alpha) -> None:
if len(self.element_id):
asdf
nelements = len(element_id)
assert element_id.min() > 0, element_id
assert nodes.min() > 0, nodes
self.nodes = nodes
self.element_id = element_id
self.dependent_dof = cb
if alpha is None:
alpha = np.zeros(nelements, dtype='float64')
self.alpha = alpha
self.n = nelements

@parse_element_check
def write_file(self, bdf_file: TextIOLike,
size: int=8, is_double: bool=False,
write_card_header: bool=False) -> None:
print_card = get_print_card_8_16(size)

eids = array_str(self.element_id)
nodes = array_str(self.nodes, size=size)
dep_nodes = array_default_int(self.dependent_dof, default=0, size=size)
alphas = array_default_float(self.alpha, default=0., size=size, is_double=is_double)
for eid, nodes, cb, alpha in zip(eids, nodes, dep_nodes, alphas):
ga, gb = nodes
list_fields = ['RBAR1', eid, ga, gb, cb, alpha]
bdf_file.write(print_card(list_fields))
return

def geom_check(self, missing: dict[str, np.ndarray]):
nid = self.model.grid.node_id
#all_nodes = np.intersect1d(self.independent_node, self.dependent_nodes, assume_unique=False)
#geom_check(self,
#missing,
#node=(nid, all_nodes))


class RBE1(RigidElement):
"""
+------+-----+-----+-----+-------+-----+-----+-----+
Expand Down Expand Up @@ -897,6 +1011,8 @@ def _save(self, element_id,
nweight, ndependent,
weight, independent_nodes, independent_dofs,
ngrid_per_weight, dependent_nodes, dependent_dofs) -> None:
if len(self.element_id):
asdf

self.element_id = element_id
self.ref_grid = ref_grid
Expand Down Expand Up @@ -1019,4 +1135,4 @@ def geom_check(self, missing: dict[str, np.ndarray]):
missing,
node=(nid, all_nodes))

RSSCON = RBAR1 = RBAR
RSSCON = RBAR
1 change: 1 addition & 0 deletions pyNastran/dev/bdf_vectorized3/cards/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def write_file(self, bdf_file: TextIOLike,
size: int=8, is_double: bool=False,
write_card_header: bool=False) -> None:
max_int = self.ids.max()
assert self.ids.min() > 0, self.ids[self.ids <= 0]
print_card = get_print_card(size, max_int)

#node_id = array_str(self.node_id, size=8)
Expand Down
6 changes: 3 additions & 3 deletions pyNastran/dev/bdf_vectorized3/cards/test/test_vector_rigid.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,16 @@ def test_rbar(self):
model.add_rbar(eid, nids, cna, cnb, cma, cmb, alpha=0., comment='rbar')
save_load_deck(model)

def _test_rbar1(self):
def test_rbar1(self):
"""tests an RBAR1"""
model = BDF(debug=False, log=None, mode='msc')
eid = 100
nids = [10, 20]
cb = '123'
model.add_grid(10, [0., 0., 0.])
model.add_grid(20, [0., 0., 0.])
rbar1 = model.add_rbar1(eid, nids, cb, comment='rbar1')
rbar1.raw_fields()
rbar1_id = model.add_rbar1(eid, nids, cb, comment='rbar1')
#rbar1.raw_fields()
save_load_deck(model)

def _test_rspline(self):
Expand Down
4 changes: 3 additions & 1 deletion pyNastran/dev/bdf_vectorized3/test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def test_other_2(self):
args = ['test_bdf', str(bdf_filename)]
test_bdf(args, show_args=False)

def test_overflow(self):
def _test_overflow(self):
# overflow
bdf_filename = MODEL_PATH / 'other' / 'sdr11se_s2dclg.bdf'
args = ['test_bdf', str(bdf_filename)]
Expand Down Expand Up @@ -409,4 +409,6 @@ def test_other_3(self):


if __name__ == '__main__':
import warnings
warnings.simplefilter('always', DeprecationWarning)
unittest.main()

0 comments on commit 3a5eccf

Please sign in to comment.