I’m trying to implement at programmable filter in which I read in an existing array from an imported solution, then calculate a new array based on an “if” “else” statement. Specifically if a nodal value is greater than zero, I perform a different calculation than if it is negative.
I’m stuck where the code is trying to evaluate the data in the existing array against “>= 0”. I think it may have to do with the fact that the data type is a ‘VTKCompositeDataArray’ and I’m trying to compare it to an integer or float. The snippet below always evaluates >=0 at TRUE even though there are negative values in the solution.
Is there a way I should convert the conditional statement parameters to the same data type, or another/better way to fix this issue? I can’t quite find a solution after searching through the various examples online.
Windows, Paraview v5.9.1
import numpy as np input0 = inputs # Max principle stress midpoint value array Sigma_m = input0.PointData["Stress_maxPrin_Mid"] # Constants numPoints = input0.GetNumberOfPoints() Ct = 1.0 Sut = 1.474*10**9 # New array for output pointArray = np.empty(numPoints,dtype=np.float64) # Iterate through Sigma_m array, populate pointArray according to if/else statement for i in range(numPoints): # the next line is giving the troubles, I believe if Sigma_m[i] >= 0: pointArray[i] = (Ct*Sut*input0.PointData["Stress_maxPrin_Alt"])/(Ct*Sut-input0.PointData["Stress_maxPrin_Mid"]) else: pointArray[i] = input0.PointData["Stress_maxPrin_Alt"] output.PointData.append(pointArray,"Stress_maxPrin_r")