<!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, &lt;E.T.A.vanderWeide@utwente.nl&gt; wrote:<BR>
<BR>
&gt; Thanks, this is working. The only problem I still have is that I have to<BR>
&gt; store much more than just a vector in context of MATSHELL in order to carry<BR>
&gt; out the matrix vector multiplication. I basically need all the contents of<BR>
&gt; an object of a certain class. I tried to store the this pointer of the<BR>
&gt; object in the context of MATSHELL, but then I get an error. So it looks<BR>
&gt; like it is not allowed to pass the this pointer to MatShellSetContext, is<BR>
&gt; that correct?<BR>
<BR>
<BR>
How are you calling MatShellSetContext() and what is the error? You can<BR>
pass &quot;this&quot;, but the callback should be either a standalone function or a<BR>
static member function.<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>