Skip to content

WIP: Python reader for VTU files

Gerry AGBOBADA requested to merge vtu_reader into master

Hi everyone,

I added a reader for vtu files in the post-processing part of the tools. This early version needs a little Python editing skills to be used to your convenience, and is really the starting point of a more comprehensive tool, that could be called only from command line.

  • The main loop (in the main function) iterates over any number of vtu files in order to obtain the info and print them to Stdout

  • The main module, read_vtu_field uses re module to detect the beginning of the data block we want to read, and can either :

    • Extract the value of a particular node/cell (so it will be done for every vtu file in the main loop)
    • Aggregate the values of every node/cell to give an average value
  • Note : it explicitly runs on Python3 (Trying to force myself to at least), but I think it will run okay on Python2.6+ with import print from __future__

For the time being I only use it in order to obtain proper comma/tab/space separated values files for further post-processing (matplotlib/gnuplot), and it does this part well enough. Though on top of all the TODOs in the file which will make the module easier to use, developing other features can help a lot :

  • We could create our own sensor, without ModeleCapteur (so we would not need to run new simulations) :
    • Read the mesh in the vtu file
    • Find the closest node/cell, or surrounding points for interpolation (<- can be very long I admit)
    • Run read_vtu_field to filter all files and obtain the correct values, with time in a text file Even if it may be longer to do sensors like this, one advantage is that it runs only on Python, and there's no need to run a whole simulation again.

And even if that's not interesting enough, there's no other vtu_reader in the repo, so there's a common one now at least

Merge request reports

Loading