[petsc-users] C++ wrapper for petsc vector

Martin Vymazal martin.vymazal at vki.ac.be
Tue Aug 4 12:30:58 CDT 2015


Hello,

 1) thank you for the suggestion.
 2) suppose you want to be able to switch between solver implementations 
provided by different libraries (e.g. petsc/trilinos). One obvious approach is 
through inheritance, but in order to keep child interfaces conforming to base 
class signatures, I need to wrap the solvers. If you can think of a better 
approach that would keep switching between solvers easy, I'm open to 
suggestions. I don't really need both trilinos and petsc, this is just a 
matter of curiosity.

Best regards,

 Martin Vymazal


On Tuesday, August 04, 2015 12:24:14 PM Matthew Knepley wrote:
> On Tue, Aug 4, 2015 at 12:15 PM, Martin Vymazal <martin.vymazal at vki.ac.be>
> 
> wrote:
> > Hello,
> > 
> >  I'm trying to create a small C++ class to wrap the 'Vec' object. This
> > 
> > class
> > has an internal pointer to a member variable of type Vec, and in its
> > destructor, it calls VecDestroy. Unfortunately, my test program segfaults
> > and
> > this seems to be due to the fact that the destructor of the wrapper class
> > is
> > called after main() calls PetscFinalize(). Apparently VecDestroy performs
> > some
> > collective communication, so calling it after PetscFinalize() is too late.
> > How
> > can I fix this?
> 
> 1) Declare your C++ in a scope, so that it goes out of scope before
> PetscFinalize()
> 
> 2) Is there any utility to this wrapper since everything can be called
> directly from C++?
> 
>   Thanks,
> 
>      Matt
> 
> > Thank you,
> > 
> >  Martin Vymazal



More information about the petsc-users mailing list