Paraview rotate fields

I am using Paraview 5.0.1. If any solution requires updating, I can try.

I want to programmatically obtain field plots (and corresponding PlotOverLine) of displacements and stresses in rotated coordinate systems.

What are appropriate/convenient/possible ways of doing this?

So far, I have created one Calculator filter for each component of displacements and stresses. For instance, I used Calculators in 2D with results

(displacement.iHat)*cos(0.7853981625)+(displacement.jHat)*sin(0.7853981625)
(stress_3-stress_0)*sin(45.0*3.14159265/180)*cos(45.0*3.14159265/180)+stress_1*((cos(45.0*3.14159265/180))^2-(sin(45.0*3.14159265/180))^2)

It works fine, but it is quite cumbersome, in several aspects:

  1. Creating them (one filter per component).
  2. Plotting several of them in a single XY plot
  3. Exporting them (one export per component).

Is there a simple way to do this?

PS: The Transform filter does not accomplish this. It rotates the view, not the fields.

Upvotes: 2

Views: 1199

Answers (1)

Mathieu Westphal
Mathieu Westphal

Reputation: 2643

Two solutions:

  1. Ugly, inneficient solution

    • Use Transform and check "Transform All Input vectors"
    • Add a calculator and add a dummy array
    • Use transform the other way around, without checking "Transform All Input vectors"
  2. Correct solution : Compute the transformation yourself in a programmable filter

    input = self.GetUnstructuredGridInput();
    output =  self.GetUnstructuredGridOutput();
    output.ShallowCopy(input)
    
    data = input.GetPointData().GetArray("YourArray")
    
    vec = vtk.vtkDoubleArray();
    vec.SetNumberOfComponents(3);
    vec.SetName("TransformedVectors");
    
    numPoints = input.GetNumberOfPoints()
    for i in xrange(0, numPoints):
        tuple = data.GetTuple(i)
        transform(tuple) # implement the transform in python
        vec.InsertNextTuple(tuple)
    
    output.GetPointData().AddArray(vec)
    

Upvotes: 2

Related Questions