ROBOT - API - VB.NET - Performance

ROBOT - API - VB.NET - Performance

Temo_Escudero
Participant Participant
1,220 Views
8 Replies
Message 1 of 9

ROBOT - API - VB.NET - Performance

Temo_Escudero
Participant
Participant

Hi there!

I have a question regarding the performance of extracting information from ROBOT. Maybe the poor performance I am getting is because I am doing something terribly wrong.

What I am trying to do is to extract the finite element information, such as conectivities, labels, and also the nodal information only of the subset of selected FEs.

 

This is an example of a loop over finite elements:

        Dim rbtSel_FEs = Me._robApp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_FINITE_ELEMENT)
        rbtSel_FEs.FromText(listFEs)
        Dim FEsCollection As IRobotCollection = Me._robApp.Project.Structure.FiniteElems.GetMany(rbtSel_FEs)
        Dim iKont As Integer = 0

        For II = 1 To FEsCollection.Count
            iKont += 1
            Dim kFE As IRobotFiniteElement
            kFE = FEsCollection.Get(iKont)
            Dim iFE As ItemFE = New ItemFE
            iFE.ID = kFE.Number
            iFE.N1 = kFE.Nodes.Get(1)
            iFE.N2 = kFE.Nodes.Get(2)
            iFE.N3 = kFE.Nodes.Get(3)

            If (kFE.FeType = IRobotFiniteElementType.I_FET_T3) Then
                iFE.FE_Type = "I_FET_T3"
                iFE.N4 = -1
            ElseIf (kFE.FeType = IRobotFiniteElementType.I_FET_Q4) Then
                iFE.FE_Type = "I_FET_Q4"
                iFE.N4 = kFE.Nodes.Get(4)
            End If

            Me.theFEs.Add(iFE)
        Next

