Dear support,
I am trying to estimate the principal stress from stress and shear stress components using matrix resolution.
This type of resolution cannot be used in a calculator ad thus I wanted to do it using pvbatch:
- loop over all cells
- Solve the matrix for each cell
- Add the result to a new field
- Visualise the new field over the whole domain
Could anyone help me, especially regarding the creation of a new field (cell based) and the filling of said field?
Thank you
PS: long live Paraview
mwestphal
(Mathieu Westphal (Kitware))
2
You want to do that using a programmable filter 
Hello Mathieu,
Thanks for the quick feedback, itâs a nice feature that I didnât know about.
So I gave it a try and I can recover the data I want using the examples.
The only issue I have then is using VTKArray with numpy, due to the format of the data:
How can I convert it to numpy array? I tried np.array on the VTKArray but it failed.
Thank you
Below the script I tried to use
##############################################
Code for âScriptâ
import numpy as np
input0 = inputs\[0\]
#Recover data
sigma_x = np.array(input0.CellData\[âsigma_xxâ\])
sigma_y = np.array(input0.CellData\[âsigma_yyâ\])
sigma_z = np.array(input0.CellData\[âsigma_zzâ\])
tau_xy = np.array(input0.CellData\[âsigma_xyâ\])
tau_yz = np.array(input0.CellData\[âsigma_yzâ\])
tau_xz = np.array(input0.CellData\[âsigma_xzâ\])
#Build the tensor
sigma_tensor = np.array(\[
\[sigma_x, tau_xy, tau_xz\],
\[tau_xy, sigma_y, tau_yz\],
\[tau_xz, tau_yz, sigma_z\]
\])
#Solve the coefficients
I1 = np.trace(sigma_tensor)
I2 = (sigma_x *sigma_y + sigma_y sigma_z + sigma_z sigma_x
- tau_xy\*\****2 - tau_yz**\*\*2 - tau_xz\*\*2)
I3 = np.linalg.det(sigma_tensor)
Note that the Yield Criteria filter could compute the principal stress (but not shear stress):
However there is some assumption regarding the tensor itself, see : Pb with YieldCriteria Filter
1 Like