<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Dear petsc-users,</p>
<p> I am trying with a student to modify the MG example 65 to use
mat-shells instead of assembled matrices. Our use case is for a
method that will use custom shell operators and shell
interpolation/restrictions.</p>
<p>To start we have modified ex65 and tried to replace the standard
restriction/interpolation with a shell matrix that performs the
same operations on the DMDA grids.<br>
</p>
<p>I attach our modifications to ex65.</p>
<p>The problem is that the code sometimes completes execution and
sometimes errors out like<br>
</p>
<p><span style="font-family:monospace"><span style="color:#000000;background-color:#ffffff;">$ ./ex65shell
-ksp_monitor -pc_type mg -da_refine 2 -ksp_rtol 1e-1 </span><br>
>> Created DMshell 0x55bbc83c91a0 (0x55bbc8390a80)
<br>
Calling KSPSolve from main
<br>
computeRHS on grid 513
<br>
computeMatrix on grid 513
<br>
Inside Coarsen
<br>
>> Created DMshell 0x55bbc84c5270 (0x55bbc84b2ff0)
<br>
Inside Coarsen
<br>
>> Created DMshell 0x55bbc84e0a30 (0x55bbc84bdb60)
<br>
>> Create interpolation from
0x55bbc84c5270(0x55bbc84b2ff0) to 0x55bbc83c91a0(0x55bbc8390a80)
<br>
<span style="font-weight:bold;color:#ff5454;background-color:#ffffff;">[0]PETSC
ERROR: --------------------- Error Message
--------------------------------------------------------------</span><span style="color:#000000;background-color:#ffffff;">
</span><br>
[0]PETSC ERROR: Invalid pointer
<br>
[0]PETSC ERROR: Invalid Pointer to PetscObject: Argument 'obj'
(parameter # 1)
<br>
[0]PETSC ERROR: See <a class="moz-txt-link-freetext" href="https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!Y29qRoOD71oxcd-BQFTUohkIToMJNW3puZ3CerpZ6pBnecqhBQ8TBwhSnikLt4BYQTmsBgtKvoCFi-JuLXQAE_Oe_a_d2XOL8KvOmw$">https://petsc.org/release/faq/</a> for trouble
shooting.
<br>
[0]PETSC ERROR: Petsc Release Version 3.22.0, unknown <br>
[0]PETSC ERROR: ./ex65shell with 1 MPI process(es) and
PETSC_ARCH on signalkuppe by matteo Tue Dec 10 12:55:12 2024
<br>
[0]PETSC ERROR: Configure options:
--prefix=/home/matteo/software/petscsaved/3.22-opt/
PETSC_DIR=/home/matteo/software/petsc --PETSC_ARCH=dbg
--with-debugging=1 --with-st<br>
rict-petscerrorcode --download-hdf5 --download-ml --with-metis
--with-parmetis --with-gmsh --with-triangle --with-zlib
--with-p4est-dir=~/software/p4est/local/
<br>
[0]PETSC ERROR: #1 PetscObjectReference() at
/home/matteo/software/petsc/src/sys/objects/inherit.c:620
<br>
[0]PETSC ERROR: #2 PCMGSetRScale() at
/home/matteo/software/petsc/src/ksp/pc/impls/mg/mgfunc.c:394
<br>
[0]PETSC ERROR: #3 PCSetUp_MG() at
/home/matteo/software/petsc/src/ksp/pc/impls/mg/mg.c:998
<br>
[0]PETSC ERROR: #4 PCSetUp() at
/home/matteo/software/petsc/src/ksp/pc/interface/precon.c:1071
<br>
[0]PETSC ERROR: #5 KSPSetUp() at
/home/matteo/software/petsc/src/ksp/ksp/interface/itfunc.c:415
<br>
[0]PETSC ERROR: #6 KSPSolve_Private() at
/home/matteo/software/petsc/src/ksp/ksp/interface/itfunc.c:826
<br>
[0]PETSC ERROR: #7 KSPSolve() at
/home/matteo/software/petsc/src/ksp/ksp/interface/itfunc.c:1075
<br>
[0]PETSC ERROR: #8 main() at ../src/ex65shell.c:79
<br>
[0]PETSC ERROR: PETSc Option Table entries:
<br>
[0]PETSC ERROR: -da_refine 2 (source: command line)
<br>
[0]PETSC ERROR: -ksp_monitor (source: command line)
<br>
[0]PETSC ERROR: -ksp_rtol 1e-1 (source: command line)
<br>
[0]PETSC ERROR: -pc_type mg (source: command line)
<br>
<span style="font-weight:bold;color:#ff5454;background-color:#ffffff;">[0]PETSC
ERROR: ----------------End of Error Message -------send entire
error message to <a class="moz-txt-link-abbreviated" href="mailto:petsc-maint@mcs.anl.gov">petsc-maint@mcs.anl.gov</a>----------</span><br>
</span></p>
<p>In all cases valgrind complains like<br>
</p>
<p><span style="font-family:monospace"><span style="color:#000000;background-color:#ffffff;">$ valgrind
./ex65shell -ksp_monitor -pc_type mg -da_refine 2 -ksp_rtol
1e-1 -int_view ascii::ascii_info
</span><br>
==2130767== Memcheck, a memory error detector
<br>
==2130767== Copyright (C) 2002-2022, and GNU GPL'd, by Julian
Seward et al.
<br>
==2130767== Using Valgrind-3.19.0 and LibVEX; rerun with -h for
copyright info
<br>
==2130767== Command: ./ex65shell -ksp_monitor -pc_type mg
-da_refine 2 -ksp_rtol 1e-1 -int_view ascii::ascii_info
<br>
==2130767== <br>
hwloc x86 backend cannot work under Valgrind, disabling.
<br>
May be reenabled by dumping CPUIDs with hwloc-gather-cpuid
<br>
and reloading them under Valgrind with HWLOC_CPUID_PATH.
<br>
>> Created DMshell 0xfbf50f0 (0xfb49480)
<br>
Calling KSPSolve from main
<br>
computeRHS on grid 513
<br>
computeMatrix on grid 513
<br>
Inside Coarsen
<br>
>> Created DMshell 0xff404a0 (0xff062d0)
<br>
Inside Coarsen
<br>
>> Created DMshell 0xff78ca0 (0xff4a530)
<br>
>> Create interpolation from 0xff404a0(0xff062d0) to
0xfbf50f0(0xfb49480)
<br>
Mat Object: 1 MPI process
<br>
type: shell
<br>
rows=513, cols=257
<br>
==2130767== Conditional jump or move depends on uninitialised
value(s)
<br>
==2130767== at 0x83FDAAE: PCSetUp_MG (mg.c:998)
<br>
==2130767== by 0x8620C04: PCSetUp (precon.c:1071)
<br>
==2130767== by 0x7DA78D5: KSPSetUp (itfunc.c:415)
<br>
==2130767== by 0x7DB2093: KSPSolve_Private (itfunc.c:826)
<br>
==2130767== by 0x7DB7A53: KSPSolve (itfunc.c:1075)
<br>
==2130767== by 0x10D2F7: main (ex65shell.c:79)
<br>
==2130767== <br>
==2130767== Conditional jump or move depends on uninitialised
value(s)
<br>
==2130767== at 0x5794061: VecDestroy (vector.c:570)
<br>
==2130767== by 0x83FDC36: PCSetUp_MG (mg.c:999)
<br>
==2130767== by 0x8620C04: PCSetUp (precon.c:1071)
<br>
==2130767== by 0x7DA78D5: KSPSetUp (itfunc.c:415)
<br>
==2130767== by 0x7DB2093: KSPSolve_Private (itfunc.c:826)
<br>
==2130767== by 0x7DB7A53: KSPSolve (itfunc.c:1075)
<br>
==2130767== by 0x10D2F7: main (ex65shell.c:79)
<br>
==2130767== <br>
</span></p>
<p>We are clearly doing something wrong since PCSetUp_MG (mg.c:998)
is an area of code where I wouldn't expect we would enter.</p>
<p>Can you advise on the proper way to achieve our goal?<br>
</p>
<p>Best regards</p>
<p> Matteo<br>
</p>
</body>
</html>