Up
to now, I always create PETScWrappers::MPI::Vector. And use "operator
const Vec & () const" to get PETSc generic vector out:
Vec a; // PETSc generic vector
a = x; // x is a PETScWrappers::MPI::Vector generated previously
In
sum, I prefer to go with the second method. My basic reason is that I
need to generate MPI vector by PETScWrappers::MPI::Vector. The
simpilified workflow of my program is as follows,
1. I need build the parallel vector through PETScWrappers::MPI::Vector.
2. PETSc Vec is derived from PETScWrappers::MPI::Vector and is imported into my own functions (written based on PETSc).
3. My functions output updated PETSc Vec.
4. I update PETScWrappers::MPI::Vector based on the updated PETSc Vec.
The pesudo code is as follows,
Vec a;
a = x;
a = myfunctions(a); // my functions (written based on PETSc)
dealii::PETScWrappers::VectorBase b(a); // generate VectorBase from PETSc Vec
dealii::PETScWrappers::MPI::Vector c(opt->mpi_communicator, b, opt->locally_owned_cells.size()); // generate
PETScWrappers::MPI::Vector from VectorBase
x = c; // update the PETScWrappers::MPI::Vector that was generated previously
May I ask 2 further questions:
1.
The function has been deprecated according to deal.ii official
document: dealii::PETScWrappers::MPI::Vector c(opt->mpi_communicator,
b, opt->locally_owned_cells.size()). I can run it successfully, but
is there a walkaround of this because I don't want to use a deprecated
function.
2. What is the basic idea behind
creating the two classes: dealii::PETScWrappers::MPI::Vector and
VectorBase? I mean why not only one (I am a newbie, sorry, no offense)?
For my understanding is VectorBase is a wrapper of PETSc Vec and
dealii::PETScWrappers::MPI::Vector is a wrapper of VectorBase.
Thank you so much for your guidance and help in advance!
Zhidong Brian Zhang