<div dir="ltr"><span class="gmail-"></span><br><span class="gmail-"></span><div class="gmail_extra"><div class="gmail_quote"><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>
</span> PCMG can actually do this for you if you tell it to use Galerkin so you shouldn't need to do this (with both the "standard" PCMG interface and its use of DM).<br>
<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Sure. I realize if there is a DM on the fine grid, and the DM has the method DMCoarsen(), then galerkin operators can/will be constructed by PCMG if the galerkin flag is set. However, my understanding is that PCMG will create Galerkin operators for on ALL levels (except the finest). <br><br>I wanted to have control over exactly which levels in the hierarchy defined Galerkin operators. I also wanted more control over how the mesh hierarchy was constructed than DMCoarsen() provided, so i found it more convenient to build the mesh hierarchy myself.<br><br></div><div>Cheers<br></div><div> Dave<br></div><div><br> </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-HOEnZb"><font color="#888888">
Barry<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
><br>
><br>
><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>
> Should they be "levels" (numbered?) or named approximations?<br>
><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>
> Presumably. Is a DM a function space, an operator, or both?<br>
><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>
> 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>
><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>
> SNESSetFunction calls DMSNESSetFunction.<br>
><br>
> > Or does one every need "lower order operation evaluation"? Is lower<br>
> > order linearization enough?<br>
><br>
> No, dual-order discretizations are possibly more important for nonlinear<br>
> problems.<br>
><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>
> One common application of lower order discretizations is in in the<br>
> function provided to SNESSetNGS.<br>
><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>
> Yup.<br>
><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>
> 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>
><br>
<br>
</div></div></blockquote></div><br></div></div>