From 9324b67c9bc17cb823d7813f14a7b69893344d00 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 23 Mar 2004 19:51:35 +0000 Subject: [PATCH] Have reinit() have another argument. git-svn-id: https://svn.dealii.org/trunk@8850 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/petsc_vector_base.h | 14 +++++++++++--- deal.II/lac/source/petsc_vector.cc | 4 +++- deal.II/lac/source/petsc_vector_base.cc | 7 ++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/deal.II/lac/include/lac/petsc_vector_base.h b/deal.II/lac/include/lac/petsc_vector_base.h index bebc71cf2d..65b78c85c1 100644 --- a/deal.II/lac/include/lac/petsc_vector_base.h +++ b/deal.II/lac/include/lac/petsc_vector_base.h @@ -210,7 +210,7 @@ namespace PETScWrappers /** * Change the dimension of the vector - * to @p{N}. It is unspecified how + * to @arg N. It is unspecified how * resizing the vector affects the * memory allocation of this object; * i.e., it is not guaranteed that @@ -220,13 +220,21 @@ namespace PETScWrappers * the same amount of memory is used * for less data. * - * On @p{fast==false}, the vector is + * On @arg fast is false, the vector is * filled by zeros. Otherwise, the * elements are left an unspecified * state. + * + * For parallel vectors, @arg + * local_size denotes how many of the + * @arg N values shall be stored + * locally on the present process. This + * argument is ignored for sequantial + * vectors. */ void reinit (const unsigned int N, - const bool fast=false); + const bool fast=false, + const unsigned int local_size = 0); /** * Change the dimension to that of the diff --git a/deal.II/lac/source/petsc_vector.cc b/deal.II/lac/source/petsc_vector.cc index 14794f0657..43484710b1 100644 --- a/deal.II/lac/source/petsc_vector.cc +++ b/deal.II/lac/source/petsc_vector.cc @@ -46,8 +46,10 @@ namespace PETScWrappers void Vector::create_vector (const unsigned int n, - const unsigned int /*local_size*/) + const unsigned int local_size) { + Assert (local_size < n, ExcIndexRange (local_size, 0, n)); + const int ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc index bf7919c8aa..b074a01fdb 100644 --- a/deal.II/lac/source/petsc_vector_base.cc +++ b/deal.II/lac/source/petsc_vector_base.cc @@ -50,11 +50,12 @@ namespace PETScWrappers void VectorBase::reinit (const unsigned int n, - const bool fast) + const bool fast, + const unsigned int local_sz) { // only do something if the sizes // mismatch - if (size() != n) + if ((size() != n) || (local_size() != local_sz)) { // FIXME: I'd like to use this here, // but somehow it leads to odd errors @@ -68,7 +69,7 @@ namespace PETScWrappers ierr = VecDestroy (vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); - create_vector (n); + create_vector (n, local_sz); } // finally clear the new vector if so -- 2.39.5