<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><br>
</div><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>