<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 3, 2015 at 9:42 AM, Nicolas Pozin <span dir="ltr"><<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><br><div><br></div><hr><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><b>De: </b>"Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br><b>À: </b>"Nicolas Pozin" <<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>><br><b>Cc: </b>"PETSc" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br><b>Envoyé: </b>Lundi 3 Août 2015 16:33:16<br><b>Objet: </b>Re: [petsc-users] problem with MatShellGetContext<br><div><br></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 3, 2015 at 9:13 AM, Nicolas Pozin <span dir="ltr"><<a href="mailto:nicolas.pozin@inria.fr" target="_blank">nicolas.pozin@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div>Hello everyone,</div><div><br></div><div>I am having trouble using MatShellGetContext.<strong><br></strong></div><div><br></div><div>Here's the simple test I did :</div><div><br></div><div><br></div><div>typedef struct{</div><div>    PetscInt testValue;</div><div>    Mat matShell;</div><div>    KSP currentCtx;</div><div>} AppCtx;</div><div><br></div><div><br></div><div>AppCtx context1;</div><div>KSPCreate(PETSC_COMM_WORLD,&context1.currentCtx);</div><div>context1.testValue=18;</div><div>MatCreateShell(PETSC_COMM_WORLD, nl, nl, nL, nL, context1.currentCtx, &context1.matShell);</div></div></div></blockquote><div><br></div><div>It looks like you want ''&context1" for the context argument. You are just passing the KSP pointer.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div>AppCtx context2;</div><div>MatShellGetContext(context1.matShell, (void*)&context2);</div></div></div></blockquote><div><br></div><div>Here you better declare</div><div><br></div><div>AppCtx *context2;</div><div><br></div><div>and access it as</div><div><br></div><div>  context2->testValue;</div></div></div></div></blockquote><div>Thanks, but It doesn't work better unfortunately</div></div></div></blockquote><div><br></div><div>This tells me NOTHING. How can I help you with this information? This has nothing to do with PETSc. It is</div><div>simple C semantics. Write a test code and send it in.</div><div><br></div><div>  Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><blockquote style="border-left:2px solid #1010ff;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>    Matt</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt;color:#000000"><div>It happens that context2.testValue is different from 18.</div><div><br></div><div>Any would have a clue on what I miss?</div><div><br></div><div>thanks a lot,</div><div>Nicolas</div><div><br></div></div></div></blockquote></div><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div></font></span></div></div></blockquote><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>