Get positions of FEA nodes in pychrono

45 views
Skip to first unread message

Maksym Riabov

unread,
Nov 25, 2024, 7:17:14 PM11/25/24
to ProjectChrono
Hello Chrono,
I've ran into the problem that it seems impossible to extract ChNodeFEAxyz positions from pychrono.
The obvious thing would be: 
```
 for ch_node in ch_mesh.GetNodes():
               position = ch_node_xyz.GetPos()
```
But GetNodes returns ChNodeFEAbase which does not contain xyz position.
I've tried typecasting, like this: ```
for ch_node in ch_mesh.GetNodes():
                ch_node_xyz: fea.ChNodeFEAxyz = fea.CastToChNodeFEAxyz(ch_node)
                # ch_node = ch_mesh.GetNode(ch_node.GetIndex()) #and something like this, hoping that it would return ChNodeFEAxyz
                position = ch_node_xyz.GetPos()
``` But the `ch_node_xyz.x`, `.y`, `.z` returns `nan`.
So, what can we do get positions of each node?
My usecase: given known AABB positions, find ones which a specific mesh intersects. I believe it's possible to do through creating a separate CollisionSystem instance and attempting to run it separately (I don't know if it's possible), but then AABBs intersect that too.

Is it possible to solve this in PyChrono? Examples only export positions for visualization and that's not what I need.
Thank you,
Maksym

Maksym Riabov

unread,
Nov 27, 2024, 4:27:59 AM11/27/24
to ProjectChrono
Hello folks.
I'm completely blocked by this. Any simple way of solving it? It should be via a single command or such.
Or is this a bug that needs fixing?

Radu Serban

unread,
Nov 30, 2024, 4:02:41 AM11/30/24
to ProjectChrono

Hi Maksym,

 

The joys of wrapping C++ in Python!  You need to do something like:

    my_node = fea.CastToChNodeFEAxyz(fea.CastToChNodeFEAbase(mesh.GetNode(1)))

    print("t = ", sys.GetChTime(), "  ", my_node.GetPos())

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/projectchrono/40c97670-6dfd-444c-9d2e-21619d1f48dan%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages