[petsc-users] MatGetLocalSubMatrix Trouble

Barry Smith bsmith at mcs.anl.gov
Mon Feb 15 22:43:05 CST 2016


  Jared,

   Though it is not properly documented the matrix must have had a call to MatSetLocalToGlobalMapping() before you can call MatCreateLocalRef().  

   I'll add a little more error checking and docs.

  Barry

Note that matrices obtained with DMCreateMat() generally have had the local to global mapping already provided to the matrix so you don't need to call it yourself.


> On Feb 15, 2016, at 10:31 PM, Jared Crean <jcrean01 at gmail.com> wrote:
> 
> Hello,
>    When I try to use MatGetLocalSubMatrix (line 55 of the attached code), I get the following error:
> 
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer
> [0]PETSC ERROR: Null Object: Parameter # 2
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.6.0, Jun, 09, 2015
> [0]PETSC ERROR: ./jc3 on a arch-linux2-cxx-debug named k475 by jared Mon Feb 15 23:19:29 2016
> [0]PETSC ERROR: Configure options --with-clanguage=C++
> [0]PETSC ERROR: #1 ISL2GCompose() line 117 in /home/jared/build/petsc-3.6.0/src/mat/impls/localref/mlocalref.c
> [0]PETSC ERROR: #2 MatCreateLocalRef() line 259 in /home/jared/build/petsc-3.6.0/src/mat/impls/localref/mlocalref.c
> [0]PETSC ERROR: #3 MatGetLocalSubMatrix() line 9686 in /home/jared/build/petsc-3.6.0/src/mat/interface/matrix.c
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer
> [0]PETSC ERROR: Null Object: Parameter # 2
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.6.0, Jun, 09, 2015
> [0]PETSC ERROR: ./jc3 on a arch-linux2-cxx-debug named k475 by jared Mon Feb 15 23:19:29 2016
> [0]PETSC ERROR: Configure options --with-clanguage=C++
> [0]PETSC ERROR: #4 ISL2GCompose() line 117 in /home/jared/build/petsc-3.6.0/src/mat/impls/localref/mlocalref.c
> [0]PETSC ERROR: #5 MatCreateLocalRef() line 259 in /home/jared/build/petsc-3.6.0/src/mat/impls/localref/mlocalref.c
> [0]PETSC ERROR: #6 MatGetLocalSubMatrix() line 9686 in /home/jared/build/petsc-3.6.0/src/mat/interface/matrix.c
> [0]PETSC ERROR: #7 main() line 55 in /home/jared/build/petsc-3.6.0/src/ksp/ksp/examples/tutorials/jc3.c
> [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----------
> application called MPI_Abort(MPI_COMM_WORLD, 85) - process 0
> 
> 
>    A did a little digging and found:
> 
>    Line 117-118 of mlocalref.c are:
>  PetscValidHeaderSpecific(ltog,IS_LTOGM_CLASSID,2);
>  PetscValidPointer(cltog,3);
> 
>    where ltog is the ISLocalToGlobalMapping from (line 259):
>        A->rmap->mapping
> 
>    where A is the original matrix, cltog is a reference to the local to global mapping to be created .
>    The code prints out A, so it appears to be a valid matrix.  Is there something wrong with the way I am using MatGetLocalSubMatrix?
> 
>    Jared Crean
> 
> 
> <jc3.c>



More information about the petsc-users mailing list