ansys / pyrocky

A Python API for Ansys Rocky
https://rocky.docs.pyansys.com/
MIT License
4 stars 1 forks source link

GetGridFunction in RAWall Object critically limited #112

Closed florianreinle closed 1 week ago

florianreinle commented 1 week ago

πŸ” Before submitting the issue

🐞 Description of the bug

Postprocessing like this works fine (like in the examples):

particles = Study.GetParticles() velocity_gf = particles.GetGridFunction("Velocity : Translational : Absolute")

BUT with:

geometry_workpiece = Study.GetGeometry(geometry_name) GF = np.array(geometry_workpiece.GetGridFunction(GF_name).GetArray())

Sadly only those Grid Functions are available:

Available: Coordinate : Nodal : Z Area : Cell Coordinate : Nodal : X Area : Nodal Coordinate : Nodal : Y

So no time depended values available, which are necessary for post processing like "Duration : Mean", "Stress : Normal" and many, many more.

If I try:

wall = Study.GetWallFromFilename(geometry_name) wall = wall[0] # since we get a list wall_duration = wall.GetGridFunction("Duration : Mean")

to get the object with another way same issue occurs. HasResults and RefreshResult was also used for double check.

πŸ“ Steps to reproduce

  1. Run any simulation with a wall that should gathet results
  2. Try accessing GetGridFuction not on particles but walls like e.g. "Duration : Mean"

πŸ’» Which operating system are you using?

Linux

πŸ“€ Which ANSYS version are you using?

Ansys Rocky 22R2

🐍 Which Python version are you using?

3.12

πŸ“¦ Installed packages

#ansys-rocky-core==0.2.0
matplotlib==3.6.3
mpmath==0.0.0
msgpack==1.0.3
numpy==1.26.4
pandas==2.1.4+dfsg
pymeshlab==2023.12.post1
Pyro5==5.15
redis==5.1.1
trimesh==4.4.9
zstd==1.5.5.1
viniciusdaroz commented 1 week ago

Dear @florianreinle,

Try following the code snippet below:

import ansys.rocky.core as pyrocky
rocky = pyrocky.launch_rocky()
project = rocky.api.OpenProject("Path/to/rocky_project.rocky")
geometry = project.GetStudy().GetGeometryCollection().GetGeometry("wall_name")
gf_names = geometry.GetGridFunctionNames()

I tested it here with PyRocky 0.2.0 (the latest release) and Rocky 24.2. PyRocky is able to access both static and transient grid functions on walls. To access any array at any given output, say the 20th:

gf = geometry.GetGridFunction("grid_function_name").GetArray(time_step=20)

The code structure should follow the same as in https://developer.ansys.com/docs/prepost-scripting-2024-r2/RAStudy.md

florianreinle commented 1 week ago

Dear @viniciusdaroz

Thank you so much! Now it works. In my case GetGeometryCollection() was not necessary. There was a mistake in the module setup so no result data available even if simulation was run. (I'm working a lot with automated simulations ATM). There was a chain of old mistakes/assumptions and communication errors with project partners involved. Your advice helped making me look for the right things:-) And what matters, it works now!

Thanks for the help and Greetings Florian