[petsc-users] question about contexts

Dominik Szczerba dominik at itis.ethz.ch
Fri Sep 30 09:34:13 CDT 2011


I am currently declaring functions outside my C++ solver class to be
used by via MatShellSetOperation like:

#undef __FUNCT__
#define __FUNCT__ "StiffnessMatrixMultiplication"
PetscErrorCode StiffnessMatrixMultiplication(Mat A, Vec x, Vec y)
{
	// ...
	ierr = MatShellGetContext(A, (void**) &ctx);CHKERRQ(ierr);
	Mat foo;
	foo = ctx->foo;
	// ...
}

and I set/get contexts to e.g. pass 'foo' around. Is it possible in
Petsc / is it a good idea / to instead declare such functions as
static class member functions and then use the class members directly
without any contexts shuffled around?

Thanks for any hints.

Dominik


More information about the petsc-users mailing list