Hi Zhidong, In C++ constructors are not inherited, so this function call won't work: it's not possible to create a PETScWrappers::MPI::Vector from a Vec object directly.
I think that you can solve your problem by just using VectorBase: you can create objects of this type directly that wrap around a Vec and don't destroy it when they go out of scope. Would this work for you? One alternative would be to always create PETScWrappers::MPI::Vector objects (instead of ever explicitly creating a Vec) and then using the conversion operator (part of VectorBase) to get the Vec out when you need it. Thanks, David On Wed, Dec 4, 2019 at 11:42 AM Zhidong Brian Zhang <wonderful...@gmail.com> wrote: > > Dear, deal.ii colleagues, > > A vector conversion problem has been troubled me for a long time. > > It is the conversion between between dealii::PETScWrappers::MPI::Vector and a > PETSc Vec. > > I have some functions written based on PETSc directly. So that I would like > to use them directly in deal.ii. However, I need to convert vectors between > dealii's MPI vectors to PETSc's generic vectors. > > Here is an simplified example: > Vec a; // PETSc vector > VecDuplicate(x, &a); // x is a dealii::PETScWrappers::MPI Vector generated > previously > VecCopy(x, a); > dealii::PETScWrappers::MPI::Vector b(a); // dealii MPI vector > > I try to construct a dealii vector named with "b" based on PETSc Vector named > "a". This should be OK in my opinion based on the constructor that is > VectorBase (const Vec &v) in the deal.ii's document: > https://www.dealii.org/current/doxygen/deal.II/classPETScWrappers_1_1VectorBase.html#a08f6d7c4850e085271c225c5c19d7502 > > > In addition, dealii::PETScWrappers::MPI::Vector is inherited from VectorBase, > so the constructor VectorBase (const Vec &v) should be able to be called by > dealii::PETScWrappers::MPI::Vector as well. > > However, the error reported is: > no matching function for call to > dealii::PETScWrappers::MPI::Vector::Vector(_p_Vec*&) > > > So may I get some information about this vector conversion problem? > Thank you very much in advance! > > Zhidong Brian Zhang > > > BTW, I found some info in the following forum but it is related to Mat > conversion between deal.ii and PETSc: > https://groups.google.com/forum/#!searchin/dealii/petscwrappers$3A$3Avector|sort:date/dealii/1HHsnUeJC28/qgBaE0SVBgAJ > > -- > The deal.II project is located at http://www.dealii.org/ > For mailing list/forum options, see > https://groups.google.com/d/forum/dealii?hl=en > --- > You received this message because you are subscribed to the Google Groups > "deal.II User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to dealii+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/b013a870-32bd-4d91-884d-1b3fc2eff9a3%40googlegroups.com. -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CABrTbYTQ2UjRfTc7dAzKmg0GRNkTk9MXmLCcYppMgveEh%2BLcZg%40mail.gmail.com.