How to get connected elements between components in hypermesh/hyperworks using "hm_getconnected2delems"?

Christian Nörenberg
Christian Nörenberg Altair Community Member
edited April 2022 in Community Q&A

Hi,

I want to connect 2 surfaces/components (2D) automaticly by using a contact (very low level question). Therefore I want to create 2 "contact surfaces" and use "contact pair".

1. Question: Is this even the right way? Or would it be enough to use 2 sets of "SET_ELEM" with the elements on the edge and pair them? Or 1 "SET_ELEM" and 1 "SET_GRID" with the nodes of the edge?

The elements and nodes between the components can be found by using the command "hm_getconnected2delems".
The Code I build so far for the first "contact surfaces" is:

*createentity sets cardimage=SURF name="set_1" id=1;   *createmark comps 1 "1" "2" *createstringarray 3 "find: 1 0 1 1" "features: 0 179.9 comp" "output: 0 1 1" set entity_list_all_comps [hm_getconnected2delems comps 1 1 3];    #as discribed in documentation set elem_list_comp_1 [lindex $entity_list_all_comps 0];            #elements from comp 1 set node_list_comp_1 [lindex $entity_list_all_comps 2];            #nodes from comp 1  eval *createmark elements 1 $elem_list_comp_1  eval *createmark nodes 1 $node_list_comp_1 *segmentsetaddfaces "set_1" 1 1 30 1 0

Same thing for the second "contact surface".
But somehow its not working. I think the lists are empty, but I cant see the elements in the list ("puts" isnt working)

image

Do you know how to use this command correctly?

Thanks for your answers!

Best Answer

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022 Answer ✓

    Thanks!

    But I think the first line is wrong bc "set_NODES" isnt created yet and the mark with nodes, too.
    Did you maybe miss some lines before?

    sorry, yes, copy/pasted wrong line

    ok, this is working:

    *createmark elems 1 displayed *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_LOW id=1 *setvalue sets name=set_NODES_LOW ids={[hm_getusermark nodes]} *equivalence elems 1 0.1 3 2 1 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_HIGH id=2 *setvalue sets name=set_NODES_HIGH ids={[hm_getusermark nodes]} *createmark nodes 1 "by set id" 1 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_LOW id=3 *setvalue sets name=set_ELEM_LOW ids={[hm_getmark elems 2]} *createmark nodes 1 "by set id" 2 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_HIGH id=4 *setvalue sets name=set_ELEM_HIGH ids={[hm_getmark elems 2]} 

    only caveat is that it is sorting by 'High' and 'Low' Ids, so in cases where the numbering was crossing over between the comps, you would get a mixture of the elements from each component in each set

