<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>   Beats me :-) Just set it to whatever the DMDA sets it too <div><br></div><div>  Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Dec 10, 2024, at 11:20 AM, Matteo Semplice <matteo.semplice@uninsubria.it> wrote:</div><br class="Apple-interchange-newline"><div>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
  <div><p>Thanks, Barry.<br>
    </p><p>Just to be sure, one should refer to the help of
      <a class="moz-txt-link-freetext" href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/DM/DMCreateInterpolationScale/__;!!G_uCfscf7eWS!adeZHH1r8zFo3A5H1wpZDveIiI1ryL_lOJwl2MsOC0uuANOMda4SvkEHBjoh9sZgxTrk1G2RbGRejVvgyba9OYQ$">https://petsc.org/release/manualpages/DM/DMCreateInterpolationScale/</a>
      and the vec should be set to the point-wise inverse of
      (INTERPOLATION)*(vector of ones)  ?</p>
    <div class="moz-cite-prefix">Matteo</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 10/12/2024 16:38, Barry Smith wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:97C19201-BA91-4661-9E03-0CD1817AA663@petsc.dev">
      
      <div><br>
      </div>
         It appears you are completely ignoring the vec argument? Take a
      look at, for example, DMCreateInterpolation_DA() you will see you
      need to provide an appropriate vec in the same way you need (and
      do) provide an appropriate mat.
      <div><br>
      </div>
      <div>   Barry</div>
      <div><br id="lineBreakAtBeginningOfMessage">
        <div><br>
          <blockquote type="cite">
            <div>On Dec 10, 2024, at 7:02 AM, Matteo Semplice via
              petsc-users <a class="moz-txt-link-rfc2396E" href="mailto:petsc-users@mcs.anl.gov"><petsc-users@mcs.anl.gov></a> wrote:</div>
            <br class="Apple-interchange-newline">
            <div>
              <div><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="background-color: rgb(255, 255, 255);">$
                      ./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="background-color: rgb(255, 255, 255);"> </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$" moz-do-not-send="true">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 moz-txt-link-freetext" href="mailto:petsc-maint@mcs.anl.gov" moz-do-not-send="true">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="background-color: rgb(255, 255, 255);">$
                      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>
              </div>
              <span id="cid:2ED6A6D4-97BD-49C4-B25B-EC46C444CE4F"><ex65.patch></span></div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Prof. Matteo Semplice
Università degli Studi dell’Insubria
Dipartimento di Scienza e Alta Tecnologia – DiSAT
Professore Associato
Via Valleggio, 11 – 22100 Como (CO) – Italia
tel.: +39 031 2386316</pre>
  </div>

</div></blockquote></div><br></div></body></html>