[petsc-users] question about contexts
Vijay S. Mahadevan
vijay.m at gmail.com
Fri Sep 30 12:33:01 CDT 2011
You should be able to do this:
#undef __FUNCT__
#define __FUNCT__ "StiffnessMatrixMultiplication"
PetscErrorCode StiffnessMatrixMultiplication(Mat A, Vec x, Vec y)
{
MyClass* ctx ;
// ...
ierr = MatShellGetContext(A, (void**) &ctx);CHKERRQ(ierr);
Mat foo;
foo = ctx->foo; // non-static public member of MyClass that is
of type Mat
// ...
Mat bar;
bar = MyClass::bar; // static member of MyClass that is of type Mat
// ...
Mat foobar;
foobar = MyClass::foobar(); // static member function of
MyClass that returns a Mat
// ...
}
And similarly for the PCShellApply, you can get the context MyClass
from the PC instance. I don't see what problems you have with this
use-case.
Look at SampleShellPCApply in
http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/src/ksp/ksp/examples/tutorials/ex15.c.html
for a similar usage.
On Fri, Sep 30, 2011 at 12:28 PM, Dominik Szczerba <dominik at itis.ethz.ch> wrote:
>> But the method is like a "friend" in the sense that it can access members through an explicit pointer.
>
> Can you please expand a bit on this one? What is an explicit pointer?
>
> Dominik
>
More information about the petsc-users
mailing list