[petsc-users] VecSetType and ghosted vectors

Vijay S. Mahadevan vijay.m at gmail.com
Wed Oct 19 17:29:03 CDT 2011


>> My rationale: I have abstracted a C++ class called PetscLinearSolver that
>> is supposed to wrap all the complex ksp & co functionality in an easy to use
>> C++ class.

I don't see why you would have to create your own vector here. If
PetscLinearSolver is a wrapper around KSP object, and x, b are
supplied by the user, what other work vectors are you allocating ? If
this is your own custom solver, then a consistent layout can be
obtained with VecDuplicate(x, &work_vec).

As Jed points out, many packages have done this with a C++ wrapper but
mostly these are thin calls that just forward it to the petsc solver
with right options. Do you have a more complicated requirement ?

On Wed, Oct 19, 2011 at 5:22 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> On Wed, Oct 19, 2011 at 17:09, Dominik Szczerba <dominik at itis.ethz.ch>
> wrote:
>>
>> My rationale: I have abstracted a C++ class called PetscLinearSolver that
>> is supposed to wrap all the complex ksp & co functionality in an easy to use
>> C++ class.
>
> Just a word of caution: many, many packages have tried to this, but all the
> advanced users end up pulling out the PETSc objects anyway. The reason for
> "complexity" in the KSP and PC interfaces is language-independent. You're
> not going to make it simpler without losing a lot of flexibility if you wrap
> it in C++. (If you prove me wrong, I want to see how you do it, but I
> haven't seen a competitive solution yet, and not for lack of trying or lack
> of competence.)


More information about the petsc-users mailing list