15#ifndef dealii_petsc_block_vector_h
16#define dealii_petsc_block_vector_h
21#ifdef DEAL_II_WITH_PETSC
116 BlockVector(
const std::vector<size_type> &block_sizes,
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,
145 template <std::
size_t num_blocks>
146 explicit BlockVector(
const std::array<Vec, num_blocks> &);
195 const bool omit_zeroing_entries =
false);
218 reinit(
const std::vector<size_type> &block_sizes,
220 const std::vector<size_type> &locally_owned_sizes,
221 const bool omit_zeroing_entries =
false);
245 reinit(
const std::vector<IndexSet> ¶llel_partitioning,
252 reinit(
const std::vector<IndexSet> ¶llel_partitioning,
253 const std::vector<IndexSet> &ghost_entries,
265 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
267 const bool make_ghosted =
true);
296 reinit(
const unsigned int num_blocks);
317 operator const Vec &()
const;
351 print(std::ostream &out,
352 const unsigned int precision = 3,
353 const bool scientific =
true,
354 const bool across =
true)
const;
387 , petsc_nest_vector(nullptr)
404 const std::vector<size_type> &block_sizes,
406 const std::vector<size_type> &local_elements)
409 reinit(block_sizes, communicator, local_elements,
false);
420 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
429 const std::vector<IndexSet> ¶llel_partitioning,
433 reinit(parallel_partitioning, communicator);
439 const std::vector<IndexSet> ¶llel_partitioning,
440 const std::vector<IndexSet> &ghost_indices,
444 reinit(parallel_partitioning, ghost_indices, communicator);
457 template <std::
size_t num_blocks>
464 for (
auto i = 0; i < num_blocks; ++i)
492 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
507 const bool omit_zeroing_entries)
512 omit_zeroing_entries);
520 const std::vector<size_type> &locally_owned_sizes,
521 const bool omit_zeroing_entries)
526 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
529 locally_owned_sizes[i],
530 omit_zeroing_entries);
543 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
560 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
571 const std::vector<IndexSet> &ghost_entries,
581 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
594 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
596 const bool make_ghosted)
603 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
626 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
638 std::swap(this->components, v.components);
639 std::swap(this->petsc_nest_vector, v.petsc_nest_vector);
641 ::swap(this->block_indices, v.block_indices);
648 const unsigned int precision,
649 const bool scientific,
650 const bool across)
const
652 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
655 out <<
'C' << i <<
':';
657 out <<
"Component " << i << std::endl;
658 this->
components[i].print(out, precision, scientific, across);
682 namespace LinearOperatorImplementation
695 template <
typename Matrix>
701 v.
reinit(matrix.locally_owned_range_indices(),
702 matrix.get_mpi_communicator());
705 template <
typename Matrix>
711 v.
reinit(matrix.locally_owned_domain_indices(),
712 matrix.get_mpi_communicator());
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
::internal::BlockVectorIterators::Iterator< BlockVectorBase, false > iterator
unsigned int n_blocks() const
const value_type * const_pointer
typename BlockType::const_reference const_reference
types::global_dof_index size_type
typename BlockType::value_type value_type
BlockVectorBase & operator=(const value_type s)
std::vector< Vector > components
::internal::BlockVectorIterators::Iterator< BlockVectorBase, true > const_iterator
typename BlockType::reference reference
BlockIndices block_indices
BlockType & block(const unsigned int i)
std::size_t locally_owned_size() const
const BlockIndices & get_block_indices() const
BaseClass::value_type value_type
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
bool has_ghost_elements() const
BaseClass::const_reference const_reference
MPI_Comm get_mpi_communicator() const
BaseClass::pointer pointer
void swap(BlockVector &u, BlockVector &v) noexcept
void swap(BlockVector &v) noexcept
BlockVector & operator=(const value_type s)
BaseClass::reference reference
void compress(VectorOperation::values operation)
BaseClass::const_pointer const_pointer
bool has_ghost_elements() const
static void reinit_range_vector(const Matrix &matrix, PETScWrappers::MPI::BlockVector &v, bool)
static void reinit_domain_vector(const Matrix &matrix, PETScWrappers::MPI::BlockVector &v, bool)
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcNonMatchingBlockVectors()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
types::global_dof_index locally_owned_size
void swap(BlockVector &u, BlockVector &v) noexcept