Unable to change filter timestep in python/pvbatch

I have been trying to write a batch script in python/pvbatch that would

  • probe a location from an openfoam case.
  • Read its velocity and pressure data
  • Save the data onto a numpy array
  • loop over all time steps of the case

Though for some reason I am not able to loop over all the time steps.

Here is a simplified version of my code: https://pastebin.com/8iyyqibC

I would have thought that using

TimeKeeper.Time = 0.33

Note in the code that is written tk.Time = 0.33

Would be enough to change the probeLocation1 dataset to a new time step… but apparently that does not seem to be the case.

What am I missing? I thought this would be a trivial script but I am at my wit’s end.

Thanks in advance for your help

I know you said that was a simplified case but the first thing that jumps out at me is that you are explicitly setting the time. You already have a handle to the timesteps through times = tk.TimestepValues so you should set the time like tk.Time = times[1]

As far as the time looping goes, the full code shouldn’t be much different from a simplified version. Just some code pushed under a for loop.

You might need a general UpdatePipeline() or Render() call as well.

Hi,

thanks for takijng the time to answer.

This bit of code was a based off a trace I took.

I have not yet implemented a loop, as I thought I would not add any more complexity if I could not even manually switch the time affectively. The trace seemed to suggest that tk.Time = was the way to go. But either this is not the case or there is a bug.

I have probeLocation1.UpdatePipeline() on line 55, so I doubt it will do anything or maybe I am using it wrong.

As for Render(), I thought that was just used to force a redraw/render to a viewport. Since this is strictly in the command line with no viewport, I thought it would not do anything. In fact, I just tested it and it gives an error if used.

So, the question still remains, how would I go about changing the time to location probe data?

I’ve never used the OpenFOAMReader but can you set the time on the reader itself?

I don’t think so, if it is possible, it is not obvious to me.

You could also try using the animation scene like:

scene = GetAnimationScene()
scene.GoToNext()

I am afraid that did not work