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

Jed Brown jed at jedbrown.org
Tue Aug 4 12:24:38 CDT 2015


Martin Vymazal <martin.vymazal at vki.ac.be> writes:

> Hello,
>
>  I'm trying to create a small C++ class to wrap the 'Vec' object. 

A word of warning: Lots of people try this, but I've never seen an
implementation that wasn't a leaky, high-maintenance abstraction with
purely cosmetic value.

> 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?

Scope so your objects are destroyed before PetscFinalize.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150804/74c824c9/attachment.pgp>


More information about the petsc-users mailing list