[petsc-users] Local sizes when creating PETSC MatIS

Stefano Zampini stefano.zampini at gmail.com
Fri Jun 14 20:58:17 CDT 2019


This seems a problem related with your code, I suggest you to run valgrind.
Which version of PETSc are you using?


> On Jun 14, 2019, at 3:12 PM, José Lorenzo <joslorgom at gmail.com> wrote:
> 
> Following the PETSC examples, I was trying something like:
> 
>   call ISLocalToGlobalMappingCreate(PETSC_COMM_WORLD, 1, nidx, idx_global, PETSC_COPY_VALUES, ltog, ierr)
> 
>   call MatCreateIS(PETSC_COMM_WORLD, 1_ip, proedg(rank), proedg(rank), PETSC_DETERMINE, PETSC_DETERMINE, ltog, ltog, An, ierr)
> 
>   call MatISSetPreallocation(An, d_nz, PETSC_NULL_INTEGER, o_nz, PETSC_NULL_INTEGER, ierr)
> 
> with idx_global storing the global indices of both local and ghost edges, and proedg(rank) the number of edges at the current processor. 
> 
> The program crashes in the Preallocation subroutine:
> 
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Argument out of range
> [0]PETSC ERROR: nnz cannot be less than 0: local row 4 value -7493980938351671286
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html <http://www.mcs.anl.gov/petsc/documentation/faq.html> for trouble shooting.
> [0]PETSC ERROR: #1 MatSeqAIJSetPreallocation_SeqAIJ() line 3670 in PETSC_DIR/src/mat/impls/aij/seq/aij.c
> [0]PETSC ERROR: #2 MatSeqAIJSetPreallocation() line 3646 in PETSC_DIR/src/mat/impls/aij/seq/aij.c
> [0]PETSC ERROR: #3 MatISSetPreallocation_IS() line 1795 in PETSC_DIR/src/mat/impls/is/matis.c
> 
> And with your suggestion I get the same error during the preallocation step.
> 
> Thank you.
> 
> 
> El vie., 14 jun. 2019 a las 14:24, Stefano Zampini (<stefano.zampini at gmail.com <mailto:stefano.zampini at gmail.com>>) escribió:
> Jose,
> 
> 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.
> 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
> 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 https://epubs.siam.org/doi/abs/10.1137/15M1025785 <https://epubs.siam.org/doi/abs/10.1137/15M1025785>)
> 
> MatCreate(comm,&A)
> MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)
> MatSetType(A,MATIS)
> MatSetLocalToGlobalMapping(A,l2g,l2g)// this creates the local Neumann matrices
> 
> For n = 1: number_of_local_elements
>   Construct element matrix
>   // you have two alternitives
>   MatSetValuesLocal(A, // using local ordering of dofs
>   //or MatSetValues(A, // using global ordering of dofs
> end
> 
>> On Jun 14, 2019, at 5:09 AM, José Lorenzo via petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>> wrote:
>> 
>> 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.
>> 
>> 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
>> 
>> 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? 
>> 
>> 
>> 
>> Thanks,
>> 
>> Jose
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190614/2244339d/attachment.html>


More information about the petsc-users mailing list