<div dir="ltr"><div>I'm using PETSC 3.10 with 64 bits indices.</div><div><br></div><div>When I run valgrind I get the following message at the end of the report, which I don't know how to interpret:</div><div><br></div><div>==399672== Invalid read of size 8<br>==399672== at 0x5627D05: MatZeroEntries_SeqAIJ (aij.c:1077)<br>==399672== by 0x5394A61: MatZeroEntries (matrix.c:5664)<br>==399672== by 0x53DEF3F: MatZeroEntries_IS (matis.c:3064)<br>==399672== by 0x5394A61: MatZeroEntries (matrix.c:5664)<br>==399672== by 0x53B682C: matzeroentries_ (matrixf.c:1024)<br>==399672== by 0x415C0B: parallmodule_mp_elementarymatrices_ (parallModule.F90:101)<br>==399672== by 0x424C40: MAIN__ (main.F90:414)<br>==399672== by 0x40303D: main (in /myproject/)<br>==399672== Address 0x4c30 is not stack'd, malloc'd or (recently) free'd</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El sáb., 15 jun. 2019 a las 3:58, Stefano Zampini (<<a href="mailto:stefano.zampini@gmail.com">stefano.zampini@gmail.com</a>>) escribió:<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 style="overflow-wrap: break-word;"><div>This seems a problem related with your code, I suggest you to run valgrind.</div>Which version of PETSc are you using?<div><div><br></div><div><br><blockquote type="cite"><div>On Jun 14, 2019, at 3:12 PM, José Lorenzo <<a href="mailto:joslorgom@gmail.com" target="_blank">joslorgom@gmail.com</a>> wrote:</div><br class="gmail-m_-7591920705549130385Apple-interchange-newline"><div><div dir="ltr"><div>Following the PETSC examples, I was trying something like:</div><div><br></div><div> call ISLocalToGlobalMappingCreate(PETSC_COMM_WORLD, 1, nidx, idx_global, PETSC_COPY_VALUES, ltog, ierr)<br><br> call MatCreateIS(PETSC_COMM_WORLD, 1_ip, proedg(rank), proedg(rank), PETSC_DETERMINE, PETSC_DETERMINE, ltog, ltog, An, ierr)</div><div><br></div><div> call MatISSetPreallocation(An, d_nz, PETSC_NULL_INTEGER, o_nz, PETSC_NULL_INTEGER, ierr)</div><div><br></div><div>with idx_global storing the global indices of both local and ghost edges, and proedg(rank) the number of edges at the current processor. <br></div><div><br></div><div>The program crashes in the Preallocation subroutine:</div><div><br></div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>[0]PETSC ERROR: Argument out of range<br>[0]PETSC ERROR: nnz cannot be less than 0: local row 4 value -7493980938351671286<br>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: #1 MatSeqAIJSetPreallocation_SeqAIJ() line 3670 in PETSC_DIR/src/mat/impls/aij/seq/aij.c<br>[0]PETSC ERROR: #2 MatSeqAIJSetPreallocation() line 3646 in PETSC_DIR/src/mat/impls/aij/seq/aij.c</div><div>[0]PETSC ERROR: #3 MatISSetPreallocation_IS() line 1795 in PETSC_DIR/src/mat/impls/is/matis.c</div><div><br></div><div>And with your suggestion I get the same error during the preallocation step.</div><div><br></div><div>Thank you.<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El vie., 14 jun. 2019 a las 14:24, Stefano Zampini (<<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>>) escribió:<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>Jose,<div><br></div><div>The local size of the matrix (the one you use in MatSetSizes) tells Petsc what is the size of the local portion of the vectors involved in matrix vector products.<div>It has nothing to do with the size of the local Neumann problem needed by MatIS. These are inferred from the local to global mapping of the degrees of freedom</div><div>In your case, the l2g object needs to map all the dofs that corresponds to the local mesh to their global dof numbering (you can take a look here <a href="https://epubs.siam.org/doi/abs/10.1137/15M1025785" target="_blank">https://epubs.siam.org/doi/abs/10.1137/15M1025785</a>)</div><div><br></div><div>MatCreate(comm,&A)</div><div>MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)<br><div>MatSetType(A,MATIS)</div><div>MatSetLocalToGlobalMapping(A,l2g,l2g)// this creates the local Neumann matrices</div><div><br></div><div>For n = 1: number_of_local_elements</div><div> Construct element matrix</div><div> // you have two alternitives</div><div> MatSetValuesLocal(A, // using local ordering of dofs</div><div> //or MatSetValues(A, // using global ordering of dofs</div><div>end</div><div><br><blockquote type="cite"><div>On Jun 14, 2019, at 5:09 AM, José Lorenzo via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_-7591920705549130385gmail-m_-875568732586015957Apple-interchange-newline"><div><div dir="ltr"><p>I am working with Nedelec Finite Elements and using ghost vectors to
store the ghost values of the solution in the edges that do not belong
to current processor.<br>
</p><p>Since I have a large contrast in material properties I would like to
try the PCBDDC preconditioner in PETSC. Apparently, my matrix needs to
be of type MatIS, but I don't get to understand how MatCreateIS would
work in my particular case, although I did have a look at mat/ex3.c and
ksp/ex59.c</p><p>I set the local size m to the number of edges in current processor,
but I do not know whether I should include the number of ghost edges.
And for the local size n should I use the total number of DOFs or
proceed as with m? <br>
</p><p><br>
</p><p>Thanks,</p><p>Jose</p>
</div>
</div></blockquote></div><br></div></div></div></blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>