[petsc-users] Problems with PCMGSetInterpolation

Barry Smith bsmith at petsc.dev
Mon Sep 12 11:23:06 CDT 2022

    In PCSetUp_MG() it is creating needed vectors for each level. In order to create the vectors it needs to have a "template" of the vectors. It tries
several ways to get such a template. 

If you have provided an vector for each level with PCMGSetRhs() it uses VecDuplicate for the needed vectors.

If you provided a matrix for each level with PCMGSetOperators() it uses the MatCreateVectors() using that matrix

If you have not provided either of those it tries DMCreateGlobalVector() for the DM associated with that level, if there is no DM it defaults to DMShell and then errors.

Since it errors this seems to indicate you did not provide an operator for each level, nor a right hand side vector. 

Please find attached a patch that may resolve the issue for.

In the petsc directory do
patch -p1 < mg.patch
make libs

then rerun your example. Please let us know if it resolves the problem and if not send the complete error message


> On Sep 12, 2022, at 11:02 AM, Oleg Shatrov <shatrov.oleg.a at gmail.com> wrote:
> Hello!
> Can somebody explain to me what I am doing wrong here?
> I took tutorial 28 from KSP folder and modified it a little in order to create manual DM interpolations and set them to PC.
> When i run the application I receive an error:
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Must call DMShellSetGlobalVector() or DMShellSetCreateGlobalVector()
> [0]PETSC ERROR: See https://petsc.org/release/faq/ <https://petsc.org/release/faq/> for trouble shooting.
> [0]PETSC ERROR: Petsc Development GIT revision: v3.17.3-770-gceb9926454c  GIT Date: 2022-07-15 21:35:25 +0000
> [0]PETSC ERROR: ./a.out on a  named MacBook-Pro-Oleg.local by olegshatrov Mon Sep 12 17:53:13 2022
> [0]PETSC ERROR: Configure options --prefix=/usr/local CFLAGS="-m64 -O0 -g" CXXFLAGS="-m64 -O0 -g" FCFLAGS="-m64 -O0 -g -ffree-line-length-none" --with-mem-debug=1 --with-debugging=1 --with-mpi-dir=/usr/local/ --with-moab=true
> [0]PETSC ERROR: #1 DMCreateGlobalVector_Shell() at /Users/olegshatrov/Documents/GitHub/petsc/src/dm/impls/shell/dmshell.c:206
> [0]PETSC ERROR: #2 DMCreateGlobalVector() at /Users/olegshatrov/Documents/GitHub/petsc/src/dm/interface/dm.c:998
> [0]PETSC ERROR: #3 DMGetGlobalVector() at /Users/olegshatrov/Documents/GitHub/petsc/src/dm/interface/dmget.c:161
> [0]PETSC ERROR: #4 KSPCreateVecs() at /Users/olegshatrov/Documents/GitHub/petsc/src/ksp/ksp/interface/iterativ.c:1616
> [0]PETSC ERROR: #5 PCSetUp_MG() at /Users/olegshatrov/Documents/GitHub/petsc/src/ksp/pc/impls/mg/mg.c:1129
> [0]PETSC ERROR: #6 PCSetUp() at /Users/olegshatrov/Documents/GitHub/petsc/src/ksp/pc/interface/precon.c:991
> [0]PETSC ERROR: #7 KSPSetUp() at /Users/olegshatrov/Documents/GitHub/petsc/src/ksp/ksp/interface/itfunc.c:401
> [0]PETSC ERROR: #8 main() at ex28.c:67
> [0]PETSC ERROR: No PETSc Option Table entries
> [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint at mcs.anl.gov----------
> --------------------------------------------------------------------------
> And this is strange, since I did not provide any Shell DM.
> When i comment out lines with setting interpolation matrix to PCMG everything works fine:
> <image.png>
> I am testing on MacOS 12.3.
> MPI: Open MPI: 4.1.4
> gcc version 12.1.0
> Program is compiled with mpicc ex28.c -I /usr/local/include/ -L /usr/local/lib -lpetsc
> Thanks in advance,
> Oleg
> <ex28.c>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220912/248c90a2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mg.patch
Type: application/octet-stream
Size: 1532 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220912/248c90a2/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220912/248c90a2/attachment-0001.html>

More information about the petsc-users mailing list