modifying node numbers

20 views
Skip to first unread message

clarkbr...@gmail.com

unread,
Feb 15, 2021, 12:59:16 PM2/15/21
to pyNastran Discuss
Steve,
I'm trying to follow your example code of 2/12/2021 where you said:

or if you want to break the connection:

    nid = 3007

    eids = nid_to_eids_map[nid]

    for eid in eids:

        elem = model.elements[eid]  # CBEAM, CQUAD4, ...

        i = elem.nodes.index(nid)

        elem.uncross_reference()

        elem.nodes[i] = 3113

        elem.cross_reference(model) # optional depending...

I did something like:

    nid=3007
    eids = nid_to_eids_map[nid]
    for eid in eids:
        elem = model.elements[eid]   
        i = elem.nodes.index(nid)
        elem.uncross_reference()
         elem.nodes[i] = 3113

I had read the .dat with xref=True

The first element is

elem
$inboard right upper spar 0 caps for wing
CBEAM       3001    3001    3007    3034     -1.      0.      0.

After the uncross_ref and prior to the 3113 assignment,

elem.nodes_ref
[None, None]

and after the assignment the node is unchanged:

elem.nodes
[3007, 3034]

So I tried to make you a test model. Getting enough cards defined to run that code required PSHELLs MATs, etc. I finally got the following to do the same thing, although I can't get it to cross_ref and then uncross_ref because too many cards are missing. But it shows the same nodes_xref = [None, None], not None (which I expected).

from pyNastran.bdf.bdf import BDF

model = BDF()
model.add_grid(3007,[0,0,0])
model.add_grid(3034,[1,1,1])
model.add_grid(3036,[2,2,2])
model.add_grid(3009,[3,3,3])
model.add_cbeam(3001,3001,[3007,3034],[-1,0,0],g0=None)
model.add_cquad4(3007,3007,[3007,3034,3036,3009])

nid=3007
eid=3001
elem = model.elements[eid]  
print('element eid '+str(eid)+' has nodes ',elem.nodes)
i = elem.nodes.index(nid)
elem.uncross_reference()
print('element eid '+str(eid)+' has nodes_ref ',elem.nodes_ref)
elem.nodes[i] = 3113
print('after the assignment, element eid '+str(eid)+' has nodes ',elem.nodes)

Its output is

runfile('test.py', ...)
element eid 3001 has nodes  [3007, 3034]
element eid 3001 has nodes_ref  [None, None]
after the assignment, element eid 3001 has nodes  [3007, 3034]

That element is a CBEAM. If I try it with a CQUAD, it works. Set eid=3007 and the output is

element eid 3007 has nodes  [3007, 3034, 3036, 3009]
element eid 3007 has nodes_ref  None
after the assignment, element eid 3007 has nodes  [3113, 3034, 3036, 3009]

Which is the desired change.

I also appended the file test.py.

Clark

test.py

steve

unread,
Feb 16, 2021, 11:28:37 AM2/16/21
to pyNastran Discuss
Clark,

It looks like that's not the case for the CBEAM.  That's annoying.  It uses ga/gb and ga_ref/gb_ref with nodes as a property.  You need to set elem.ga for nodes[0] and elem.gb for nodes[1].

That should change in the next version and will backwards compatible outside of nodes_ref=None vs. nodes_ref=[None,None].
Reply all
Reply to author
Forward
0 new messages