[petsc-users] problem with MatShellGetContext

Nicolas Pozin nicolas.pozin at inria.fr
Mon Aug 3 09:42:00 CDT 2015


----- Mail original -----

> De: "Matthew Knepley" <knepley at gmail.com>
> À: "Nicolas Pozin" <nicolas.pozin at inria.fr>
> Cc: "PETSc" <petsc-users at mcs.anl.gov>
> Envoyé: Lundi 3 Août 2015 16:33:16
> Objet: Re: [petsc-users] problem with MatShellGetContext

> 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;

Thanks, but It doesn't work better unfortunately 

> 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/d8e68008/attachment.html>


More information about the petsc-users mailing list