<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:14pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>P.S.<br>
</p>
<p><br>
</p>
<p>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<br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
Dennis Conklin, PE<br>
RDE&Q Principal Engineer<br>
Goodyear Innovation Center, 5th Floor South, Pillar M34<br>
Phone: 330-796-5701<br>
Email: dennis_conklin@goodyear.com<br>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Casey Goodlett <casey.goodlett@kitware.com><br>
<b>Sent:</b> Tuesday, August 12, 2014 5:26 PM<br>
<b>To:</b> Dennis Conklin<br>
<b>Cc:</b> paraview@paraview.org<br>
<b>Subject:</b> Re: [Paraview] Help with Programmable Filter</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>Hi Dennis,<br>
<br>
I took a look at the filter to see what might be wrong, but I seem to be missing a couple of things:<br>
<br>
</div>
1) Are you using the "Copy Arrays" option of the programmable filter? Otherwise you will need to reference the input data as well.<br>
<br>
</div>
2) Where are the P1,P2,P3, etc vectors created? What type are they?<br>
</div>
<div><br>
</div>
<div>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.<br>
</div>
<div><br>
<p style="margin:0px; text-indent:0px">for oblock in output:</p>
<p style="margin:0px; text-indent:0px"> oid = oblock.CellData['ObjectId']</p>
<p style="margin:0px; text-indent:0px"> o2 = oid + 10</p>
<p style="margin:0px; text-indent:0px"> oblock.CellData.append(o2, 'newdata')</p>
<br>
</div>
Hope that helps<br>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Aug 4, 2014 at 3:21 PM, Dennis Conklin <span dir="ltr">
<<a href="mailto:dennis_conklin@goodyear.com" target="_blank">dennis_conklin@goodyear.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr" style="font-size:14pt; color:#000000; background-color:#ffffff; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>I have the following script for a Paraview Programmable filter:<br>
</p>
<p><br>
</p>
<div>import math</div>
<div>import numpy</div>
<div><br>
</div>
<div>#</div>
<div># Gdyr_Principal_Strains_ProgFilter</div>
<div># Rev 0</div>
<div># Aug 1, 2014</div>
<div># Dennis Conklin - Engineering Mechanics</div>
<div># </div>
<div># Paraview 4.0.1 Progammable Filter</div>
<div># Adds Cell Variables:</div>
<div># Principal Strains: str_P1, str_P2, str_P3</div>
<div># max shear strain: tau_max</div>
<div># These can be used for coloring, Spreadsheet view, formulas, threshold, etc</div>
<div>#</div>
<div>def process_block(block):</div>
<div> #</div>
<div> # Global coordinate strains</div>
<div> # Assume strains loaded in Paraview</div>
<div> xx = block.CellData['USTRTOTXX']</div>
<div> yy = block.CellData['USTRTOTYY']</div>
<div> zz = block.CellData['USTRTOTZZ']</div>
<div> xy = block.CellData['USTRTOTXY']</div>
<div> xz = block.CellData['USTRTOTZX']</div>
<div> yz = block.CellData['USTRTOTYZ']</div>
<div><br>
</div>
<div> for i in range(block.GetNumberOfCells()</div>
<div> sigma = numpy.array([ [xx[i],xy[i],xz[i]],</div>
<div> [xy[i],yy[i],yz[i]],</div>
<div> [xz[i],yz[i],zz[i]]</div>
<div> ])</div>
<div><br>
</div>
<div> # isotropic strain matrix</div>
<div> iso = 1.0/3.0*numpy.trace(sigma)*numpy.eye(3)</div>
<div> # deviatoric strain matrix</div>
<div> dev = sigma - iso</div>
<div> </div>
<div> #principal strains</div>
<div> eigvals = list(numpy.linalg.eigvalsh(sigma))</div>
<div> eigvals.sort()</div>
<div> eigvals.reverse()</div>
<div> P1[i] = eigvals[0]</div>
<div> P2[i] = eigvals[1]</div>
<div> P3[i] = eigvals[2]</div>
<div> # max shear</div>
<div> max_shear[i] = (max(eigvals)-min(eigvals))/2.0</div>
<div> </div>
<div> block.CellData.append(P1,"P1_strain")</div>
<div> block.CellData.append(P2,"P2_strain")</div>
<div> block.CellData.append(P3,"P3_strain")</div>
<div> block.CellData.append(max_shear,"tauMax") </div>
<div><br>
</div>
<div><br>
</div>
<div># Loop over blocks in composite (Exodus) data set</div>
<div>for block in output:</div>
<div> # process each block</div>
<div> process_block(block) </div>
<div><br>
After running this script, no errors or warnings are issued but the additional quantites (taumax, Px_strain) are not present as element quantities. <br>
</div>
<div><br>
</div>
<div>Any hints as to what I'm doing wrong.<br>
</div>
<p><br>
</p>
<div>
<div name="divtagdefaultwrapper">Dennis Conklin, PE<br>
RDE&Q Senior Engineer<br>
Goodyear Innovation Center, 5th Floor South, Pillar M34<br>
Phone: <a href="tel:330-796-5701" value="+13307965701" target="_blank">330-796-5701</a><br>
Email: <a href="mailto:dennis_conklin@goodyear.com" target="_blank">dennis_conklin@goodyear.com</a><br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">
http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div dir="ltr">Casey B. Goodlett, Ph.D.<br>
Technical Leader<br>
Kitware, Inc. - North Carolina Office<br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
(919) 969-6990 x310</div>
</div>
</div>
</div>
</body>
</html>