modifying nodes parm/attr

5 views
Skip to first unread message

clarkbr...@gmail.com

unread,
Feb 12, 2021, 6:03:28 PMFeb 12
to pyNastran Discuss
Steve,
I'm still moving, chasing deleting an element and re-adding it.
FYI.
It seems I can change an item in nodes for CQUAD but not CBEAM.
model.elements[3001]
$inboard right upper spar 0 caps for wing
CBEAM       3001    3001    3007    3034     -1.      0.      0.
via
 temp = elems[i][0];del model.elements[temp.eid]
 model.add_cbeam(temp.get_field(1),temp.get_field(2),[rpivot_nodes[0],temp.nodes[1]],temp.x,g0=None,comment=temp.comment)
produces
model.elements[3001]
$$inboard right upper spar 0 caps for wing
CBEAM       3001    3001    3013    3034     -1.      0.      0.
as desired.
But I tried
temp.nodes
[3007, 3034]
IPdb [5]: temp.nodes[0]=3013
IPdb [6]: temp.nodes
[3007, 3034]
It doesn't make the change. That's a CBEAM.
Try the nodes thing with a CQUAD:
model.elements[3007]
$inboard right upper spar 0 web for wing
CQUAD4      3007    3007    3007    3034    3036    3009
via
temp = elems[i][1];del model.elements[temp.eid];temp.nodes[0]=rpivot_nodes[0]
model.add_cquad4(temp.get_field(1),temp.get_field(2),temp.nodes,comment=temp.comment)
produces
model.elements[3007]
$$inboard right upper spar 0 web for wing
CQUAD4      3007    3007    3013    3034    3036    3009
as desired.
FYI
Clark

Steven Doyle

unread,
Feb 12, 2021, 6:13:14 PMFeb 12
to pyNastran Discuss
Clark,

It's not clear to me exactly what you're trying to do, so it's hard to help you.  Are you trying to just renumber nodes?  Are you trying to change CBEAM node ids only without changing CQUAD4 node ids?  Something else?

Where do elems[i][0] and elems[i][1] come from?   You shouldn't need to delete elements.  Do have an small example model with a script that shows your error as well as what you want?



--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pynastran-discuss/1249a7b9-92be-455c-8159-0539a5430fa1n%40googlegroups.com.

clarkbr...@gmail.com

unread,
Feb 12, 2021, 6:43:05 PMFeb 12
to pyNastran Discuss
Steve,
This note was just an FYI that changing an element.nodes was inconsistent between two noded CBEAMs and four noded CQUADS. As shown, I can make both work, just differently.
re: " It's not clear to me exactly what you're trying to do"
Replying here will mangle the message streams, but the answer to this question is:
On 2/10/2021 I wrote titled "Modifying element node numbers (again)":
"I tried to understand/follow the thread dated Apr 9, 2019 titled Modifying the nodes that define an element. I tried the various ways you describe. Nothing will modify the element even tho none assignments generate a gripe.

I have a large model read from a .dat with the xref=True.

Wing spars are modeled as CBEAMs for upper and lower spar caps and the web is a CQUAD. I want to change the node numbers for some of them. For every CBEAM that has nodeA=3007 or 3019, I want it to be nodeA=3113.

I found the map:

nid_to_eids_map = model.get_node_id_to_elements_map()

Collected a list of elements:

elems=[]

elems.append(nid_to_eids_map[3007])

elems.append(nid_to_eids_map[3019])"

I have a large FEM and want to codefully change certain elements. So far, I'm trying to change the nodes referenced on some CBEAMs and CQUADs. There are a bunch of elements, but this snippet captures those that touch nodes 3007 and 3019. The goal is to replace node 3007 and 3019 in those elements with 3113.
There are some subsequent steps. I need to change the location of some nodes. set_position() seems to do that. I haven't checked well on that.
I will need to change the dependent node on some RBE3s, but my initial poking suggests the methods to alter RBEs don't work either.
The large model is an aircraft conceptual design model that was largely autogenerated (codefully). It generates wing carry through structure (between the right root rib and the left root rib) with simple continuation of the wing spars. We want to change the layout of the wing carry through structure and try to develop a more complex support structure into the fuselage. But this is too early/immature to justify hacking up the code in the big model generator. So I'm trying to make up a bit of post processing code, instead of just hand editing the original data deck.
I understand the value of a small example model. I have thought about what that might be, but didn't stop to do it. Given the prior 2019 questions, I thought you could straighten me out.
re: " You shouldn't need to delete elements."
I figured that would be the case, but since I couldn't get modifying them to work, I set out to delete and replace. Right now, any way that works will get my job done.
Doing this by writing is difficult. Talking might be better. If you are willing, I will pass you my cell phone via email outside the forum.
Clark

