16 #ifndef dealii_petsc_block_vector_h
17 #define dealii_petsc_block_vector_h
22 #ifdef DEAL_II_WITH_PETSC
98 const MPI_Comm & communicator,
115 BlockVector(
const std::vector<size_type> &block_sizes,
116 const MPI_Comm & communicator,
117 const std::vector<size_type> &local_elements);
123 explicit BlockVector(
const std::vector<IndexSet> ¶llel_partitioning,
124 const MPI_Comm &communicator = MPI_COMM_WORLD);
129 BlockVector(
const std::vector<IndexSet> ¶llel_partitioning,
130 const std::vector<IndexSet> &ghost_indices,
131 const MPI_Comm & communicator);
178 const MPI_Comm & communicator,
181 const bool omit_zeroing_entries =
false);
204 reinit(
const std::vector<size_type> &block_sizes,
205 const MPI_Comm & communicator,
206 const std::vector<size_type> &locally_owned_sizes,
207 const bool omit_zeroing_entries =
false);
231 reinit(
const std::vector<IndexSet> ¶llel_partitioning,
232 const MPI_Comm & communicator);
238 reinit(
const std::vector<IndexSet> ¶llel_partitioning,
239 const std::vector<IndexSet> &ghost_entries,
240 const MPI_Comm & communicator);
259 reinit(
const unsigned int num_blocks);
281 operator const Vec &()
const;
315 print(std::ostream & out,
316 const unsigned int precision = 3,
317 const bool scientific =
true,
318 const bool across =
true)
const;
341 : petsc_nest_vector(nullptr)
347 const MPI_Comm & communicator,
350 : petsc_nest_vector(nullptr)
358 const std::vector<size_type> &block_sizes,
359 const MPI_Comm & communicator,
360 const std::vector<size_type> &local_elements)
361 : petsc_nest_vector(nullptr)
363 reinit(block_sizes, communicator, local_elements,
false);
369 , petsc_nest_vector(nullptr)
374 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
377 this->collect_sizes();
381 const std::vector<IndexSet> ¶llel_partitioning,
382 const MPI_Comm & communicator)
383 : petsc_nest_vector(nullptr)
385 reinit(parallel_partitioning, communicator);
389 const std::vector<IndexSet> ¶llel_partitioning,
390 const std::vector<IndexSet> &ghost_indices,
391 const MPI_Comm & communicator)
392 : petsc_nest_vector(nullptr)
394 reinit(parallel_partitioning, ghost_indices, communicator);
399 , petsc_nest_vector(nullptr)
423 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
426 this->collect_sizes();
435 const MPI_Comm & communicator,
438 const bool omit_zeroing_entries)
443 omit_zeroing_entries);
450 const MPI_Comm & communicator,
451 const std::vector<size_type> &locally_owned_sizes,
452 const bool omit_zeroing_entries)
457 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
460 locally_owned_sizes[i],
461 omit_zeroing_entries);
474 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
482 const MPI_Comm & communicator)
489 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
498 const std::vector<IndexSet> &ghost_entries,
499 const MPI_Comm & communicator)
508 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
519 inline const MPI_Comm &
522 static MPI_Comm
comm = PETSC_COMM_SELF;
525 if (pcomm != MPI_COMM_NULL)
535 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
555 const unsigned int precision,
556 const bool scientific,
557 const bool across)
const
559 for (
unsigned int i = 0; i < this->
n_blocks(); ++i)
562 out <<
'C' << i <<
':';
564 out <<
"Component " << i << std::endl;
565 this->
components[i].print(out, precision, scientific, across);
589 namespace LinearOperatorImplementation
602 template <
typename Matrix>
609 matrix.get_mpi_communicator());
612 template <
typename Matrix>
619 matrix.get_mpi_communicator());
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
const BlockIndices & get_block_indices() const
::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
BaseClass::value_type value_type
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
BaseClass::size_type size_type
bool has_ghost_elements() const
void swap(BlockVector &v)
BaseClass::const_reference const_reference
void swap(BlockVector &u, BlockVector &v)
BaseClass::pointer pointer
BlockVector & operator=(const value_type s)
BaseClass::reference reference
BaseClass::const_pointer const_pointer
const MPI_Comm & get_mpi_communicator() const
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
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcNonMatchingBlockVectors()
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
@ matrix
Contents is actually a matrix.
BlockVector< double > BlockVector
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
void swap(BlockVector &u, BlockVector &v)