[petsc-users] problem with MatShellGetContext

Matthew Knepley knepley at gmail.com
Mon Aug 3 09:33:16 CDT 2015


On Mon, Aug 3, 2015 at 9:13 AM, Nicolas Pozin <nicolas.pozin at inria.fr>
wrote:

> Hello everyone,
>
> I am having trouble using MatShellGetContext.
>
> Here's the simple test I did :
>
>
> typedef struct{
>     PetscInt testValue;
>     Mat matShell;
>     KSP currentCtx;
> } AppCtx;
>
>
> AppCtx context1;
> KSPCreate(PETSC_COMM_WORLD,&context1.currentCtx);
> context1.testValue=18;
> MatCreateShell(PETSC_COMM_WORLD, nl, nl, nL, nL, context1.currentCtx,
> &context1.matShell);
>

It looks like you want ''&context1" for the context argument. You are just
passing the KSP pointer.


> AppCtx context2;
> MatShellGetContext(context1.matShell, (void*)&context2);
>

Here you better declare

AppCtx *context2;

and access it as

  context2->testValue;

    Matt


> It happens that context2.testValue is different from 18.
>
> Any would have a clue on what I miss?
>
> thanks a lot,
> Nicolas
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150803/e1892707/attachment.html>


More information about the petsc-users mailing list