<div dir="ltr"><div>You want to look at the bottom of each of these web pages</div><div><br></div><div><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCreateInjection.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCreateInjection.html</a></div><div><br></div><div><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCreateInterpolation.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCreateInterpolation.html</a></div><div><br></div><div><a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMCreateInterpolationScale.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DMDA/DMCreateInterpolationScale.html</a></div><div><br></div><div>At the bottom you will see URLs to the current set of DM implementations which implement Injection, Interpolation.<br></div><div><br></div><div>Thanks</div><div>Dave<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 12 Mar 2020 at 21:14, Xiaodong Liu <<a href="mailto:xliu29@ncsu.edu">xliu29@ncsu.edu</a>> wrote:<br></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>Hi, all, <br></div><div><br></div><div>I am practising multigrid as a preconditioner in Petsc. From the previous resource, there are 2 main ways to set up the multigrid preconditioner,</div><div><br></div><div>1). For general cae, <br></div><div>KSPCreate(MPI Comm comm,KSP *ksp); <br></div><div>KSPGetPC(KSP ksp,PC *pc);<br>PCSetType(PC pc,PCMG);<br>PCMGSetLevels(pc,int levels,MPI Comm *comms);<br>PCMGSetType(PC pc,PCMGType mode);<br>PCMGSetCycleType(PC pc,PCMGCycleType ctype);</div><div>...</div><div>PCMGSetInterpolation(PC pc,int level,Mat P); <br>PCMGSetRestriction(PC pc,int level,Mat R);</div><div><br></div><div>The above means that I need to specify a lot details, e.g., cycletype. interpolation and restriction matrix, coarse solver, etc. <br></div><div><br></div><div>2) For the case of structured mesh, (DMDA is enough)</div><div>Taking the following case as an example, <br></div><div><a href="https://www.mcs.anl.gov/petsc/petsc-3.6/src/ksp/ksp/examples/tutorials/ex25.c.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-3.6/src/ksp/ksp/examples/tutorials/ex25.c.html</a></div><div><br></div><div> 50: KSPCreate(PETSC_COMM_WORLD,&ksp);<br> 51: DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,-3,1,1,0,&da);<br> 52: KSPSetDM(ksp,da);<br> 53: KSPSetComputeRHS(ksp,ComputeRHS,&user);<br> 54: KSPSetComputeOperators(ksp,ComputeMatrix,&user);<br> 55: KSPSetFromOptions(ksp);<br> 56: KSPSolve(ksp,NULL,NULL);</div><div><br></div><div>DMDA handles all the multigrid setting automatically, e.g., interpolation and restriction matrix.</div><div>If my understanding is right, <font size="4"><b>my question is where to find these source file to define these default interpolation and restriction matrix. </b></font><br></div><div><br></div><div>Thanks,S<br></div><div><div><div dir="ltr"><div dir="ltr"><div>Xiaodong Liu, PhD<br>X: Computational Physics Division<br>Los Alamos National Laboratory<br>P.O. Box 1663, <br>Los Alamos, NM 87544<br>505-709-0534<br></div></div></div></div></div></div>
</blockquote></div>