🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

control structure

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

hi,

In a macro I written I have 3 for loop nested.

the 1st one iterates for up to 3000 times .so my execution time is long.

Is there any way to reduce time.

 

Thanks and regards,

Mahes

Find more posts tagged with

Sort by:
1 - 14 of 141
    User: "tinh"
    Altair Community Member
    Updated by tinh

    Show us your script please.

    If you just say looping 3000 times is so long then answer is looping 3 times only! 

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Show us your script please.

    If you just say looping 3000 times is so long then answer is looping 3 times only! 

    hm_markclear nodes 1
    hm_createmark nodes 1 'by set' slide5
    set nodelist [hm_getmark nodes 1]
    set setupdate $nodelist
    foreach node $nodelist {
     hm_markclear nodes 1
     hm_createmark nodes 1 $node

     
     set temp [hm_getmark nodes 1]
     hm_markclear nodes 1
     foreach nid $temp {
      set flg [lsearch $nodelist $nid]
      if {$flg >-1} {
       *nodemarkbypath $node $nid 1
       set ls [hm_getmark nodes 1]
       if { [llength $ls]<4 } {
       foreach n $ls {
        
        if { [lsearch $setupdate $n] == -1} {
         
         lappend setupdate $n }
       } }
      }
     }
     
     
     unset temp
     lreplace $nodelist 0 0
          }

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Mahes . What do you want to do?

    You have a set of nodes need to be updated

    You search for adjacent nodes of it

    Then if between it and its adjacents existing less than 4 nodes then you add those to the set.

    If you perform in 2d model, between each node and its adjacent node, there is nothing! What do you want to do with adjacent nodes?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi Mahes . What do you want to do?

    You have a set of nodes need to be updated

    You search for adjacent nodes of it

    Then if between it and its adjacents existing less than 4 nodes then you add those to the set.

    If you perform in 2d model, between each node and its adjacent node, there is nothing! What do you want to do with adjacent nodes?

    hi tinh,

    I have a model built of both hex and shell elements.

    we create some nodal sets.

    in those sets from primary nodes I need to fetch the mid nodes and update the set.

    This one is a part of my macro.

    elements are second order.

    2nd line of code mark nodes by sets.

    those sets only has primary nodes.

     

    Thanks,

    Mahes

    User: "tinh"
    Altair Community Member
    Updated by tinh

    I understand

    From primary nodes, you want to add to the set only mid nodes nearby them, don't you?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    I understand

    From primary nodes, you want to add to the set only mid nodes nearby them, don't you?

    hi tinh,

    yes .

    final set includes both primary and mid nodes.

    is there any other logic other than this.

     

    Thanks,

    Mahes

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Ok

    Do you need to add mid nodes those are inside solid comps? Or only on outer face of solid comps?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Ok

    Do you need to add mid nodes those are inside solid comps? Or only on outer face of solid comps?

    hi tinh,

    No.

    wat I want to do is...

    I will do  the mesh the model which has only 1st order elements.

    from that I will create nodal sets.

    after that I will change all elements to second order.

    By running the macro I will update the set which has the midnodes too.

     

    <?xml version="1.0" encoding="UTF-8"?>1.jpg

    <?xml version="1.0" encoding="UTF-8"?>2.jpg

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Ok, look like you want to add only mid nodes on outer face of solid

    Can't you switch to 2nd then create sets?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Ok, look like you want to add only mid nodes on outer face of solid

    Can't you switch to 2nd then create sets?

    hi tinh,

    Usually for me updates for mesh will come often.

    each time when I want to edit mesh I have to change it to first order.

    So I have do sets again.

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Why dont you create set after all updates?

    Somehow you should take the least effort of machine and man also

    Try arrange your work flow with fewer actions

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Why dont you create set after all updates?

    Somehow you should take the least effort of machine and man also

    Try arrange your work flow with fewer actions

    Hi tinh,

    You are correct.This wat we taught.

    That's a must thing so have to be done .

     

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    :D/emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20' /> I can write a code that helps to select such mid nodes. But I think if you describe detailly your script aim, I can give another strategy that doesn't need to select mid nodes, shorter and faster,...

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    hi tinh,

    I have done with code using entity info of node id in element edges.

    Thanks for the suggestion.

     

     

    thanks,

    mahes