<div dir="ltr"><div>I get <b>significantly </b>different results from backslash and petsc using the <b>same matrix</b>.<br></div><div><div><br><div><font face="courier new, monospace">                 Deflection  |Au-b|/|b|</font></div>

<div><font face="courier new, monospace">Euler-Bernoulli:       4000</font></div><div><font face="courier new, monospace">Petsc:                 4386        0.3</font></div><div><font face="courier new, monospace">Matlab:                4013    </font><span style="font-family:'courier new',monospace">1.6e-10</span></div>

</div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>I'm exporting to 6 significant figures. Condition number is rather poor (~2e7) but I get similar or worse results with problems having lower conditions numbers (~1e3).<br>
</div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 8 July 2014 18:44, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.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"><div class="gmail_extra"><div class="gmail_quote"><div>On Tue, Jul 8, 2014 at 8:28 AM, Andrew Cramer <span dir="ltr"><<a href="mailto:andrewdalecramer@gmail.com" target="_blank">andrewdalecramer@gmail.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"><div>Doing a basic cantilever bending problem to test my code which results in the linear system Au = b.</div>


<div><br></div><div> - Using DMDA for the domain and <span style="color:rgb(0,0,0);font-size:14px"><font face="trebuchet ms, sans-serif">KSPSetComputeOperators</font></span></div>
<div> - Solving it using various methods in petsc gets similar (within 1%) solutions</div><div> - Even using -pc_type lu</div><div> - Using <font face="courier new, monospace">KSPGetOperators</font> and <font face="courier new, monospace">KSPGetRhs</font><font face="arial, helvetica, sans-serif"> to export to matlab</font></div>



<div><br></div><div>Exporting the matrix and and the rhs, importing them into matlab  and solving with backslash gives a solution which matches the Euler-Bernoulli beam model much closer (0.4% error vs 9.6%).</div></div>


</blockquote><div><br></div></div><div>As Karl says, this is probably truncation error, but more to the point this is accidental. You would not expect</div><div>a solution that is more accurate than the discretization error. If you are comparing a discrete solution to a</div>


<div>continuous solution, you want to look at "mesh convergence" meaning that you run on a series of refined</div><div>meshes, calculate the error, and usually plot log(error) against mesh size h.</div><div><br>


</div><div>    Matt</div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Calculating the residual of petsc's solution using matlab <font face="arial, helvetica, sans-serif">(</font><font face="courier new, monospace">norm(A*u-b)/norm(b)</font>) I get 0.3 having solved with <font face="courier new, monospace">-pc_type lu</font>.</div>



<div><br></div><div>Is there a way I could have accidentally made petsc solve a different problem to Ax=b? I've been looking at this code for a while now (days) and can't seem to figure out what is wrong.</div></div>



</blockquote></div></div><span><font color="#888888"><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
</font></span></div></div>
</blockquote></div><br></div></div>