[petsc-users] Store type (Eigen::Vector2d) in a petsc vec

Andrew Parker andy.john.parker at gmail.com
Tue Feb 5 08:43:01 CST 2019


Thanks, so you would suggest a flat vector storing u, v, w (or indeed x, y,
z) or interleaved and then construct eigen types on the fly?  Can I ask, is
that because Vec cannot store user defined types (as in it's not
templatetable?)

Thanks,
Andy

On Tue, 5 Feb 2019 at 14:22, Jed Brown <jed at jedbrown.org> wrote:

> My suggestion is to use PETSc like usual and inside your
> residual/Jacobian evaluation, for each cell or batch of cells, create
> Eigen objects.  For size 2d or 3d, it won't matter much whether you make
> them share memory with the PETSc Vec -- the Eigen types should mostly
> exist in registers.
>
> Andrew Parker via petsc-users <petsc-users at mcs.anl.gov> writes:
>
> > Hi,
> >
> > I have quite a bit of working code that uses eigen vector2d/3d (and some
> > corresponding matrix3d types) to allow for local linAlg.  I would like to
> > store these within a petsc vector. So for example to have a vector for
> all
> > cells of velocity-vectors in 2d held for each cell within an eigen
> > vector2d, within a Petsc Vec for all cells.  What would be the best way
> to
> > achieve this within petsc? I would like to make full use of petsc
> > capabilities including parallel (ghost updating, partitioning etc),
> > likewise those of eigen's for local linAlg on small fixed sized vectors,
> so
> > how best to achieve this to allow for both eco-systems?
> > Thanks,
> > Andy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190205/9f864fe4/attachment.html>


More information about the petsc-users mailing list