Save data to python array from Integrate Variables filter

Hi all!

I’m trying to create a synthetic streak tool that will use scalar outputs ‘A’ and ‘B’ from simulation data to get an integrated value over the quantity ‘C’. I do this by first creating a calculator to multiply the ‘A’ and ‘B’ data, creating a ‘C’ result, then using a PlotOverLine filter across the simulation domain, then integrating the data using the IntegrateVariables filter. This produces a single integrated value for C. I want to do this for multiple PlotOverLine filters (lets say N_plot) and store each integrated value to a python array. I then want to do this for every time step in the simulation (N_timesteps), and finally store this in a [N_timesteps x N_points] array.

I’ve added my current script, which works fine, however is incredibly slow, considering N_timesteps and N_points are actually 400 each. It appears that the only way to update all sources and filters with the current timestep data is by using “Show(integrateVariables1)” every time a new integration is performed (refer to attached script), which slows the process considerably. Using UpdatePipeline() doesn’t seem to update the source, and only returns the original timestep value. Can anyone spot a more efficient way of doing this?

Many thanks!

paraview_synthetic_streak.py (1.8 KB)

Hi Niki - I hope you solved (or improved) your issue by now - I found your post in pursuit of getting data from a PlotOverLine filter and you showed me how to do that with your script - so thank you!

In the past in working with time steps I have found this post useful so I keep it bookmarked. I see you are using the animation routine to step over time. I don’t know if this is helping or hurting you for speed, but it makes me think you are doing this work on screen which causes me to worry about speed since you are carrying all the visual pieces with you for all your steps. I step over time to make stuff using PVBATCH which runs in a terminal. When I was figuring this out I had to struggle to get the runtime environment setup right. But I might consider converting to this. Beyond this I would say to you to familiarize yourself with the time parameters of the reader you made in your script like this:

#%% Initialize view
CreateLayout(‘Layout #1’)
renderView1 = FindViewOrCreate(‘RenderView1’, viewtype=‘RenderView’)
SetActiveView(renderView1)

#%%Build pipeline
MED_0 = MEDReader(FileName=os.path.join(INFILEPATH))
SetActiveSource(MED_0)
MED_0Display = Show(MED_0, renderView1)

#show some basic stuff in the log
ArrayStrings=MED_0.AllArrays
timeIndices=MED_0.AllTimeSteps
timeValues = MED_0.TimestepValues

#PrintListToLog is a custom function I wrote - it does what you think
PrintListToLog(ArrayStrings,“Print of ArrayStrings:\n”)
PrintListToLog(timeIndices,“Print of TimeSteps:\n”)
PrintListToLog(timeValues,“Print of TimestepValues:\n”)

After this I think you work with these structures to push indices to “ViewTime” of the active view. So to do this I have a custom function below and then I call it with the loop below that. I think in THAT loop is where all your fancy filtering goes. I would just make the caveat that triggering THOSE to update might cause you problems - and did for me at times I seem to recall - and so you might be creating them / destroying them / creating them again to effect a refresh. If you solve it, please post!!! - Kirk

def UpdateTimeView(time_steps,time_index):
view=GetActiveView()
view.ViewTime = time_steps[time_index]
Render()
return None

for i in timeIndices:
SetActiveView(renderView1)
UpdateTimeView(timeValues,i)
UpdatePipeline()