[petsc-users] Providing matrix vector product yourself for matrix free in SNES

E.T.A.vanderWeide at utwente.nl E.T.A.vanderWeide at utwente.nl
Wed Dec 21 11:30:16 CST 2011


The call the MatShellSetContext is as follows

ierr = MatShellSetContext(mat, this);
CHKERRQ(ierr);

Later on in the call to MatShellGetContext I get the following error
[0]PETSC ERROR: MatShellGetContext() line 201 in src/mat/impls/shell/shell.c Null Pointer: Parameter # 2

The callback function is a standalone function, in which I call MatShellGetContext to get the context. In there it fails.

Edwin


-----Original Message-----
From: petsc-users-bounces at mcs.anl.gov on behalf of Jed Brown
Sent: Wed 12/21/2011 4:08 PM
To: PETSc users list
Subject: Re: [petsc-users] Providing matrix vector product yourself for matrix free in SNES
 
On Wed, Dec 21, 2011 at 08:54, <E.T.A.vanderWeide at utwente.nl> wrote:

> Thanks, this is working. The only problem I still have is that I have to
> store much more than just a vector in context of MATSHELL in order to carry
> out the matrix vector multiplication. I basically need all the contents of
> an object of a certain class. I tried to store the this pointer of the
> object in the context of MATSHELL, but then I get an error. So it looks
> like it is not allowed to pass the this pointer to MatShellSetContext, is
> that correct?


How are you calling MatShellSetContext() and what is the error? You can
pass "this", but the callback should be either a standalone function or a
static member function.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111221/7106598d/attachment-0001.htm>


More information about the petsc-users mailing list