<div class="gmail_quote">On Fri, Sep 30, 2011 at 09:34, Dominik Szczerba <span dir="ltr"><<a href="mailto:dominik@itis.ethz.ch">dominik@itis.ethz.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I am currently declaring functions outside my C++ solver class to be<br>
used by via MatShellSetOperation like:<br>
<br>
#undef __FUNCT__<br>
#define __FUNCT__ "StiffnessMatrixMultiplication"<br>
PetscErrorCode StiffnessMatrixMultiplication(Mat A, Vec x, Vec y)<br>
{<br>
// ...<br>
ierr = MatShellGetContext(A, (void**) &ctx);CHKERRQ(ierr);<br>
Mat foo;<br>
foo = ctx->foo;<br>
// ...<br>
}<br>
<br>
and I set/get contexts to e.g. pass 'foo' around. Is it possible in<br>
Petsc / is it a good idea / to instead declare such functions as<br>
static class member functions and then use the class members directly<br>
without any contexts shuffled around?<br></blockquote><div><br></div><div>You have to go through the context unless your class is a singleton. Or do you still mean casting the ctx to your class type and accessing members through it (explicit "this")? That should work, if you prefer.</div>
</div>