# How to load vtm files from foamToVTK into a pvpython script

**URL:** https://discourse.paraview.org/t/how-to-load-vtm-files-from-foamtovtk-into-a-pvpython-script/16266
**Category:** ParaView Support
**Tags:** python
**Created:** [March 6, 2025, 10:41am UTC](https://discourse.paraview.org/t/how-to-load-vtm-files-from-foamtovtk-into-a-pvpython-script/16266 "2025-03-06T10:41:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lukasWiel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukaswiel/32/6420_2.png) [@lukasWiel](https://discourse.paraview.org/u/lukasWiel)
#### Post date: [March 6, 2025, 10:41am UTC](https://discourse.paraview.org/t/how-to-load-vtm-files-from-foamtovtk-into-a-pvpython-script/16266/1 "2025-03-06T10:41:43Z")

</div>

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:

```auto
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:

```auto
( 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

---

<div class="post-metadata">

### Author: ![lukasWiel](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukaswiel/32/6420_2.png) [@lukasWiel](https://discourse.paraview.org/u/lukasWiel)
#### Post date: [March 6, 2025, 12:10pm UTC](https://discourse.paraview.org/t/how-to-load-vtm-files-from-foamtovtk-into-a-pvpython-script/16266/2 "2025-03-06T12:10:26Z")

</div>

Solved it.

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

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

```

which could then be streamtracered with:

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

```

That should suffice to get this beastie to work 🙂
