[petsc-users] arbitrary number of linear systems in an application

Dominik Szczerba dominik at itis.ethz.ch
Fri Sep 9 10:06:49 CDT 2011


Hi,

I have an application where I do not know how many linears systems I
will solve. Solution of the first will determine coefficient of the
second etc., e.g., in case of a pressure correction method.
I do not see a problem of having a std::vector of KSP objects,
matrices and vectors (at least not yet...) but I am not sure how to
handle

KSPSetConvergenceTest(this->ksp, DefaultConvergenceTest, (void*)
&ctxConvergence, DestroyDefaultConvergenceContext);

where the functions are defined as


#undef __FUNCT__
#define __FUNCT__ "DefaultConvergenceTest"
PetscErrorCode DefaultConvergenceTest(KSP ksp, int n, PetscReal rnorm,
KSPConvergedReason *reason, void *void_ctx)
{
// ...
}

and

#undef __FUNCT__
#define __FUNCT__ "destroyConvergenceContext"
PetscErrorCode DestroyDefaultConvergenceContext(void *void_ctx)
// ...
}

I would like something like a user defining how many linear system he
wants and I want these functions to be pre-filled for them with a
default generic content, which the user could, however, overwrite to
possibly have different criteria for different solvers.

I am unsure how to achieve this elegantly. I am thinking about a
class, whereby such a function would be virtual static member. Then I
could create a vector of instances. But will the __FUNCT__ mechanism
accept such functions? Any better ideas?

Many thanks for any feedback.

Regards,
Dominik


More information about the petsc-users mailing list