16 #ifndef dealii__petsc_block_vector_h 17 #define dealii__petsc_block_vector_h 20 #include <deal.II/base/config.h> 22 #ifdef DEAL_II_WITH_PETSC 24 # include <deal.II/lac/petsc_vector.h> 25 # include <deal.II/lac/petsc_parallel_block_vector.h> 26 # include <deal.II/lac/block_indices.h> 27 # include <deal.II/lac/block_vector_base.h> 28 # include <deal.II/lac/exceptions.h> 30 DEAL_II_NAMESPACE_OPEN
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;
89 explicit BlockVector (
const unsigned int num_blocks = 0,
90 const size_type block_size = 0);
124 template <
typename InputIterator>
126 const InputIterator first,
127 const InputIterator
end);
164 void reinit (
const unsigned int num_blocks,
165 const size_type block_size,
166 const bool omit_zeroing_entries =
false);
186 void reinit (
const std::vector<size_type> &N,
187 const bool omit_zeroing_entries=
false);
204 const bool omit_zeroing_entries=
false);
212 void reinit (
const unsigned int num_blocks);
234 void print (std::ostream &out,
235 const unsigned int precision = 3,
236 const bool scientific =
true,
237 const bool across =
true)
const;
259 const size_type block_size)
261 reinit (n_blocks, block_size);
281 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
295 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
301 template <
typename InputIterator>
303 const InputIterator first,
304 const InputIterator
end)
311 InputIterator start = first;
312 for (
unsigned int b=0; b<n.size(); ++b)
314 InputIterator end = start;
315 std::advance (end, static_cast<signed int>(n[b]));
317 for (size_type i=0; i<n[b]; ++i, ++start)
318 this->
block(b)(i) = *start;
320 Assert (start == end, ExcIteratorRangeDoesNotMatchVectorSize());
363 const size_type bl_sz,
364 const bool omit_zeroing_entries)
366 std::vector<size_type> n(n_bl, bl_sz);
367 reinit(n, omit_zeroing_entries);
375 const bool omit_zeroing_entries)
381 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
389 const bool omit_zeroing_entries)
395 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
405 reinit (num_blocks, 0,
true);
417 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
427 const unsigned int precision,
428 const bool scientific,
429 const bool across)
const 431 for (
unsigned int i=0; i<this->
n_blocks(); ++i)
434 out <<
'C' << i <<
':';
436 out <<
"Component " << i << std::endl;
437 this->
components[i].print(out, precision, scientific, across);
462 DEAL_II_NAMESPACE_CLOSE
464 #endif // DEAL_II_WITH_PETSC
BlockVector & operator=(const value_type s)
BaseClass::value_type value_type
BlockDynamicSparsityPattern BlockCompressedSparsityPattern DEAL_II_DEPRECATED
BlockIndices block_indices
BlockVectorBase< Vector > BaseClass
BlockVector(const unsigned int num_blocks=0, const size_type block_size=0)
const BlockIndices & get_block_indices() const
#define Assert(cond, exc)
DeclException0(ExcIteratorRangeDoesNotMatchVectorSize)
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
std::vector< Vector > components
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
BaseClass::BlockType BlockType
void swap(BlockVector &u, BlockVector &v)
void reinit(const unsigned int num_blocks, const size_type block_size, const bool omit_zeroing_entries=false)
unsigned int n_blocks() const
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
unsigned int size() const
BlockType & block(const unsigned int i)
BlockVectorBase & operator=(const value_type s)
void swap(BlockVector &v)