<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 26 February 2017 at 05:30, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> writes:<br>
<br>
>> On Feb 25, 2017, at 7:35 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
>><br>
>> Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> writes:<br>
>>> Do you think this is a reasonable approach or am I missing<br>
>>> something fundamental? I am assuming generally for the "higher<br>
>>> order" DM the Mat it returns is a MATSHELL or a new matrix class<br>
>>> built on "tensor contractions" and that kind of nonsense. I don't<br>
>>> want to do all the coding and then have it turn out that it is<br>
>>> totally useless for CEED etc.<br>
>><br>
>> Well, this is exactly what we do in pTatin.<br>
><br>
> So why didn't you fix it in PETSc at that time?<br>
<br>
</span>I didn't know it "didn't work" because what we were doing did work. (I<br>
think we used PCMG interfaces directly; we were mixing unassembled and<br>
assembled representations, plus Galerkin on coarser levels.)<br></blockquote><div><br><br></div><div>I can confirm that Jed's recollection is correct.<br></div><div><br>The configuration used in ptatin was performed in the context of a non-linear problem. Essentially all the MG setup has conducted during my method for computeJacobian(). The setup / config for the different operators was a little delicate, but the standard PCMG API permitted mixing matrix-free, assembled and Galerkin coarse operators. For the Galerkin case, I performed the call to MatPtAP myself in my computeJacobian() function and would stuff the result into the appropriate KSP defining the smoother.<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">
<span class="gmail-"><br>
>> I would ask, why just two discretizations? I've always thought a better<br>
>> interface would be for Mats (and any other operators/functions) to have<br>
>> optional approximations or supplementary data attached. We can do this<br>
>> with PetscObjectCompose, but that's hard to work with in a structured<br>
>> way. Anyway, I think I would rather just have the Amat with ability to<br>
>> attach one or more Pmats.<br>
><br>
> Understood. I don't like the API as "attach one or more Pmats to a<br>
> Mat" but instead prefer to think of it as a linear operator that has<br>
> one or more "levels of approximation"<br>
<br>
</span>Should they be "levels" (numbered?) or named approximations?<br>
<span class="gmail-"><br>
> that can optionally be indicated; which one you wish to use is up to<br>
> the algorithm using the linear operator. Changing this in PETSc<br>
> would require some conceptional changes and refactoring in<br>
> PETSc. Would simplify things like SNESSetJacobian() because we would<br>
> not need to track mat and pmat. But would not be terribly difficult<br>
> for the PETSc developers or user.<br>
><br>
> If we used this model, instead of adding a new DM to the interface<br>
> do we keep the one DM but have a way to "attach" other "lower order"<br>
> DMs to the that one DM that can be accessed?<br>
<br>
</span>Presumably. Is a DM a function space, an operator, or both?<br>
<span class="gmail-"><br>
> DMCreateMatrix(dm,&mat);<br>
> pmat = mat;<br>
> DMGetLowerDM(dm,&ldm);<br>
> if (ldm) {<br>
> DMCreateMatrix(ldm,&pmat);<br>
> }<br>
> KSP/SNES/TSSetIJacobian(ts,<wbr>mat,pmat,...);<br>
><br>
> more generally DMGetLowerDM(dm,<wbr>PetscOrderIndicater i,&ldm); Similarly MatGetLowerMat(mat,<wbr>PetscOrderIndicater i,&lmat)?<br>
><br>
> ----- an aside<br>
> BTW: this introduces a possible "missing" object in PETSc. We have<br>
> as a fundamental object the Mat which is a linear operator, we do<br>
> not have a fundamental object for a "general" operator, instead we<br>
> accept user provided functions directly (SNESSetFunction(),<br>
> TSSetIFunction() etc). I've resisted the PetscOperator because I<br>
> felt it was overly abstract (and thus confusing to most users) and<br>
> is more difficult to implement cleanly since the operator may depend<br>
> on more than one input vector (TSSetIFunction depends on u and udot;<br>
> would we have a PetscOperator2 that had two input vectors?).<br>
<br>
</span>DMSNES and DMTS effectively provide this, it's just intimately coupled<br>
to the DM. I advocated before for separating these because function<br>
spaces have meaning independent of operators defined on them, but that's<br>
more of a performance consideration that assumes DM implementations<br>
don't have cheap sharing of common data.<br>
<span class="gmail-"><br>
> I did try the PF object but it is very limited and rarely<br>
> used. Certainly I think for a wide class of users, especially Fortran,<br>
> SNESSetFunction() is understandable but<br>
><br>
> PetscOperatorCreate(&operator)<br>
> PetscOperatorSetRawFunction(<wbr>operator, function())<br>
> SNESSetOperator(snes,operator)<br>
><br>
> becomes gibberish and so we would lose many potential users. Of course we could introduce the PetscOperator and maintain the simplicity of the current interface by having things like SNESSetFunction() automatically handle the conversion to the "operator" interface and have a new SNESSetOperator() for the general case. I hate having this kind of "wrapper" code because it usually bit decays over time and I don't like have multiple equivalent interfaces for the same effect (how do you document them, how does the user decide which one to use? I hate perl :-), there should be one way to do each thing).<br>
<br>
</span>SNESSetFunction calls DMSNESSetFunction.<br>
<span class="gmail-"><br>
> Or does one every need "lower order operation evaluation"? Is lower<br>
> order linearization enough?<br>
<br>
</span>No, dual-order discretizations are possibly more important for nonlinear<br>
problems.<br>
<span class="gmail-"><br>
> Currently with mat and pmat we only support lower order linearization,<br>
> we don't for example allow passing a higher order and lower order<br>
> nonlinear function both to SNESSetFunction. If the lower order<br>
> operator is never needed, only the lower order linearization then<br>
> PetscOperator (which would allow managing several orders of general<br>
> operator) would not be needed so API for users is simpler. Or we could<br>
> introduce lower order linear operators now and not worry about lower<br>
> order function evaluations for years? --- end of the aside<br>
<br>
</span>One common application of lower order discretizations is in in the<br>
function provided to SNESSetNGS.<br>
<span class="gmail-"><br>
> I also don't disagree with Matt, should we just "complete" support for two levels of approximation by having proper two DMs for TS/KSP/SNES, see how that goes rather than jumping directly from a (far from perfect since users need to manually do ugly stuff since we only have one DM) two level support (as we currently have) to multilevel support? I won't change the current interface to do this instead I would just add TS/SNES/KSPSetDMs()<br>
<br>
</span>Yup.<br>
<span class="gmail-"><br>
> Imagine poor Ed's book if we suddenly change stuff like this in PETSc :-( So the question is what should/could we do now to improve flexibility without requiring Ed to start all over again? That is, how gradually we need to introduce this kind of overhaul, and with how much backward compatibility?<br>
<br>
</span>I would say quite gradual and with at least a full release cycle of<br>
backward compatibility. And although I think it is ultimately better<br>
for extensibility, I'm not 100% convinced it is worth the cost to users<br>
to overhaul. One nice thing about the current interface is that it<br>
forces people to acknowledge that those two arguments could be<br>
different, so they may read or find examples. If we switch so our<br>
operators have a basket of approximations, lots of users may never learn<br>
about that basket.<br>
</blockquote></div><br></div></div>