[Paraview] Help with Programmable Filter
Dennis Conklin
dennis_conklin at goodyear.com
Mon Aug 4 15:21:20 EDT 2014
I have the following script for a Paraview Programmable filter:
import math
import numpy
#
# Gdyr_Principal_Strains_ProgFilter
# Rev 0
# Aug 1, 2014
# Dennis Conklin - Engineering Mechanics
#
# Paraview 4.0.1 Progammable Filter
# Adds Cell Variables:
# Principal Strains: str_P1, str_P2, str_P3
# max shear strain: tau_max
# These can be used for coloring, Spreadsheet view, formulas, threshold, etc
#
def process_block(block):
#
# Global coordinate strains
# Assume strains loaded in Paraview
xx = block.CellData['USTRTOTXX']
yy = block.CellData['USTRTOTYY']
zz = block.CellData['USTRTOTZZ']
xy = block.CellData['USTRTOTXY']
xz = block.CellData['USTRTOTZX']
yz = block.CellData['USTRTOTYZ']
for i in range(block.GetNumberOfCells()
sigma = numpy.array([ [xx[i],xy[i],xz[i]],
[xy[i],yy[i],yz[i]],
[xz[i],yz[i],zz[i]]
])
# isotropic strain matrix
iso = 1.0/3.0*numpy.trace(sigma)*numpy.eye(3)
# deviatoric strain matrix
dev = sigma - iso
#principal strains
eigvals = list(numpy.linalg.eigvalsh(sigma))
eigvals.sort()
eigvals.reverse()
P1[i] = eigvals[0]
P2[i] = eigvals[1]
P3[i] = eigvals[2]
# max shear
max_shear[i] = (max(eigvals)-min(eigvals))/2.0
block.CellData.append(P1,"P1_strain")
block.CellData.append(P2,"P2_strain")
block.CellData.append(P3,"P3_strain")
block.CellData.append(max_shear,"tauMax")
# Loop over blocks in composite (Exodus) data set
for block in output:
# process each block
process_block(block)
After running this script, no errors or warnings are issued but the additional quantites (taumax, Px_strain) are not present as element quantities.
Any hints as to what I'm doing wrong.
Dennis Conklin, PE
RDE&Q Senior Engineer
Goodyear Innovation Center, 5th Floor South, Pillar M34
Phone: 330-796-5701
Email: dennis_conklin at goodyear.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20140804/ae59f121/attachment.html>
More information about the ParaView
mailing list