<br><br><div class="gmail_quote">On Fri, Feb 10, 2012 at 12:13 AM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div class="gmail_quote">On Fri, Feb 10, 2012 at 00:05, Dmitry Karpeev <span dir="ltr"><<a href="mailto:karpeev@mcs.anl.gov" target="_blank">karpeev@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>I don't think so.  Preallocating doesn't set any values and seems to leave the matrix marked !assembled.</div>

<div>MatDuplicate for such a matrix will fail.  Assemblying it before setting values (just to force an assembled flag)</div><div>will squeeze out the extra values, won't it?  I think it would just be reasonable to allow to duplicate unassembled</div>





<div>matrices, or, better yet, have a matrix be "assembled" by default until MatSetValues has been called.</div><div>But I'm not sure whether either solution will break something else.</div></blockquote></div>



<br></div><div>Are you calling DMSetMatrixPreallocateOnly()?</div></blockquote><div><br></div><div>So, as I understand, this behavior is reasonable for the use with SNES, since the matrix is assembled with a call to SNES(DM)ComputeJacobian. DMGetMatrix is also used with KSP, when  it is also expected to assemble the matrix.</div>


<div>This seems to make the behavior of DMGetMatrix a bit schizophrenic and dependent on whether it is used from a SNES or a KSP.  Should we try to unify this instead?  One option is to assume that DMGetMatrix (or DMGetOperators) merely preallocates the matrix of a DM-preferred type, while a call to SNESDMComputeJacobian or (the  new method) KSPDMFormOperators, respectively, would actually compute the values and assemble or do the equivalent thing for MF.  In fact, one could unify this behavior already by treating linear problems as nonlinear.</div>

<div><br></div><div>Dmitry.</div><div><br></div><div>Dmitry.</div></div><br>