Home › Forum › SOFA › Using SOFA › [SOLVED] Exporting files using Monitor
- This topic has 6 replies, 2 voices, and was last updated 4 years, 9 months ago by Sarah.
-
AuthorPosts
-
12 March 2020 at 16:23 #15391SarahBlocked
I’m in the process of wanting to extract data from my simulation. However, am having a hard time extracting the data I need. In particular, I would like to export the position, the forces, and velocities of a single node. Furthermore, I was considering extracting data such as the volume of an object or the total applied pressure.
For the forces, positions and nodes I was wanting to use the ‘Monitor’ object as described here: https://www.sofa-framework.org/community/doc/using-sofa/advanced-features/monitoring/
In the GUI these elements were clearly visualized but when trying to export them I could not trace them in them back in the Sofa directory. Also not following the rule given (your_monitor_component_name+_x.txt). Is there a way to set the directory of where these files should be stored. And are there any other steps neccesary to initiate the export of these files?“Export states as gnuplot files” is checked in the Stats tab of the GUI. The four files this produces are properly exported, but the ones I hope to store using ‘Monitor’are not.
Further alternative methods to export these values, also for the pressure and volume would be appreciated!
17 March 2020 at 18:06 #15424HugoKeymasterHi @sarah
Welcome on the forum!
Sorry for the delay, we needed to setup due to Covid19.Are you using XML or Python file for defining your simulation?
When would you like this export to happen? How would you like to get this export (as a file)?Depending on your needs, I will provide you the best option.
Best,Hugo
18 March 2020 at 09:39 #15478SarahBlockedNo problem, I can imagine it may cause some delays.
I’m using a python file for my simulation. And would like the exports to happen when I end the animation. And preferably as a txt or csv file so I can use them to plot the data.
Thank you very much!
Sarah18 March 2020 at 16:22 #15499HugoKeymasterHi @sarah
Using python you have plenty of possibility.
Two options here:- in your python script, you can use a VTKExporter specifying the filename and exportAtEnd=”1″ and when the simulation will close, a file will be generated (vtk/vtu format can be visualize with Paraview)
node.createObject('VTKExporter', name='exporter', filename='my_output_filename', position='@MechanicalObject.position', pointsDataFields='@MechanicalObject.velocity')
- when you want your simulation to stop (t=xx s), you can directly access the mechanical object of interest and get the value of its position, velocity, force datafield. There, you can export it as csv (example)
I hope this helps
Hugo
19 March 2020 at 12:06 #15501SarahBlockedI found that the monitor is working rahter well now. It exports all the files in the bin and only takes the data points I’m concerned with. The VTKExportr is currently running but consistently exports at the beginning and not at the end even when setting exportAtEnd=”1″, which isn’t very helpful when wanting look at the animation. The gnuplots export well in SOFA. So, I think I’ve found what I’m looking for for now. Despite not having VTKExport doing exactly what I would want yet, I was able to retrieve the data I was looking for. Thank you for the tip!
19 March 2020 at 18:07 #15502HugoKeymasterHi @sarah
Great to hear that you got the monitor to work.
However, the VTKExporter should be working fine. It is validated and stable, I just gave it a try myself. Maybe some data were wrongly defined. In case you need it later, do not hesitate to rely on the example scene: examples/Components/misc/VTKExporter.scnShall we close the topic?
Best wishes,
Hugo
19 March 2020 at 20:30 #15503SarahBlockedYou’re right, I got it to work in the example. But haven’t invested a lot of time to further apply it to my simulation. Thanks
- in your python script, you can use a VTKExporter specifying the filename and exportAtEnd=”1″ and when the simulation will close, a file will be generated (vtk/vtu format can be visualize with Paraview)
-
AuthorPosts
- You must be logged in to reply to this topic.