How to set element density on the lines if line IDs are available?

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

How can I set element density for two shortest lines of a rectangular surface and leave the other two lines with the default element density based on predefined element size?

 

I have the line IDs.

 #Selected Surface set surfIDs [ hm_getmark surfs 1] *createmark lines 1 'by surface' {*}$surfIDs  #Line list  set lineList [hm_getmark lines 1]  #Line IDs set lineId1 [lindex $lineList 0] set lineId2 [lindex $lineList 1] set lineId3 [lindex $lineList 2] set lineId4 [lindex $lineList 3]

 

 

 

Answers

  • tinh
    tinh Altair Community Member
    edited May 2017

    Hi,

    try this script:

     set Density1 5 set Density2 10 *deleteelementsmode 2 *createmarkpanel surfs 1 'Pick a surface:' if {[hm_marklength surfs 1]==1} {     foreach LineId [join [hm_getsurfaceedges [hm_getmark surfs 1]]] {lappend LineList [list $LineId [hm_linelength $LineId]]}     set LineList [lsort -increasing -real -index 1 $LineList]     lassign [join $LineList] Line1 -> Line2     *setedgedensitylinkwithaspectratio -1      *elementorder 1      *defaultremeshsurf 1 [hm_getelementsize] 2 2 2 0 1 1 1 0 0 0 0      *createmark lines 1 $Line1     *change_edgedensities 1 1 $Density1 0     *createmark lines 1 $Line2     *change_edgedensities 1 1 $Density2 0 }

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    Hi

    I'm getting following error. What could be the reason?

     

     

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

  • tinh
    tinh Altair Community Member
    edited May 2017

    Hi,

    what did hm say in error message bar?

    it could be due to your surf has only 1 edge

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    I'm selecting the top surface as shown in image.

     

    <?xml version="1.0" encoding="UTF-8"?>Capture7.thumb.PNG.82b69cc978b17847d16fc2da5e460b21.PNG

     

     

    Getting following message:

     

    Capture6.PNG.059b7fa44bc3629441919ea622360553.PNG

     

     

    Few questions regarding the code:

     

    Can you please explain what does below line do?

    lassign [join $LineList] Line1 -> Line2

     

     puts '[lassign [join $LineList] Line1 -> Line2]]'

    Above line is following output. What are 43  and 42 numbers signify?

     

    1 43 1 42 1 15 1 45 1 15 1 45 1 43 1 42 1 45 1 46 1 45 1 46 1 15 1 45 1 43 1 42 1 15 1 45 1 43 1 42 1 45 1 46 1 15 1 45 1 43 1 42 1 45 1 46 1 15 1 45 1 43 1 42 1 43 1 42 1 15 1 45 1 45 1 46 1 15 1 45 1 15 1 45 1 15 1 45 1 45 1 46 1 43 1 42 1 43 1 42 1 43 1 42 1 43 1 42 1 15 1 45 1 43 1 42 1 18 1 20 1 24 1 26 1 24 1 26 1 18 1 20 1 18 1 20 1 26 1 22 1 24 1 26 1 18 1 20 1 26 1 22 1 9 1 8 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 6 1 9 1 6 1 9 1 5 1 4 1 9 1 8 1 6 1 9 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 5 1 4 1 48 2 48 2 48 2 48 2 48 2 48 2 48 2 15 2 15 2 2 2 2 2 44 5 47 5 25 5 47 5 41 5 40 5 41 5 40 5 25 5 47 5 44 5 47 5 44 5 47 5 41 5 40 5 25 5 47 5 41 5 40 5 25 5 47 5 44 5 47 5 41 5 40 5 25 5 47 5 44 5 47 5 41 5 40 5 25 5 47 5 25 5 47 5 41 5 40 5 44 5 47 5 41 5 40 5 41 5 40 5 41 5 40 5 44 5 47 5 25 5 47 5 25 5 47 5 25 5 47 5 25 5 47 5 41 5 40 5 25 5 47 5 17 5 19 5 23 5 25 5 23 5 25 5 17 5 19 5 {19 15 21 26 22} 5 {23 24 25 26} 5 {17 18 19 20} 5 {19 15 21 26 22} 5 {23 24 25 26} 5 17 5 19 5 19 5 21 5 23 5 25 5 17 5 19 5 19 5 21 5 3 5 7 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 11 5 10 5 11 5 10 5 1 5 3 5 3 5 7 5 11 5 10 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 1 5 1 5 1 5 3 5 1 5 3 5 1 5 3 5 1 5 3 5]

     

     

  • tinh
    tinh Altair Community Member
    edited May 2017

    Hi,

    I can run it with no error. Did you copy my script and run? or you retyped them (maybe you missed something)?

    Send me your model please.

     

    for lassign command usage, please refer to

    https://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited May 2017

    Hi

    I'm using the exact code what you have written.

    The selected surface is meshed but not according to the element density specified in the code. 

     

    I closed the hypermesh and started it again. Now I'm getting the error. But the mesh is not according to the density specified.

     

    On one of the shortest edge density is 5 and another shortest edge its 10.

     

     

     

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

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

    Unable to find an attachment - read this blog

  • tinh
    tinh Altair Community Member
    edited June 2017

    I don't understand.

    In tcl script, you set Density1 = 5 and Density2 = 10, then your mesh appeared with one shortest edge has 5 segments and the alternative has 10. So what are you expecting?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2017

    I would like to have same elements on both the short edges of the rectangle and mesh with default element size on the other two long edges.

     

    In the second image(rectangular surface on the bottom right corner) above it can be seen , the element density is 2 on the shortest edges. But I have set the Density1 = 5 in the script.

  • tinh
    tinh Altair Community Member
    edited June 2017

    I found the issue. I did not reset variable LineList

    Just insert below code at begining of script:

    set LineList ''

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2017

    My problem is not completely solved but taking your script as a reference I have written a script. Its working now.

     

    Thank you very much for your help.