<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [petsc-users] Providing matrix vector product yourself for matrix free in SNES</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>The call the MatShellSetContext is as follows<BR>
<BR>
ierr = MatShellSetContext(mat, this);<BR>
CHKERRQ(ierr);<BR>
<BR>
Later on in the call to MatShellGetContext I get the following error<BR>
[0]PETSC ERROR: MatShellGetContext() line 201 in src/mat/impls/shell/shell.c Null Pointer: Parameter # 2<BR>
<BR>
The callback function is a standalone function, in which I call MatShellGetContext to get the context. In there it fails.<BR>
<BR>
Edwin<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: petsc-users-bounces@mcs.anl.gov on behalf of Jed Brown<BR>
Sent: Wed 12/21/2011 4:08 PM<BR>
To: PETSc users list<BR>
Subject: Re: [petsc-users] Providing matrix vector product yourself for matrix free in SNES<BR>
<BR>
On Wed, Dec 21, 2011 at 08:54, <E.T.A.vanderWeide@utwente.nl> wrote:<BR>
<BR>
> Thanks, this is working. The only problem I still have is that I have to<BR>
> store much more than just a vector in context of MATSHELL in order to carry<BR>
> out the matrix vector multiplication. I basically need all the contents of<BR>
> an object of a certain class. I tried to store the this pointer of the<BR>
> object in the context of MATSHELL, but then I get an error. So it looks<BR>
> like it is not allowed to pass the this pointer to MatShellSetContext, is<BR>
> that correct?<BR>
<BR>
<BR>
How are you calling MatShellSetContext() and what is the error? You can<BR>
pass "this", but the callback should be either a standalone function or a<BR>
static member function.<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>