<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 2 November 2015 at 21:49, Justin Chang <span dir="ltr"><<a href="mailto:jychang48@gmail.com" target="_blank">jychang48@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">So when would I use one over the other? <br><br>- If I wanted to solve a problem using a direct solver or an iterative solver without a preconditioner, I would use A = J?<br></div></blockquote><div><br></div><div>Yes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>- The documentation for SNESSetJacobian() says that AMat and PMat are usually the same, but if I used something like GAMG would I need to create two different objects/Mats?<br></div></div></blockquote><div><br></div><div>I would say "maybe".<br><br><div>If the Jacobian (here A) was defined via a
matrix-free finite difference approximation, but you wish to use a non-trivial preconditioner, you might wish to assemble J. J might be the Picard linearized operator (for example).<br></div><br>Another
use case where A != J might arise is if you define A with a high order spatial discretization (probably matrix free) and
you use a low order discretization to define the preconditioner which will ultimately be passed to GAMG.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,<br></div><div>Justin<br></div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 1:39 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>Justin Chang <<a href="mailto:jychang48@gmail.com" target="_blank">jychang48@gmail.com</a>> writes:<br>
<br>
> Hi all,<br>
><br>
> In my DMPlex program, I have these lines:<br>
><br>
> Mat A,J;<br>
><br>
> ...<br>
><br>
> ierr = DMSetMatType(dm, MATAIJ); CHKERRQ(ierr);<br>
> ierr = DMCreateMatrix(dm, &J); CHKERRQ(ierr);<br>
> A = J;<br>
><br>
> ierr = DMSNESSetFunctionLocal(dm, ...); CHKERRQ(ierr);<br>
> ierr = DMSNESSetJacobianLocal(dm, ...); CHKERRQ(ierr);<br>
> ierr = SNESSetJacobian(snes, A, J, NULL, NULL); CHKERRQ(ierr);<br>
> ierr = SNESSetFromOptions(snes); CHKERRQ(ierr);<br>
><br>
> ...<br>
><br>
> ierr = SNESSolve(snes, NULL, x); CHKERRQ(ierr);<br>
><br>
> ...<br>
> ierr = MatDestroy(&J); CHKERRQ(ierr);<br>
><br>
><br>
> For the line "A = J;",<br>
<br>
</span>This means you have two handles referring to the same object.<br>
<span><br>
> what exactly is the difference, if any, between that and "ierr =<br>
> MatDuplicate(...)"<br>
<br>
</span>This creates a new object.<br>
<span><br>
> or "ierr = MatCopy(...)"?<br>
<br>
</span>The second argument needs to be a valid Mat to call this function.<br>
<span><br>
> Do these different options somehow affect memory usage/performance?<br>
<br>
</span>Yes.<br>
<div><div><br>
> Say I am solving a standard poisson equation using either GAMG and/or<br>
> HYPRE.<br>
><br>
> Thanks,<br>
> Justin<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>