From: heister Date: Tue, 19 Feb 2013 22:49:52 +0000 (+0000) Subject: new constructor/reinit for PETScWrappers::MPI::BlockVector using IndexSets X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4caedf418ea91832c07bd10ec5486eaa3d401d4d;p=dealii-svn.git new constructor/reinit for PETScWrappers::MPI::BlockVector using IndexSets git-svn-id: https://svn.dealii.org/trunk@28483 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 4f791bf6af..f3b589a070 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -208,6 +208,11 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. New: PETScWrappers::MPI::BlockVector now has a constructor and reinit +that takes a std::vector (same interface as in Trilinos). +
    +(Timo Heister, 2013/02/19) +
  2. New: PETScWrappers::*Matrix::add(other, factor) to add a scaled other matrix to the current matrix.
    diff --git a/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h b/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h index e17ce5b484..3c5587a6ab 100644 --- a/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/petsc_parallel_block_vector.h @@ -126,6 +126,13 @@ namespace PETScWrappers const MPI_Comm &communicator, const std::vector &local_elements); + /** + * Create a BlockVector with parallel_partitioning.size() blocks, + * each initialized with the given IndexSet. + */ + explicit BlockVector (const std::vector ¶llel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD); + /** * Destructor. Clears memory */ @@ -265,6 +272,13 @@ namespace PETScWrappers void reinit (const BlockVector &V, const bool fast=false); + /** + * Reinitialize the BlockVector using IndexSets. See the constructor + * with the same arguments for details. + */ + void reinit (const std::vector ¶llel_partitioning, + const MPI_Comm &communicator); + /** * Return a reference to the MPI * communicator object in use with @@ -365,6 +379,12 @@ namespace PETScWrappers this->components[i] = v.components[i]; } + inline + BlockVector::BlockVector (const std::vector ¶llel_partitioning, + const MPI_Comm &communicator) + { + reinit(parallel_partitioning, communicator); + } inline @@ -438,6 +458,22 @@ namespace PETScWrappers block(i).reinit(v.block(i), fast); } + inline + void + BlockVector::reinit (const std::vector ¶llel_partitioning, + const MPI_Comm &communicator) + { + std::vector sizes(parallel_partitioning.size()); + for (unsigned int i=0; iblock_indices.reinit(sizes); + if (this->components.size() != this->n_blocks()) + this->components.resize(this->n_blocks()); + + for (unsigned int i=0; in_blocks(); ++i) + block(i).reinit(communicator, parallel_partitioning[i]); + } inline