P.S.

P1, P2, P3 and max_shear are each just scalar numbers (value of Principal 
strains) - the P1[] is just a value for each element in the block


Dennis Conklin, PE
RDE&Q Principal Engineer
Goodyear Innovation Center, 5th Floor South, Pillar M34
Phone:  330-796-5701
Email:  dennis_conk...@goodyear.com
________________________________
From: Casey Goodlett <casey.goodl...@kitware.com>
Sent: Tuesday, August 12, 2014 5:26 PM
To: Dennis Conklin
Cc: paraview@paraview.org
Subject: Re: [Paraview] Help with Programmable Filter

Hi Dennis,

I took a look at the filter to see what might be wrong, but I seem to be 
missing a couple of things:

1) Are you using the "Copy Arrays" option of the programmable filter? Otherwise 
you will need to reference the input data as well.

2) Where are the P1,P2,P3, etc vectors created?  What type are they?

The below script worked for me if Copy Arrays is enabled.  I used the can.ex2 
example dataset from paraview and ensured the "Object Ids" cell data was 
selected in the reader.


for oblock in output:

   oid = oblock.CellData['ObjectId']

   o2 = oid + 10

   oblock.CellData.append(o2, 'newdata')

Hope that helps


On Mon, Aug 4, 2014 at 3:21 PM, Dennis Conklin 
<dennis_conk...@goodyear.com<mailto:dennis_conk...@goodyear.com>> wrote:

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<tel:330-796-5701>
Email:  dennis_conk...@goodyear.com<mailto:dennis_conk...@goodyear.com>

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview




--
Casey B. Goodlett, Ph.D.
Technical Leader
Kitware, Inc. - North Carolina Office
http://www.kitware.com
(919) 969-6990 x310
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to