[petsc-users] Invalid MAT_CLASSID

Barry Smith bsmith at mcs.anl.gov
Mon Oct 20 18:51:08 CDT 2014



  ./programname options   -on_error_attach_debugger 

then when it stops look at the object and see what it is and why it isn’t a Mat  This is trivial and not worth a bunch of emails back and forth; you need to know the basics of using a debugger.


 Barry

> On Oct 20, 2014, at 5:21 PM, Harshad Sahasrabudhe <hsahasra at purdue.edu> wrote:
> 
> Hi Matt,
> 
> If I have 2 instances of PETSc, one which is initialized by LibMesh and the other which is initialized in my code, then would getting a Mat from one version to the other cause this issue? I know that this is not the right way to do it, I'm just trying to zero in on the problem.
> 
> a) is not the problem, since I create and assemble the matrix using LibMesh API. b) is not it either, I ran a simple example and it works in that case. For c), I ran my code with Valgrind and didn't get any invalid write errors.
> 
> Thanks,
> Harshad
> 
> On Mon, Oct 20, 2014 at 4:19 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Mon, Oct 20, 2014 at 3:17 PM, Harshad Sahasrabudhe <hsahasra at purdue.edu> wrote:
> I get the Mat object from libMesh::PetscMatrix<>::mat(), and it's been created and assembled before I call MatGetType.
> 
> But what you are getting is invalid, so either
> 
>   a) it has not been created and assembled in LibMesh
> 
>   b) the right thing is not getting passed back (LibMesh problem)
> 
> or
> 
>   c) you are overwriting memory and it manifests here (check with valgrind)
> 
> It is very easy to look in these structures using the debugger. We are just checking an integer
> in the header for the object that identifies it as a Mat.
> 
>    Matt
>  
> On Mon, Oct 20, 2014 at 4:12 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Mon, Oct 20, 2014 at 3:07 PM, Harshad Sahasrabudhe <hsahasra at purdue.edu> wrote:
> Hi,
> 
> I get the following error when I call MatGetType even though I'm calling the function with a Mat object.
> 
> [0]PETSC ERROR: Invalid argument!
> [0]PETSC ERROR: Wrong type of object: Parameter # 1!
> 
> What could be going wrong?
> 
> You are not calling it with a valid Mat object. Did you call MatCreate?
> 
>    Matt
>  
> Thanks,
> Harshad
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
> 
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
> 



More information about the petsc-users mailing list