How to load vtm files from foamToVTK into a pvpython script

Dear more experienced and knowledgeable friend,

I have run a model in openFoam, and used foamToVTK to generate vtm files (somehow it did not generate a vtk file).
I wish to postprocess this model automatically (as in reality there are hundreds of these runs that I prefer not to do by hand).
Post processing involves computing the streamtracers and computing some of their properties
To do this, I have ran a trace in the ParaView GUI (started with paraFoam) and done this my hand.
The trace gave me the following script:

from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
porousFlowfoam = GetActiveSource()
streamTracer1 = StreamTracer(registrationName='StreamTracer1', 
                                                  Input=porousFlowfoam,
                                                 SeedType='Line')

and then it proceeds with setting up the member variables of streamTracer1.
When I run this script on its own from the shell (as opposed to in the GUI), I get a:

( 2.005s) [paraview ]vtkDemandDrivenPipeline:675 ERR| vtkPVCompositeDataPipeline (0xfa50b0): Input port 0 of algorithm vtkPStreamTracer (0xeb17f0) has 0 connections but is not optional.

which I suppose makes sense, because in the shell there is no data loaded, so no active sourceā€¦ I guess?

I followed documentation and replaced the GetActiveSource() command by

porousFlowfoam = LegacyVTKReader(FileNames=['VTK/meshMaker_2.vtm'])

That vtm file contains links to the data I need. Reading this vtm gives me:

(   2.433s) [paraview        ]  vtkPDataSetReader.cxx:134    ERR| vtkPDataSetReader (0xeb6630): This does not look like a VTK file: VTK/meshMaker_2.vtm
(   2.436s) [paraview        ]  vtkPDataSetReader.cxx:170    ERR| vtkPDataSetReader (0xeb6630): Unknown data type.
(   2.436s) [paraview        ]       vtkExecutive.cxx:729    ERR| vtkPVCompositeDataPipeline (0xf056d0): Algorithm vtkFileSeriesReader (0xf037a0) returned failure for request: vtkInformation (0xf04f70)
  Debug: Off
  Modified Time: 95518
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA_OBJECT
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0

Am I bamboozled by the subtle differences between vtk and vtm files?

Is there somewhere documentation that I missed, explaining how to let a pvpython script read in output of foamToVTK?

Thanks a lot,

Lukas

Solved it.

The trick was to start the Trace before loading the vtm files. This gave me a nice:

meshMakervtmseries = XMLMultiBlockDataReader(registrationName='meshMaker.vtm.series', 
FileName=['/path/to/meshMaker.vtm.series'])

which could then be streamtracered with:

streamTracer1 = StreamTracer(registrationName='StreamTracer1', Input=meshMakervtmseries,
    SeedType='Line')

That should suffice to get this beastie to work :slight_smile: