<div dir="ltr">Thank you very much Barry.<div><span style="font-size:12.8px">Apparently I missed many things about "DMShell..." that I didn't find in the current users manual, and I was trying to create the operators through matCreateShell() and MatShellSetOperation().</span><br></div><div><span style="font-size:12.8px">If I use "</span><span style="font-size:12.8px">DMShellSetCreate..." to define the matrices I shouldn't have any doubt about the da to refer to. </span></div><div><br></div><div>Now I can go on. </div><div>Thank you again.</div><div><br></div><div>Best,</div><div>Valeria</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-size:12.800000190734863px"><font color="#666666">---------------------------------------------------------------------------------------------<span style="background-color:rgb(255,255,255)"><br></span></font></div><div style="font-size:12.800000190734863px"><font color="#666666"><span style="background-color:rgb(255,255,255)">PhD Valeria Mele</span><br><br>University of Naples Federico II</font></div><div style="font-size:12.800000190734863px"><font color="#666666">Department of Mathematics and Applications "R. Caccioppoli"<br></font></div><div style="font-size:12.800000190734863px"><font color="#666666">Complesso Universitario M.S. Angelo, Via Cinthia<br></font></div><div style="font-size:12.800000190734863px"><font color="#666666">80126 Naples </font></div><div style="font-size:12.800000190734863px"><font color="#666666">---------------------------------------------------------------------------------------------</font><font color="#000000"><br></font></div></div></div></div>
<br><div class="gmail_quote">2016-07-29 12:19 GMT-05:00 Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jul 28, 2016, at 12:48 PM, Valeria Mele <<a href="mailto:valeria.mele@unina.it">valeria.mele@unina.it</a>> wrote:<br>
><br>
> Hi everyone,<br>
> this time I am using PETSc to do something that is more complicated than my usual and I want to do it at the highest possible abstraction level.<br>
><br>
> To put it in a nutshell, my intent is to build a parallel multigrid to solve a linear system via DM, KSP and PCMG (I would like to use DMMG but probably I should have the same problems or more).<br>
<br>
</span> DMMG doesn't exist anymore. It was refactored away many years ago, its functionality is handled by PCMG and DM.<br>
<span class=""><br>
<br>
><br>
> I created the distributed object, da, with DMDACreate3d, even if it is distributed (as yet) only in the x-dimension and has 3 dof.<br>
> Then I create the KSP (type KSPRICHARDSON) and set the nonzero initial guess and PCMG as preconditioner. Here I start to tune the MG.<br>
><br>
> The point is that I need to define all the operators as matrix-free, since they will do several operations on x to obtain y, and I am not familiar with the way to access all the elements or informations in the two levels involved and/or among the processors with a so-high level interface.<br>
><br>
> So please (please please please please) tell me if I correctly understand the mechanism or I am on the wrong way and clear my doubts.<br>
><br>
> That is, let's say that my operation for the shell are:<br>
> • A_mult(Mat mat,Vec x, Vec y) //coefficients matrix<br>
> in this case the level is only one but should I write it taking into account only the local data (I think so) and accessing them via the informations in da?<br>
<br>
</span> Yes. You can use VecGetDM(x,&da) to get the DMDA object<br>
<span class=""><br>
><br>
> For example, if I use DMDAVecGetArray, DMDAVecGetCorners (or DMDAGetGhostCorners) and DMDAVecRestoreArray, will they retrieve informations from the right level each time (I am pretty sure that in some official examples it is done in this way)?<br>
><br>
> Or should I handle just Vecs as local structures with their usual indices (through VecGetArray and VecRestoreArray)?<br>
<br>
</span> No, no, no because then you would need to mange all the structured grid information yourself, since the DMDA manages it for you you should use it.<br>
<br>
> • P_mult(Mat mat,Vec x, Vec y) //interpolation matrix that is NOT conceptually the traspose of Restriction<br>
<span class="">> in this case x and y will be from two different levels (respectively L and L+1), so, if I retrieve informations from the da... how can I access the two at different levels?<br>
<br>
</span> Use VecGetDM(x, and VecGetDM(y to get access to both DMDA.<br>
<span class=""><br>
><br>
> I am sorry if it seems that they are trivial questions, and I will be grateful to anyone will help me.<br>
<br>
</span> Additional information. Since the PCMG will be requesting the matrices and the interpolation/restriction operations (rather than you setting them into each level of multigrid) you will need to use DMShellSetCreateMatrix() and DMShellSetCreateInterpolation() and DMShellSetCreateRestriction() to provide the routines that will create the Shell matrices you need to represent the operators on the levels and the restriction and interpolation (Even though you are using a DMDA you can still call these routines).<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> Thanks a lot,<br>
> Valeria<br>
><br>
><br>
><br>
><br>
><br>
><br>
> ---------------------------------------------------------------------------------------------<br>
> PhD Valeria Mele<br>
><br>
> University of Naples Federico II<br>
> Department of Mathematics and Applications "R. Caccioppoli"<br>
> Complesso Universitario M.S. Angelo, Via Cinthia<br>
> 80126 Naples<br>
> ---------------------------------------------------------------------------------------------<br>
<br>
<br>
</div></div></blockquote></div><br></div>