This is the other loop that take ages, 

        For Each iFE As ItemFE In Me.theFEs
            'Nodo 1...
            If (Me.theNodes.posVec(iFE.N1 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N1 - 1) = kPos
                iNode = getNodalInfo(iFE.N1)
                Me.theNodes.Items.Add(iNode)
            End If

            'Nodo 2...
            If (Me.theNodes.posVec(iFE.N2 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N2 - 1) = kPos
                iNode = getNodalInfo(iFE.N2)
                Me.theNodes.Items.Add(iNode)
            End If

            'Nodo 3...
            If (Me.theNodes.posVec(iFE.N3 - 1) = -1) Then
                kPos += 1
                Me.theNodes.posVec(iFE.N3 - 1) = kPos
                iNode = getNodalInfo(iFE.N3)
                Me.theNodes.Items.Add(iNode)
            End If

        Next

    Private Function getNodalInfo(ByVal iNode As Integer) As ItemNode
        Dim nodeToReturn As ItemNode = New ItemNode

        Dim rbtSel_Node = Me._robApp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_NODE)
        rbtSel_Node.FromText(iNode.ToString)
        Dim pointCollection As IRobotCollection = Me._robApp.Project.Structure.Nodes.GetMany(rbtSel_Node)
        Dim iPoint As IRobotNode
        iPoint = pointCollection.Get(1)
        nodeToReturn.ID = iNode
        nodeToReturn.X = iPoint.X
        nodeToReturn.Y = iPoint.Y
        nodeToReturn.Z = iPoint.Z

        Return nodeToReturn
    End Function

 

Also at the begining of the process I am doing this: robApp.Interactive = 0. In such a way I expect the process to finish in like 6 hours to get the info of 69000 FEs and 45000 nodes. The specs of the PC are: 64Gb of RAM and AMD Ryzen 7 2700 Eight-Core.

 

I would kindly appreciate if someone can tell me if in someone's experience this performance I am getting is ridiculously poor. In my experience they are, compared with other pre-processors.

Greetings!

0 Likes
1,221 Views
8 Replies
Replies (8)
Message 2 of 9

rsousa_
Advocate
Advocate

I'm no expert, but I can give you my personal experience.

 

"COM" connections have, in general, very poor perfomance. This is valid for ROBOT, EXCEL and so on... And if if you don't do "special" programming, you don't take advantage of you hardware at all... it only depends on main cpu frequency (you only use one core...). 

 

For example, in Excel, it takes almost same time to read one cell or the entire worksheet... 

 

So, you should always reduce to the minimun these conections to read data. You should go there one time and get all the information at once. 

 

In ROBOT you should try queries and see if you can get all the information you need in one shot.

 

Regards 

Message 3 of 9

Romanich
Mentor
Mentor

Hi @Temo_Escudero ,

 

Romanich_0-1611840795719.png

 

I would definitely recommend you to watch this webinar:

https://www.youtube.com/watch?v=tYvb6IzjNmQ&list=PLY-ggSrSwbZqow_60fiqJwS69mg1nQMzk&index=9

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.

Roman Zhelezniak

Robot Evangelist & Passionate Civil Structural Engineer

LinkedIn | Robot & Хобот | App Store for Robot
EESignature


Message 4 of 9

Stephane.kapetanovic
Mentor
Mentor

An advice,
Declare your variables beforehand, if the definition is known, its type instance does not have to be in the loop.
Why not nest the logic for points and edges in the same loop rather than iterating afterwards. In your case you seems accumulate the time of two successive operations, one for the points, one for the edges, both end to end.
You should also ask yourself why to store all its values ​​and which ones you can do without.
Also, for your nodes, make an array before, it will be easier to index a node of an internal array than to resort to a connection via the API to the ROBOT database.

Have you considered other language which could allow you to use parallel tasks ?

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 5 of 9

Temo_Escudero
Participant
Participant

Hi @rsousa_ ... Thank you for taking the time to answer. Yes, as you suggest I must keep the the 'connections' to a minimum, now I am working on finding out how I do that. Greetings!

0 Likes
Message 6 of 9

Temo_Escudero
Participant
Participant

Hi @Romanich  thank you fot taking the time to answer. Look:

 

  • I was already using robApp.Interactive = false.
  • Watching the webinar the only suggestion that seems to apply is: use collections or whole server.
  • Other recomendations are: Use Cache (to generate geometry), use multyOperatios (to create/edit geometry), use RobApp.Interactive = false (already using).

 

Consider this small piece of code:

Dim allNodes As IRobotCollection
allNodes = Me._robApp.Project.Structure.Nodes.GetAll
Dim iNode As IRobotNode
Dim jNode as ItemNode = New ItemNode

For II = 1 To allNodes.Count
  iNode = allNodes.Get(II)  '<---- TAKES ABOUT 80% OF ALL PROCESS
  jNode.ID = iNode.Number   '      ACCORDING TO VTune.
  jNode.X  = iNode.X
  jNode.Y  = iNode.Y
  jNode.Z  = iNode.Z
Next

 

The question is: is that the right way of extracting such data?  or there is a way so I can manage to perform a 'Get all data at once' and store it in a list. Like this:

 

AllNodalInfo = allNodes.GetAllAtOnce

 

Maybe that's what I am not seeing and I am accessing to the info in the worst way. Greetings!

0 Likes
Message 7 of 9

Temo_Escudero
Participant
Participant

Hi @Stephane.kapetanovic I really appreciate you took the time to answer. Look, let's assume the code is poorly programed (which it is, specially the part to get the nodal information), the thing here is that even that, I was not expecting such execution time. And to be honest the only part I have the patience to execute is to get the finite elements.

 

In my opinion to perform the operations to read information from 69000 FEs and 45000 nodes does not worth the effor to parallelize and to change a programming language.

 

Now I am aware that reading the info in the way I am doing it seems very ineffitient.

 

Changing the approach, now is possible to read the info in like 15-20 minutes. The question is: is that the average time? there is a way of doing it in like 1 minute or less?

0 Likes
Message 8 of 9

Romanich
Mentor
Mentor

Hi @Temo_Escudero ,

 

By the way, in Excel VBA do not forget to use Application.ScreenUpdating = False in the beginning of your macro

Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.

Roman Zhelezniak

Robot Evangelist & Passionate Civil Structural Engineer

LinkedIn | Robot & Хобот | App Store for Robot
EESignature


0 Likes
Message 9 of 9

Stephane.kapetanovic
Mentor
Mentor

hi Temo_Escudero,

 

This topic seems out of scope of using API and concern points clouds, algoritms and langage forums.

Not knowing the performance of your environment and with a langage code like VBA, you have to lighten your code, disconnect everything that can be and choose the indexations with the fewest intermediaries to be ready to treat big volume datas.

On the other hand, you will find here qualified people, with experience by doing professionnal applications, who could help you.
To answer your question, getting 45,000 nodes takes about 5 minutes for my HP ZB i7 SSD with code and a project similar to yours by adding the bars, panels and a progress bar. But changing the way getting them and keeping in mind the trade-off between load times and post processing, you can expect to get them in under 2 minutes.
So, yes, the manner is also strategic here than the speed by a better approach of volume of datas. A good code can rarely be obtained by a first draft.

 

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature