16 #ifndef dealii_petsc_parallel_block_vector_h 17 #define dealii_petsc_parallel_block_vector_h 20 #include <deal.II/base/config.h> 22 #ifdef DEAL_II_WITH_PETSC 24 # include <deal.II/lac/petsc_parallel_vector.h> 25 # include <deal.II/lac/block_indices.h> 26 # include <deal.II/lac/block_vector_base.h> 27 # include <deal.II/lac/exceptions.h> 28 # include <deal.II/lac/vector_type_traits.h> 30 DEAL_II_NAMESPACE_OPEN
79 typedef BaseClass::pointer pointer;
80 typedef BaseClass::const_pointer const_pointer;
81 typedef BaseClass::reference reference;
82 typedef BaseClass::const_reference const_reference;
83 typedef BaseClass::size_type size_type;
99 const MPI_Comm &communicator,
100 const size_type block_size,
101 const size_type local_size);
116 BlockVector (
const std::vector<size_type> &block_sizes,
117 const MPI_Comm &communicator,
118 const std::vector<size_type> &local_elements);
124 explicit BlockVector (
const std::vector<IndexSet> ¶llel_partitioning,
125 const MPI_Comm &communicator = MPI_COMM_WORLD);
130 BlockVector (
const std::vector<IndexSet> ¶llel_partitioning,
131 const std::vector<IndexSet> &ghost_indices,
132 const MPI_Comm &communicator);
163 const MPI_Comm &communicator,
164 const size_type block_size,
165 const size_type local_size,
166 const bool omit_zeroing_entries =
false);
188 void reinit (
const std::vector<size_type> &block_sizes,
189 const MPI_Comm &communicator,
190 const std::vector<size_type> &local_sizes,
191 const bool omit_zeroing_entries=
false);
208 const bool omit_zeroing_entries=
false);
214 void reinit (
const std::vector<IndexSet> ¶llel_partitioning,
215 const MPI_Comm &communicator);
220 void reinit (
const std::vector<IndexSet> ¶llel_partitioning,
221 const std::vector<IndexSet> &ghost_entries,
222 const MPI_Comm &communicator);
230 void reinit (
const unsigned int num_blocks);
265 void print (std::ostream &out,
266 const unsigned int precision = 3,
267 const bool scientific =
true,
268 const bool across =
true)
const;
286 const MPI_Comm &communicator,
287 const size_type block_size,
288 const size_type local_size)
297 const MPI_Comm &communicator,
298 const std::vector<size_type> &local_elements)
300 reinit (block_sizes, communicator, local_elements,
false);
312 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
318 const MPI_Comm &communicator)
320 reinit(parallel_partitioning, communicator);
325 const std::vector<IndexSet> &ghost_indices,
326 const MPI_Comm &communicator)
328 reinit(parallel_partitioning, ghost_indices, communicator);
351 for (size_type i=0; i<this->
n_blocks(); ++i)
364 const MPI_Comm &communicator,
365 const size_type block_size,
366 const size_type local_size,
367 const bool omit_zeroing_entries)
371 std::vector<size_type>(
n_blocks, local_size),
372 omit_zeroing_entries);
380 const MPI_Comm &communicator,
381 const std::vector<size_type> &local_sizes,
382 const bool omit_zeroing_entries)
388 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
390 local_sizes[i], omit_zeroing_entries);
397 const bool omit_zeroing_entries)
403 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
410 const MPI_Comm &communicator)
412 std::vector<size_type> sizes(parallel_partitioning.size());
413 for (
unsigned int i=0; i<parallel_partitioning.size(); ++i)
414 sizes[i] = parallel_partitioning[i].
size();
420 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
421 block(i).
reinit(parallel_partitioning[i], communicator);
427 const std::vector<IndexSet> &ghost_entries,
428 const MPI_Comm &communicator)
430 std::vector<types::global_dof_index> sizes(parallel_partitioning.size());
431 for (
unsigned int i=0; i<parallel_partitioning.size(); ++i)
432 sizes[i] = parallel_partitioning[i].
size();
438 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
439 block(i).
reinit(parallel_partitioning[i], ghost_entries[i], communicator);
448 return block(0).get_mpi_communicator();
455 bool ghosted=
block(0).has_ghost_elements();
457 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
478 const unsigned int precision,
479 const bool scientific,
480 const bool across)
const 482 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
485 out <<
'C' << i <<
':';
487 out <<
"Component " << i << std::endl;
488 this->
components[i].print(out, precision, scientific, across);
515 namespace LinearOperatorImplementation
517 template <
typename>
class ReinitHelper;
527 template <
typename Matrix>
533 v.
reinit(matrix.locally_owned_range_indices(), matrix.get_mpi_communicator());
536 template <
typename Matrix>
542 v.
reinit(matrix.locally_owned_domain_indices(), matrix.get_mpi_communicator());
561 DEAL_II_NAMESPACE_CLOSE
563 #endif // DEAL_II_WITH_PETSC void reinit(const unsigned int n_blocks, const MPI_Comm &communicator, const size_type block_size, const size_type local_size, const bool omit_zeroing_entries=false)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
void swap(BlockVector &v)
const MPI_Comm & get_mpi_communicator() const
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
static void reinit_range_vector(const Matrix &matrix, Vector &v, bool omit_zeroing_entries)
static ::ExceptionBase & ExcNonMatchingBlockVectors()
BaseClass::value_type value_type
static void reinit_domain_vector(const Matrix &matrix, Vector &v, bool omit_zeroing_entries)
BlockIndices block_indices
void swap(BlockVector &u, BlockVector &v)
const BlockIndices & get_block_indices() const
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
#define DeclException0(Exception0)
std::vector< Vector > components
void swap(Vector< Number > &u, Vector< Number > &v)
BaseClass::BlockType BlockType
unsigned int n_blocks() const
BlockVectorBase< Vector > BaseClass
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
bool has_ghost_elements() const
BlockVector & operator=(const value_type s)
BlockType & block(const unsigned int i)
BlockVectorBase & operator=(const value_type s)
static ::ExceptionBase & ExcInternalError()