From bdf to vtk file

114 views
Skip to first unread message

Emanuele Cannizzaro

unread,
Feb 27, 2020, 3:24:02 AM2/27/20
to pyNastran Discuss
Hello pynastran users
Is it possible to convert a nastran bdf file into a vtk file for 3d visualisation?

If so, what steps shall I follow?

Thank you
Emanuele

Michael Redmond

unread,
Feb 27, 2020, 6:43:10 AM2/27/20
to pynastra...@googlegroups.com
Emanuele,

Take a look at the file below.  It's a simple file and you should be able to fit it to your needs. 



--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pynastran-discuss/e8d76951-5073-4864-a165-b27aa4cf2efd%40googlegroups.com.

Steven Doyle

unread,
Feb 27, 2020, 3:09:16 PM2/27/20
to pyNastran Discuss
Emanuele,

There are two other options you might consider:

1:  This option only supports nodal results (displacement, velocity, acceleration, eigenvector) results and a limited set of elements.  I'm not familiar enough with Paraview to understand how results should be generated for mixed element result types (e.g., solid elements don't have plate stresses).  Paraview has a Nastran option, but it's definitely not well supported or robust.

>>> from pyNastran.op2.export_to_vtk import export_to_vtk_filename
>>> bdf_filename = 'model.bdf' 
>>> op2_filename = 'model.op2'  
>>> vtk_filename = 'model.vtk'   
>>> export_to_vtk_filename(bdf_filename, op2_filename, vtk_filename,
                           debug=False, log=None)

2:  I far prefer using pyNastranGUI.  It's nice in that it understands the Nastran data.  It creates VTK objects under the hood.  It's pretty self-explanatory.  https://pynastran-git.readthedocs.io/en/latest/quick_start/gui.html

If you're using the master,  there are now multiple options to speed things up if you're not interested in them (e.g., element quality, showing material coordinate systems for different plies). Many more OP2 results can now be shown (e.g., plate stress, solid stress, rod stress vs. simply stress) and even supports complex fringe results.  The custom results now also supports missing nodes/elements.

Steve

marco.g...@gmail.com

unread,
Sep 30, 2020, 10:17:19 AM9/30/20
to pyNastran Discuss
Hi Emanuele, Steve and Michael.
Emanuele,
sorry for my delay.
If you need a .vtk file you have to use export_to_vtk.py (which is called in export_to_vtk_filename.py) script to make pyNastran translate the .op2 file, as Steve wrote (Steve is quite skilled about PyNastran isn't he?).
Notice that the export_to_vtk.py has a minor issue (in the release I'm using) while translating elements which don't have a pre-definited number of nodes (for example celas may have one or two nodes, and chexas may have 8 or 20 nodes). In these cases the script may create a wrong .vtk, causing Paraview to fail while reading the vtk file (gmsh is able to read the uncorrect .vtk in any case). I modified the script, by forcing it to check the number of nodes of each element but that resulted in a much slower program (expecially if the nastran model is big).
Other aspect regards the result data. For what concerns the displacements, I modified the script making it create a VECTOR results in vtk (it is just a cosmetic improvement).
For element results, which are not translated by the original script, I added some lines to make the script write them. It seems to work for simple cases (I tested for example the static_solid_shell_bar example of pyNastran), also for composites but please do not considered it as fully working and always double check the .vtk. The element results in .vtk file must be similar to the results in .f06 file so just check the f06 file (you can re-create it with write_f06.py). Consider that you may have hundreds of datasets in the .vtk. Remember to back-up the original script!
I attached the modified export_to_vtk.py. In my python installation (portable winpython) I had to place it in C:\WPy64-3850\python-3.8.5.amd64\Lib\site-packages\pyNastran\op2\ to my make it work. I hope it can be useful.
Thanks to Steve for his wonderful pyNastran!
Regards,
Marco
export_to_vtk.py

Emanuele Cannizzaro

unread,
Oct 2, 2020, 2:53:04 PM10/2/20
to pynastra...@googlegroups.com
Thank you, Marco.

--
You received this message because you are subscribed to a topic in the Google Groups "pyNastran Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pynastran-discuss/ASVDHvo4TrM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pynastran-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pynastran-discuss/9a5fb25e-56fc-41f7-b256-c3cb13f52c0bn%40googlegroups.com.

marco.g...@gmail.com

unread,
Mar 11, 2021, 6:15:42 AMMar 11
to pyNastran Discuss
Hi Emanuele, Steve and Michael.
I realized that, in the file I posted on September 30th, there was a seroius bug in translating solid results. I'm really sorry for that and I hope I did not make you wast time.
I attach now a new corrected version of the file.
The script has still some limits: it does not assemble results for different topologies (first "to do") but create one set for tria, one for quad etc (you can easily do that in paraview);  the script does not assemble the results in tensor (second "to do").
I hope it can be useful.
Best regards
Marco

export_to_vtk.py
Reply all
Reply to author
Forward
0 new messages