--- /dev/null
+Changed: The PETScWrappers::MPI::Vector class always corresponds to a PETSc
+vector with type <code>mpi</code>, even when empty.
+<br> (David Wells, 2017/03/29)
internal::VectorReference::ExcWrongMode (VectorOperation::unknown,
last_action));
-
- if (v.size()==0)
- {
- // this happens if v has not been initialized to something useful:
- // Vector x,v;
- // x=v;
- // we skip the code below and create a simple serial vector of
- // length 0
-
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- PetscErrorCode ierr = VecDestroy (vector);
-#else
- PetscErrorCode ierr = VecDestroy (&vector);
-#endif
- AssertThrow (ierr == 0, ExcPETScError(ierr));
-
- const int n = 0;
- ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
- ghosted = false;
- ghost_indices.clear();
- return *this;
- }
-
// if the vectors have different sizes,
// then first resize the present one
if (size() != v.size())
Vector::Vector ()
: communicator (MPI_COMM_SELF)
{
- // this is an invalid empty vector, so we can just as well create a
- // sequential one to avoid all the overhead incurred by parallelism
- const int n = 0;
- const PetscErrorCode ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
- ghosted = false;
+ create_vector(0, 0);
}
void
Vector::clear ()
{
- // destroy the PETSc Vec and create an invalid empty vector,
- // so we can just as well create a sequential one to avoid
- // all the overhead incurred by parallelism
attained_ownership = true;
VectorBase::clear ();
- const int n = 0;
- const PetscErrorCode ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
+ create_vector(0, 0);
}