At first I was going to suggest using Python Calculator
, but due to a bug I just found, I expect that won’t work for you.
Until that’s fixed, you’ll probably have to use the Programmable Filter
. You can use that to get the real and imaginary fields from your data as well as the current time from the pipeline. From there, you can compute the instant value of the vibration. Here is an example Script
for the Programmable Filter
:
real = inputs[0].PointData['Real']
imag = inputs[0].PointData['Imag']
executive = self.GetExecutive()
time_value = executive.GetOutputInformation(0).Get(executive.UPDATE_TIME_STEP())
vibrate = real * cos(6.28 * time_value) - imag * sin(6.28 * time_value)
output.PointData.append(vibrate, 'vibrate')
However, that alone won’t do it because you also have to tell the VTK pipeline what time you want. If you don’t, the pipeline won’t give you any time. So, you will need to also set the the RequestInformation Script
(an advanced property). The following RequestInformation Script
sets up 100 time steps between time 0 and time 1.
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
outInfo.Remove(executive.TIME_STEPS())
for i in range(0, 100):
outInfo.Append(executive.TIME_STEPS(), i/100)
outInfo.Remove(executive.TIME_RANGE())
outInfo.Append(executive.TIME_RANGE(), 0)
outInfo.Append(executive.TIME_RANGE(), 1)
Here is an example state file that creates some fabricated data with real and imaginary components and then applies a Programmable Filter
to animate the vibration: vibration-animation-example.pvsm (583.1 KB)