Answers

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited March 2022

    I think I have a general problem with the handling/understanding of this output-"lists" ...

    Now I tried "hm_getnodessharedbyothercomps" to get the nodes between both comps.

    *createmark comps 1 1 set nodes_list [hm_getnodessharedbyothercomps 1 1 0] *clearmark comps 1  *createentity sets cardimage=SET_GRID includeid=0 name=set_1 id=1 *setvalue sets id=1 support=-1 eval "*setvalue sets id=1 ids=$nodes_list";            # 1. attempt eval "*setvalue sets id=1 ids=\{nodes $nodes_list\}";  # 2. attempt

    I did many more attempts (with/without eval), but none was working ..

    In the tcl-commandfile I saw that the "nodes_list" is empty (bc it disappeared in the evaluated expression).

    I tried all kinds of brackets, with/without "nodes_list" variable at all, ...
    But I am running out of new ideas

  • PaulAltair
    PaulAltair
    Altair Employee
    edited March 2022

    In your original hm the 2 comps don't share any nodes so the hm 'get nodes...' command would return nothing, in attached I equivalenced 3 nodes, then the following returns a set with 3 nodes in it, once they are equivalenced, you don't need to create a contact between them though... so not sure it helps much with your original request!

    *createmark comps 1 1 hm_getnodessharedbyothercomps 1 1 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES id=1 *setvalue sets name=set_NODES ids={[hm_getmark nodes 1]}

     

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    Got it, thanks a lot!
    Than I cant use this cmd, bc I need to import to geometry from 2 step-files and contact the surfaces/comps.

    But if I understand the documentation of the first command ("hm_getconneted2delems") correctly, it should work for this model. Do you have any advices for the syntax?

    From documentation:

    "Returns lists of 2D shell elements and nodes that form t-connections or share edges at component boundaries. Advanced options are available to categorize the connected entities (T-connected, L-connected, Butt-connected or Overlap connected), as well as to specify the format of the return values."

    Latest attempt (which is not working):

    *createstringarray 3 "find: 1 0 0 1" "features: 5.0 175.0 comp" "output: 0 0 1" *createmark comps 1 1 hm_getconnected2delems comps 1 1 3 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES id=1 *setvalue sets name=set_NODES ids={[hm_getmark nodes 1]}

    I just want to get access to the returned lists from the command.

    From your answer it looks like the command "hm_getnodessharedbyothercomps" returns a new "mark" with nodes instead of a simple list, but the other command should return lists ...

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    Alright, I tried this lines in your hm model:

    *createmark comps 1 1 *createstringarray 3 "find: 1 0 0 1" "features: 5.0 175.0 comp" "output: 0 1 1" set elem_lists [hm_getconnected2delems comps 1 1 3]

    and I really got a list of the 4 elements and 3 nodes. But only for the nodes you have equivalenced.

    Is there another way to get all elements/nodes at the edges for both components without equivalencing before?

    Bc if I equivalence all nodes at the edge, I think the model doesnt make sense anymore and I dont need contacts at all, right? And it would be very hard to code in tcl/batch mode.

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022

    Got it, thanks a lot!
    Than I cant use this cmd, bc I need to import to geometry from 2 step-files and contact the surfaces/comps.

    But if I understand the documentation of the first command ("hm_getconneted2delems") correctly, it should work for this model. Do you have any advices for the syntax?

    From documentation:

    "Returns lists of 2D shell elements and nodes that form t-connections or share edges at component boundaries. Advanced options are available to categorize the connected entities (T-connected, L-connected, Butt-connected or Overlap connected), as well as to specify the format of the return values."

    Latest attempt (which is not working):

    *createstringarray 3 "find: 1 0 0 1" "features: 5.0 175.0 comp" "output: 0 0 1" *createmark comps 1 1 hm_getconnected2delems comps 1 1 3 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES id=1 *setvalue sets name=set_NODES ids={[hm_getmark nodes 1]}

    I just want to get access to the returned lists from the command.

    From your answer it looks like the command "hm_getnodessharedbyothercomps" returns a new "mark" with nodes instead of a simple list, but the other command should return lists ...

    I don't think it will work for your original requirement, for a few reasons:

    You are only selecting 1 component in your comp createmark, and this command works on shared edges between the comps in the mark (and you only have 1, so nothing shared)

    Even if you did have both selected in the mark, again, the key here is the wording 'share edges', in your original hm the components don't 'share' an edge, i.e. the nodes are not equivalenced, they are merely coincident. 

    Also in your example, you are requesting output of elems, but trying to create a node set

    If you use my modified hm from last reply and pick both comps in the mark then this command should work for those 2 elements/3 nodes that are 'shared' (see below)

    The output even then is of the form 'all elems elementlist' though so you can't use that directly to make a set, as the string contains the words 'all' and 'elems' as well as the ids

    e.g. 

    *createmark comps 1 displayed

    *createstringarray 3 "find: 1 0 0 1" "features: 0.0 179.9 comp" "output: 0 1 0"

    set elem_lists [hm_getconnected2delems comps 1 1 3]

     

    image

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022

    Alright, I tried this lines in your hm model:

    *createmark comps 1 1 *createstringarray 3 "find: 1 0 0 1" "features: 5.0 175.0 comp" "output: 0 1 1" set elem_lists [hm_getconnected2delems comps 1 1 3]

    and I really got a list of the 4 elements and 3 nodes. But only for the nodes you have equivalenced.

    Is there another way to get all elements/nodes at the edges for both components without equivalencing before?

    Bc if I equivalence all nodes at the edge, I think the model doesnt make sense anymore and I dont need contacts at all, right? And it would be very hard to code in tcl/batch mode.

    What about:

    *setvalue sets name=set_NODES ids={[hm_getmark nodes 1]} *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES id=1 *setvalue sets name=set_NODES ids={[hm_getusermark nodes]} *findmark nodes 1 257 1 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEMS id=2 *setvalue sets name=set_ELEMS ids={[hm_getmark elems 2]}

    nearly.. but it only gets you the nodes and elems on one side of the edge...

     

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    What about:

    *setvalue sets name=set_NODES ids={[hm_getmark nodes 1]} *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES id=1 *setvalue sets name=set_NODES ids={[hm_getusermark nodes]} *findmark nodes 1 257 1 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEMS id=2 *setvalue sets name=set_ELEMS ids={[hm_getmark elems 2]}

    nearly.. but it only gets you the nodes and elems on one side of the edge...

     

    Thanks!

    But I think the first line is wrong bc "set_NODES" isnt created yet and the mark with nodes, too.
    Did you maybe miss some lines before?

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022 Answer ✓

    Thanks!

    But I think the first line is wrong bc "set_NODES" isnt created yet and the mark with nodes, too.
    Did you maybe miss some lines before?

    sorry, yes, copy/pasted wrong line

    ok, this is working:

    *createmark elems 1 displayed *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_LOW id=1 *setvalue sets name=set_NODES_LOW ids={[hm_getusermark nodes]} *equivalence elems 1 0.1 3 2 1 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_HIGH id=2 *setvalue sets name=set_NODES_HIGH ids={[hm_getusermark nodes]} *createmark nodes 1 "by set id" 1 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_LOW id=3 *setvalue sets name=set_ELEM_LOW ids={[hm_getmark elems 2]} *createmark nodes 1 "by set id" 2 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_HIGH id=4 *setvalue sets name=set_ELEM_HIGH ids={[hm_getmark elems 2]} 

    only caveat is that it is sorting by 'High' and 'Low' Ids, so in cases where the numbering was crossing over between the comps, you would get a mixture of the elements from each component in each set

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022

    sorry, yes, copy/pasted wrong line

    ok, this is working:

    *createmark elems 1 displayed *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_LOW id=1 *setvalue sets name=set_NODES_LOW ids={[hm_getusermark nodes]} *equivalence elems 1 0.1 3 2 1 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_HIGH id=2 *setvalue sets name=set_NODES_HIGH ids={[hm_getusermark nodes]} *createmark nodes 1 "by set id" 1 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_LOW id=3 *setvalue sets name=set_ELEM_LOW ids={[hm_getmark elems 2]} *createmark nodes 1 "by set id" 2 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_HIGH id=4 *setvalue sets name=set_ELEM_HIGH ids={[hm_getmark elems 2]} 

    only caveat is that it is sorting by 'High' and 'Low' Ids, so in cases where the numbering was crossing over between the comps, you would get a mixture of the elements from each component in each set

    I should add, if all you wanted to do was equivalence them... then, we can lose most of the above! and just use

    *createmark elems 1 displayed *equivalence elems 1 0.1 1 2 0
  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    sorry, yes, copy/pasted wrong line

    ok, this is working:

    *createmark elems 1 displayed *equivalence elems 1 0.1 3 2 0 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_LOW id=1 *setvalue sets name=set_NODES_LOW ids={[hm_getusermark nodes]} *equivalence elems 1 0.1 3 2 1 *createentity sets cardimage=SET_GRID includeid=0 name=set_NODES_HIGH id=2 *setvalue sets name=set_NODES_HIGH ids={[hm_getusermark nodes]} *createmark nodes 1 "by set id" 1 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_LOW id=3 *setvalue sets name=set_ELEM_LOW ids={[hm_getmark elems 2]} *createmark nodes 1 "by set id" 2 *findmark nodes 1 257 elements 0 2 *createentity sets cardimage=SET_ELEM includeid=0 name=set_ELEM_HIGH id=4 *setvalue sets name=set_ELEM_HIGH ids={[hm_getmark elems 2]} 

    only caveat is that it is sorting by 'High' and 'Low' Ids, so in cases where the numbering was crossing over between the comps, you would get a mixture of the elements from each component in each set

    Awesome, thanks again!

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    I should add, if all you wanted to do was equivalence them... then, we can lose most of the above! and just use

    *createmark elems 1 displayed *equivalence elems 1 0.1 1 2 0

    Honestly, this might be enough for the first time.
    It is so hard to find the right command within the huge list of tcl commands in the documentation ...

    But thanks for all the further lines of code, this will help me a lot to understand the syntax and handling of lists, marks, usermarks etc.

    If I am right, I should use the command just for "searching" and not for "equivalencing" (with the according flag). But I might misunderstand the "equivalencing".

  • PaulAltair
    PaulAltair
    Altair Employee
    edited April 2022

    Awesome, thanks again!

    if you 'equivalence' them (i.e. 'mode = 1' on the *equivalence), the 2 original nodes become one shared node, the connectivity of the elements will be updated so they are joined together at the new node, you can choose whether you want to retain the higher or lower ID of the originals for the new node and the location of the new node (lower id location, higher id location or geometrically between the 2)

    if you use mode=3 then you are just adding the prospective nodes for equivalence to a mark without actually performing the combination

    NB. all this would only be of use where your mesh 'matches' between the edges since it it is seeking nodes within a location tolerance of each other, your original post request would also have potential to deal with situations where the mesh density is not matching? by finding the edges and tying them together with contact (I'm not sure how to achieve that in a script, but it should also be possible)

     

    image

     

     

  • Christian Nörenberg
    Christian Nörenberg Altair Community Member
    edited April 2022

    if you 'equivalence' them (i.e. 'mode = 1' on the *equivalence), the 2 original nodes become one shared node, the connectivity of the elements will be updated so they are joined together at the new node, you can choose whether you want to retain the higher or lower ID of the originals for the new node and the location of the new node (lower id location, higher id location or geometrically between the 2)

    if you use mode=3 then you are just adding the prospective nodes for equivalence to a mark without actually performing the combination

    NB. all this would only be of use where your mesh 'matches' between the edges since it it is seeking nodes within a location tolerance of each other, your original post request would also have potential to deal with situations where the mesh density is not matching? by finding the edges and tying them together with contact (I'm not sure how to achieve that in a script, but it should also be possible)

     

    image

     

     

    Ok, understood!

    You're right, different mesh densities would be a problem, but luckily I can control it.
    Otherwise I think I would need a workaround like

    1. getting the surfaces edges (hm_getsurfaceedges),
    2. identify / find the overlapping/duplicated edges (maybe by comparing the coords of their start & end points, idk)
    3. finally get the nodes of the corresponding edges ("hm_getgeometrynodes") or elements ("hm_getnearyentities") close to the edges (but there might be a smarter way)

    This seem very rough, so hopefully the simple way will do.