Steven Doyle

unread,
Feb 12, 2021, 6:56:23 PMFeb 12
to pyNastran Discuss
> The goal is to replace node 3007 and 3019 in those elements with 3113.

Are you trying to simply renumber them or change only the node ids associated with CBEAMs, but not CQUADs/anything else?

If you have a cross-referenced model, you can simply run:
    nid = 3007
    eids = nid_to_eids_map[nid]
    for eid in eids:
        elem = model.elements[eid]  # CBEAM, CQUAD4, ...
        i = elem.nodes.index(nid)
        elem.nodes_ref[i].nid = 3113

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...

There's always another way to do it, so it depends on how important speed is/other things you're doing, etc.

> Doing this by writing is difficult. Talking might be better. If you are willing, I will pass you my cell phone via email outside the forum.

I'd prefer not at least not without a contract though M4 Engineering.  That makes it harder for other users (and other future users).

clarkbr...@gmail.com

unread,
Feb 12, 2021, 7:17:21 PMFeb 12
to pyNastran Discuss
Steve,
Outstanding. Thanks for your patience.
re: " I'd prefer not" to talk. Ok enough.
I do see that one uses elem.nodes_ref[i].nid and the other uses elem.nodes[i].
I thought I had worked with these examples (which I saw in the original Apr 9, 2019 thread) multiple times the last few days but I can see now I didn't quite do them correctly.
But what does your phrase "break the connection" mean?
This question exposes a fundamental non-understanding on my part.
re: " Are you trying to simply renumber them or change only the node ids associated with CBEAMs, but not CQUADs/anything else?"
Again, I don't understand your meaning. I want to change the connections on those CBEAMS and CQUADS that use nodes 3007 and 3009 and make them use 3113.
I'm very carefully picking the returned elements from the map to make sure I want to change those. I'm trying not make any global assumptions about what else uses these nodes.
I like your first example (given I don't understand breaking and re-cross referencing). Your much more elegant Python with the for eid in eids and your use of index beats the heck out of my list of elements.
Thanks,
Clark

Steven Doyle

unread,
Feb 12, 2021, 7:40:30 PMFeb 12
to pyNastran Discuss
> But what does your phrase "break the connection" mean?

It means uncross-reference.  For example, if you're cross-referenced:

>>> cbeam
CBEAM,1,2,, 100, 3007, 1.0, 0.0, 0.0
>>> cquad4
CQUAD4,2,3,, 100, 101, 3007, 3008

cbeam.nodes_ref[1].nid = 3113
>>> cbeam
CBEAM,1,2,, 100, 3113, 1.0, 0.0, 0.0
>>> cquad4
CQUAD4,2,3,, 100, 101, 3113, 3008

That changes all node id 3007 -> 3113 for every element/constraint/mass/etc., but doesn't affect connectivity/results at all (assuming you don't haven't used node 3113).  That's what I mean by it's simply a renumbering.  If you want the CBEAMs to change, but the CQUAD4s to be left alone, then you can do it the second way.  If there's more subtleties to it (e.g., but only if the property id is in some list and the element ids are in some list), then you need to change the logic a bit.

clarkbr...@gmail.com

unread,
Feb 12, 2021, 8:14:27 PMFeb 12
to pyNastran Discuss
Steve,
Nice explanation.
That's a much more far reaching meaning that I could have imagined. I'll work on it.
In my current case, that isn't what I was doing.
" If you want the CBEAMs to change, but the CQUAD4s to be left alone, then you can do it the second way."
That's what I was thinking.
With my new understanding, I could just be that the cross-referenced way can apply, given how I numbered stuff. That would certainly help. Now I change every CBEAM and CQUAD with that number individually. With cross-referecing, I could just change a CBEAM and the CQUADs would change. One step.
Thanks so much,
Clark
Reply all
Reply to author
Forward
0 new messages