What is the TCL Command to "get nodes of elements" to which "hexa node is projeted"?

Jouher_20929
Jouher_20929 Altair Community Member
edited October 2020 in Community Q&A

What is the TCL Command to 'get nodes of elements' to which 'hexa node is projeted'?

Please see the imageimage.png.86513532dc27d04b72736e124e87c5ad.png

Answers

  • tinh
    tinh Altair Community Member
    edited March 2018

    There is no direct command I think.

    did you search on script exchange?

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    tinh, I have searched it but  it went in vain. Please help me to do this.

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi,

    use hwat package but you have to put your shell comps into an assembly, named ShellComps for example.

    code

     package require hwat   *createmarkpanel nodes 1 'Select a node of hexa element:'   set NodeId [hm_getmark nodes 1]   lassign [join [hm_nodevalue $NodeId]] x y z   set AttachedShellElemId [::hwat::utils::GetClosestElement $x $y $z ShellComps]   puts 'Attached shell element is $AttachedShellElemId'

     

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Dear Tinh,

    Please understand my requirement.

    I have to get the IDs of nodes of shell element to which node of hexa is projected. See the image. 

    Your last code will give the selected node's ID which is not my requirement.

  • tinh
    tinh Altair Community Member
    edited March 2018
     package require hwat   *createmarkpanel nodes 1 'Select a node of hexa element:'   set NodeId [hm_getmark nodes 1]   lassign [join [hm_nodevalue $NodeId]] x y z   set AttachedShellElemId [::hwat::utils::GetClosestElement $x $y $z ShellComps]   *createmark nodes 1 'by element' $AttachedShellElemId   puts 'Nodes: [hm_getmark nodes 1]'   

     

    Hi

    add more above command

  • tinh
    tinh Altair Community Member
    edited March 2018

    Dear Tinh,

    Please understand my requirement.

    I have to get the IDs of nodes of shell element to which node of hexa is projected. See the image. 

    Your last code will give the selected node's ID which is not my requirement.

     

    Once you got the element ID => you will get its nodes

     

    What do you mean with 'give the selected node's ID'?

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    What do you mean with 'give the selected node's ID'?

     

     

    When I have tried your code, It is returning id of selected hexa node. In mean time  I want to return node ids of element to which hexa node is projected.

  • tinh
    tinh Altair Community Member
    edited March 2018

    I said, you have to put the shell comps into an assembly named ShellComps, did you do it?

    and do not put hexa comp to that assembly

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Thanks Tinh, for your kindly support

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Hi Tinh,

    Please see the image. I have marked two nodes in the image. If i select those nodes, opposite element is selected. That is, I am getting wrong selection.

     

    My hexa height is 1.9.Capture.PNG.2cf19035c1fc3437fdc39ba842a3098a.PNG

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    One side is perfect, while opposite not. When I increase tolerance between two shell mesh(increase height of hexa) it works. Please help me to solve

    <?xml version="1.0" encoding="UTF-8"?>Capture.PNG

  • tinh
    tinh Altair Community Member
    edited March 2018

    I understand, it's because a node of lower element is closer to hexa node than nodes of the expected element

     

    a strategy for you that, once you find the element, get it's component and temporary remove this component from assembly ShellComps, then search again for closest element.

    you'll get upper and lower elements, and now you can compare normal distance from hexa node to these 2 elements, finally you get the closer one by compare 2 distance values.

    After done, put again the component into assembly ShellComps if you continue search for other position

     

    Can you write codes for above works?

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Thanks Tinh. I am a beginner in coding. I am trying that. Meantime if you could, it will be fine

  • tinh
    tinh Altair Community Member
    edited March 2018

    Please try it and tell us if you are stuck on somthing

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Hi Tinh,

    I have Node id in $NodeID & element ids: $AttachedShellElemId2  and  $AttachedShellElemId2. Now how to measure the normal distance. please help me.

     

     


      package require hwat
        *createmarkpanel nodes 1 'Select a node of hexa element:'
        set NodeId [hm_getmark nodes 1]
        lassign [join [hm_nodevalue $NodeId]] x y z
        set AttachedShellElemId [::hwat::utils::GetClosestElement $x $y $z ShellComps]
        *createmark nodes 1 'by element' $AttachedShellElemId
        puts 'Nodes: [hm_getmark nodes 1]'
        set comid [hm_getvalue elems id=$AttachedShellElemId dataname=collector.id]
        set coname [hm_getvalue elems id=$AttachedShellElemId dataname=collector.name]
        puts $comid
        puts $coname

      
      *createmark assemblies 2 'ShellComps'
      *createmark components 1 $coname
      *assemblyremovemark 2 components 1
      *createmark components 2 $coname
      *assemblyaddmark 2 components 2
      
      
      lassign [join [hm_nodevalue $NodeId]] x y z
          set AttachedShellElemId2 [::hwat::utils::GetClosestElement $x $y $z ShellComps]
          *createmark nodes 1 'by element' $AttachedShellElemId2
          puts 'Nodes: [hm_getmark nodes 1]'
          set comid2 [hm_getvalue elems id=$AttachedShellElemId2 dataname=collector.id]
          set coname2 [hm_getvalue elems id=$AttachedShellElemId2 dataname=collector.name]
          puts $comid2
          puts $coname2
      
        
        *createmark assemblies 2 'ShellComps'
        *createmark components 1 $coname2
        *assemblyremovemark 2 components 1
        *createmark components 2 $coname2
      *assemblyaddmark 2 components 2
      

      

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi,

    with each shell element, you get one of its node for example NodeOfElem1, NodeOfElem2

    with each shell element, you get its normal vector (using hm_getvalue elems id=$AttachedShellElemId dataname=normalx , normaly, normalz)

    then you can calculate distance from the hexa node to each plane define by normal vector and NodeOfElem

     

     

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    But Tinh, I want to calculate normal distance.

    what is the command to calculate distance from the hexa node to each plane define by normal vector and NodeOfElem

     

     

     

    *createmarkpanel nodes 1 'Select a node of hexa:'
    set NodeOfHexa [hm_getmark nodes 1]
    set NodeXYZ [join [hm_nodevalue $NodeOfHexa]]
    set ShellElem1 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]
    set CompIdOfElem1 [hm_getvalue elems id=$ShellElem1 dataname=collector.id]

      *createmark assemblies 2 'ShellComps'
      *createmark components 1 $coname
      *assemblyremovemark 2 components 1
      *createmark components 2 $coname
      *assemblyaddmark 2 components 2
      

    set ShellElem2 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]
    lassign [hm_nodelist $ShellElem1] NodeElem1
    lassign [hm_nodelist $ShellElem2] NodeElem2
    set N1x [hm_getvalue elems id=$ShellElem1 dataname=normalx]
    set N1y [hm_getvalue elems id=$ShellElem1 dataname=normaly]
    set N1z [hm_getvalue elems id=$ShellElem1 dataname=normalz]
    set N2x [hm_getvalue elems id=$ShellElem2 dataname=normalx]
    set N2y [hm_getvalue elems id=$ShellElem2 dataname=normaly]
    set N2z [hm_getvalue elems id=$ShellElem2 dataname=normalz]
    set Vector1 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem1]] [join [hm_nodevalue $NodeOfHexa]]]
    set Vector2 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem2]] [join [hm_nodevalue $NodeOfHexa]]]
    set CosA1 [hm_triplecos {*}$Vector1 $N1x $N1y $N1z]

    set CosA2 [hm_triplecos {*}$Vector2 $N2x $N2y $N2z]
    puts $CosA1
    puts $CosA2

  • tinh
    tinh Altair Community Member
    edited March 2018

    But Tinh, I want to calculate normal distance.

    what is the command to calculate distance from the hexa node to each plane define by normal vector and NodeOfElem

     

    It's just a vector operator

    d = D*cos(a)

    D = distance from hexa node to shell node

    a = angle between shell normal and vector generated from shell node to hexa node

    actually you just need to compare cos(a1) and cos(a2) (that is dot product / magnitude)

    zzz.PNG.ef4fc2d8337b71440f206cc77914eed7.PNG

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Deat Tinh, Now i am completely confused, please help me in remaining.

     


      package require hwat
        *createmarkpanel nodes 1 'Select a node of hexa element:'
        set NodeId [hm_getmark nodes 1]
        lassign [join [hm_nodevalue $NodeId]] x y z
        set AttachedShellElemId [::hwat::utils::GetClosestElement $x $y $z ShellComps]
      
        
      *createmark nodes 1 'by element' $AttachedShellElemId
      set nide [hm_getmark nodes 1]
        set comid [hm_getvalue elems id=$AttachedShellElemId dataname=collector.id]
        set coname [hm_getvalue elems id=$AttachedShellElemId dataname=collector.name]
        puts $comid
        puts $coname
        set nod1 [lindex $nide 0]
        set nod2 [lindex $nide 1]
    set nod3 [lindex $nide 2]

      
      *createmark assemblies 2 'ShellComps'
      *createmark components 1 $coname
      *assemblyremovemark 2 components 1
      *createmark components 2 $coname
      *assemblyaddmark 2 components 2
      
      
      lassign [join [hm_nodevalue $NodeId]] x y z
          set AttachedShellElemId2 [::hwat::utils::GetClosestElement $x $y $z ShellComps]
          
          *createmark nodes 1 'by element' $AttachedShellElemId2
        
      set nide2 [hm_getmark nodes 1]
          set comid2 [hm_getvalue elems id=$AttachedShellElemId2 dataname=collector.id]
          set coname2 [hm_getvalue elems id=$AttachedShellElemId2 dataname=collector.name]
          puts $comid2
          puts $coname2
          set nod1 [lindex $nide2 0]
          set nod2 [lindex $nide2 1]
    set nod3 [lindex $nide2 2]
      
        
        *createmark assemblies 2 'ShellComps'
        *createmark components 1 $coname2
        *assemblyremovemark 2 components 1
        *createmark components 2 $coname2
      *assemblyaddmark 2 components 2
      
      
      

  • tinh
    tinh Altair Community Member
    edited March 2018

    Hi,

    To make it clearly and not be confused, you have to write some procs:

    proc p_AddCompIDsToAssem {AssemName CompIDs} {

            => write commands to add CompIDs to assembly AssemName

    }

    proc p_RemoveCompIDsFromAssem {AssemName CompIDs} {

          -> write commands to remove CompIDs

    }

     

    example you have 2 shell comps, ID 5 and 7, first -> add it in ShellComps

    p_AddCompIDsToAssem ShellComps {5 7}

    *createmarkpanel nodes 1 'Select a node of hexa:'

    set NodeOfHexa [hm_getmark nodes 1]

    set NodeXYZ [join [hm_nodevalue $NodeOfHexa]]

    set ShellElem1 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]

    set CompIdOfElem1 [hm_getvalue elems id=$ShellElem1 dataname=collector.id]

    p_RemoveCompIDsFromAssem ShellComps $CompIdOfElem1

    set ShellElem2 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]

    lassign [hm_nodelist $ShellElem1] NodeElem1

    lassign [hm_nodelist $ShellElem2] NodeElem2

    set N1x [hm_getvalue elems id=$ShellElem1 dataname=normalx]

    set N1y...

    set N1z...

    set N2x...

    set N2y..

    set N2z...

    set Vector1 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem1]] [join [hm_nodevalue $NodeOfHexa]]]

    set Vector2 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem2]] [join [hm_nodevalue $NodeOfHexa]]]

    set CosA1 [hm_triplecos {*}$Vector1 $N1x $N1y $N1z]

    set CosA2 ...

    => compare 2 cosine value

    p_AddCompIDsToAssem ShellComps $CompIdOfElem1

  • Jouher_20929
    Jouher_20929 Altair Community Member
    edited March 2018

    Dear Tinh, 

    Thanks for your support. But I am facing a problem. Out of 8 nodes, 2 nodes are selecting wrong components using below code. please see the image also.

     

     

    *createmarkpanel nodes 1 'Select a node of hexa:'
    set NodeOfHexa [hm_getmark nodes 1]
    set NodeXYZ [join [hm_nodevalue $NodeOfHexa]]
    set ShellElem1 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]
    set CompIdOfElem1 [hm_getvalue elems id=$ShellElem1 dataname=collector.id]
      set coname1 [hm_getvalue elems id=$ShellElem1 dataname=collector.name]


      *createmark assemblies 2 'ShellComps'
      *createmark components 1 $coname
      *assemblyremovemark 2 components 1
      *createmark components 2 $coname
      *assemblyaddmark 2 components 2
      
    set ShellElem2 [::hwat::utils::GetClosestElement {*}$NodeXYZ ShellComps]
    set coname2 [hm_getvalue elems id=$ShellElem2 dataname=collector.name]
    lassign [hm_nodelist $ShellElem1] NodeElem1
    lassign [hm_nodelist $ShellElem2] NodeElem2
    set N1x [hm_getvalue elems id=$ShellElem1 dataname=normalx]
    set N1y [hm_getvalue elems id=$ShellElem1 dataname=normaly]
    set N1z [hm_getvalue elems id=$ShellElem1 dataname=normalz]
    set N2x [hm_getvalue elems id=$ShellElem2 dataname=normalx]
    set N2y [hm_getvalue elems id=$ShellElem2 dataname=normaly]
    set N2z [hm_getvalue elems id=$ShellElem2 dataname=normalz]
    set Vector1 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem1]] [join [hm_nodevalue $NodeOfHexa]]]
    set Vector2 [::hwat::math::GetVector [join [hm_nodevalue $NodeElem2]] [join [hm_nodevalue $NodeOfHexa]]]
    set CosA1 [hm_triplecos {*}$Vector1 $N1x $N1y $N1z]
    set CosA2 [hm_triplecos {*}$Vector2 $N2x $N2y $N2z]
    puts $CosA1
    puts $CosA2

    if {$CosA1 > $CosA2} {

    *createmark assemblies 2 'ShellComps'
      *createmark components 1 all
      *assemblyremovemark 2 components 1
      *createmark components 2 all
      *assemblyaddmark 2 components 2

    *createmark assemblies 2 'coname'
    *createmark components 1 $coname1
    *assemblyremovemark 2 components 1
    *createmark components 2 $coname1
    *assemblyaddmark 1 components 2
    } elseif {$CosA1 < $CosA2} {
    *createmark assemblies 2 'coname'
    *createmark components 1 $coname2
    *assemblyremovemark 2 components 1
    *createmark components 2 $coname2
    *assemblyaddmark 1 components 2
    }

    <?xml version="1.0" encoding="UTF-8"?>Capture.PNG

  • tinh
    tinh Altair Community Member
    edited March 2018

    please write the 2 procs. I want to see them, they are key point of problem

  • Manoj Yandra
    Manoj Yandra Altair Community Member
    edited August 2020

    I have duplicated few nodes(say 10 nodes). How to retrieve those 10 nodes and renumber with known IDs

  • tinh
    tinh Altair Community Member
    edited August 2020

    Try

    *createmark nodes 1 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10

    *renumber.....