On Mon, Oct 29, 2012 at 10:44 AM, Brad Aagaard <span dir="ltr">&lt;<a href="mailto:baagaard@usgs.gov" target="_blank">baagaard@usgs.gov</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Scott,<br>
<br>
At this point, OutputSolnPoints only works with the solution:<br>
displacement or velocity field.<br>
<br>
Here is a simple procedure to extract values from the closest cell to a<br>
target location. This is a vectorized calculation so it is relatively fast.<br>
<br>
1. compute the centroids of all of the cells<br>
   For 4 vertices per cell:<br>
     centroids = 1.0/4.0*(vertices[cells[:,0]] +<br>
                 vertices[cells[:,1]] +<br>
                 vertices[cells[:,2]] +<br>
                 vertices[cells[:,3]])<br>
2. calculate the distance of the centroids from the target point<br>
   dist = ((centroids[:,0]-targetX)**2 +<br>
           (centroids[:,1]-targetY)**2 +<br>
           (centroids[:,2]-targetZ)**2)**0.5<br>
3. get the index of the cell with the minimum distance<br>
   mindist = numpy.min(dist)<br>
   index = numpy.where(dist &lt;= mindist + 0.001)[0][0]<br></blockquote><div><br></div><div>Note that you can use argmin() here:</div><div><br></div><div><a href="http://www.scipy.org/Numpy_Example_List#head-c5cb8edfa80e6de8f6eb6b267253d29dff7f8369">http://www.scipy.org/Numpy_Example_List#head-c5cb8edfa80e6de8f6eb6b267253d29dff7f8369</a></div>
<div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
4. extract the values using the index<br>
   stressTarget = stress[index,:]<br>
<span class="HOEnZb"><font color="#888888"><br>
Brad<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 10/28/12 4:01 PM, Scott Henderson wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I&#39;m using Pylith for a simple 2D fracture mechanics problem. I&#39;m<br>
&gt; wondering if it&#39;s possible to output average stress solutions at<br>
&gt; specified points with the OutputSolnPoints utility? If not, is there an<br>
&gt; easy way to extract stress from the element that contains a particular<br>
&gt; (x,y) coordinate (with h5py)? Or maybe it is possible to have Pylith<br>
&gt; output the coordinates of quadrature points?<br>
&gt;<br>
&gt; Any tips would be appreciated,<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Scott<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div><div class="HOEnZb"><div class="h5">&gt; _______________________________________________<br>
&gt; CIG-SHORT mailing list<br>
&gt; <a href="mailto:CIG-SHORT@geodynamics.org">CIG-SHORT@geodynamics.org</a><br>
&gt; <a href="http://geodynamics.org/cgi-bin/mailman/listinfo/cig-short" target="_blank">http://geodynamics.org/cgi-bin/mailman/listinfo/cig-short</a><br>
&gt;<br>
<br>
_______________________________________________<br>
CIG-SHORT mailing list<br>
<a href="mailto:CIG-SHORT@geodynamics.org">CIG-SHORT@geodynamics.org</a><br>
<a href="http://geodynamics.org/cgi-bin/mailman/listinfo/cig-short" target="_blank">http://geodynamics.org/cgi-bin/mailman/listinfo/cig-short</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>