17 #ifndef __deal2__petsc_block_vector_h 18 #define __deal2__petsc_block_vector_h 21 #include <deal.II/base/config.h> 23 #ifdef DEAL_II_WITH_PETSC 25 # include <deal.II/lac/petsc_vector.h> 26 # include <deal.II/lac/petsc_parallel_block_vector.h> 27 # include <deal.II/lac/block_indices.h> 28 # include <deal.II/lac/block_vector_base.h> 29 # include <deal.II/lac/exceptions.h> 71 typedef BaseClass::pointer pointer;
72 typedef BaseClass::const_pointer const_pointer;
73 typedef BaseClass::reference reference;
74 typedef BaseClass::const_reference const_reference;
75 typedef BaseClass::size_type size_type;
98 explicit BlockVector (
const unsigned int num_blocks = 0,
99 const size_type block_size = 0);
151 template <
typename InputIterator>
153 const InputIterator first,
154 const InputIterator
end);
199 void reinit (
const unsigned int num_blocks,
200 const size_type block_size,
201 const bool fast =
false);
235 void reinit (
const std::vector<size_type> &N,
236 const bool fast=
false);
265 const bool fast=
false);
278 void reinit (
const unsigned int num_blocks);
315 void print (std::ostream &out,
316 const unsigned int precision = 3,
317 const bool scientific =
true,
318 const bool across =
true)
const;
338 const size_type block_size)
340 reinit (n_blocks, block_size);
360 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
374 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
380 template <
typename InputIterator>
382 const InputIterator first,
383 const InputIterator
end)
389 InputIterator start = first;
390 for (
unsigned int b=0; b<n.size(); ++b)
392 InputIterator end = start;
393 std::advance (end, static_cast<signed int>(n[b]));
395 for (size_type i=0; i<n[b]; ++i, ++start)
396 this->
block(b)(i) = *start;
398 Assert (start == end, ExcIteratorRangeDoesNotMatchVectorSize());
441 const size_type bl_sz,
444 std::vector<size_type> n(n_bl, bl_sz);
459 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
473 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
483 reinit (num_blocks, 0,
true);
495 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
505 const unsigned int precision,
506 const bool scientific,
507 const bool across)
const 509 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
512 out <<
'C' << i <<
':';
514 out <<
"Component " << i << std::endl;
515 this->
components[i].print(out, precision, scientific, across);
540 DEAL_II_NAMESPACE_CLOSE
542 #endif // DEAL_II_WITH_PETSC void reinit(const unsigned int num_blocks, const size_type block_size, const bool fast=false)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
unsigned int n_blocks() const
BlockVector & operator=(const value_type s)
BaseClass::value_type value_type
BlockIndices block_indices
BlockVectorBase< Vector > BaseClass
virtual void reinit(const size_type N, const bool fast=false)
BlockVector(const unsigned int num_blocks=0, const size_type block_size=0)
#define Assert(cond, exc)
const BlockIndices & get_block_indices() const
DeclException0(ExcIteratorRangeDoesNotMatchVectorSize)
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
std::vector< Vector > components
BaseClass::BlockType BlockType
void swap(BlockVector &u, BlockVector &v)
unsigned int size() const
::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
BlockType & block(const unsigned int i)
BlockVectorBase & operator=(const value_type s)
void swap(BlockVector &v)