ParaView/Tricks

From PHASTA Wiki
Jump to: navigation, search

This page contains a list of tips and tricks for ParaView, which may be useful for others.

Difference Between Two Timesteps

To look at the "delta" between two timesteps, follow these steps.

  1. Load your data file twice, so your pipeline browser has two separate instances of "flow.pht" or whatever file you open.
  2. Apply one Force Time filter to each input file, and specify the physical time (not time index) for each. This will force the time for each and make them independent of the global ParaView time control in the upper toolbar.
  3. Select both Force Time filters simultaneously, and apply a Programmable Filter. Your pipeline browser will now show arrows representing multiple inputs to the single programmable filter.
  4. Populate the programmable filter with the following code:
    tmp = inputs[0].PointData['myAvailableFieldName'] - inputs[1].PointData['myAvailableFieldName']
    output.PointData.append(tmp, 'delta of myAvailableFieldName')
  5. You can now view the field, "delta of myAvailableFieldName," and change the time steps it uses to compute the time-delta by modifying the Force Time filter properties.

Example script: relative change in eddy viscosity

s = 'EV'
a = inputs[0].PointData[s]
b = inputs[1].PointData[s]
tmp = (a - b) / b
output.PointData.append(tmp, 'delta')

Stepping Forward in Time

Let's say you load your ParaView file (for PHASTA, *.pht or *.phts) as phtFile. The times associated with each timestep referenced by the file are given by phtFile.TimestepValues.

To step forward in time, set the time of the current view. For example, GetActiveView().ViewTime = myTime. When you save an image, all visible sources will be rendered using data from that time (myTime).

Saving Data at a Given Time

It turns out the data fields you access through Python are not updated simply by setting the active view's ViewTime property. For example, if you're trying to extract data from a probe location or along a line, simply saving that pipeline object does not reflect the updated timestep. Instead, you need to call the UpdatePipeline(time=myTime) method of your ProbeLocation, Slice, or other pipeline object. This method is inherited from SourceProxy.

Visualizing Vortices

Two methods for visualizing vortices are taking iso-surfaces of either Q-criterion or the Omega-criterion (Liu 2016, "New omega vortex identification method"). To compute both, apply "Gradient of Unstructured Dataset" to the velocity field in ParaView, and name the result g. Then enter one of the following expressions into a Calculator, and finally apply a Contour at the appropriate value:

Q-criterion
-g_1*g_3-g_2*g_6-g_5*g_7+g_4*g_8+g_0*(g_4+g_8)
Contour at whatever value shows the features you want; try 1e7 as a starting point, but Q has a huge range of magnitudes
Omega-criterion
(g_1^2 + g_2^2 - 2*g_1*g_3 + g_3^2 + g_5^2 - 2*g_2*g_6 + g_6^2 - 2*g_5*g_7 + g_7^2) / (2 * (g_0^2 + g_1^2 + g_2^2 + g_3^2 + g_4^2 + g_5^2 + g_6^2 + g_7^2 + g_8^2 + 1e-14))
Contour at 0.52 as recommended in the Liu (2016) paper to start; Omega is always between 0 and 1

There is also a third useful metric for visualizing vortices. This is lambda_2 criterion. This process is outlined below.

Lambda_2-criterion
Step 1

First, you will need to compute the velocity gradient vector. This can be done using Paraview's Gradient of Unstructured DataSet filter. Make sure the box labeled Computed Gradient has an x and that the velocity field is set as the Scalar Array. When this is set, click apply.

Step 2

Once the velocity gradient vector is computed, use the Python Calculator filter. In the box labeled expression, type eigenvalue(strain(Velocity)**2 + (Gradients - strain(Velocity))**2). Note that your velocity field may not be called Velocity. If this is the case, change the aforementioned formula accordingly. Also, I recommend calling the Array name lambda opposed to the default result. The lambda_2 values will be the entries in the second column of this computed vector.