Reference documentation for deal.II version Git 7f58f27 2017-09-20 15:35:49 -0600
la_parallel_block_vector.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_la_parallel_block_vector_h
17 #define dealii_la_parallel_block_vector_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/lac/block_indices.h>
23 #include <deal.II/lac/block_vector_base.h>
24 #include <deal.II/lac/la_parallel_vector.h>
25 #include <deal.II/lac/vector_type_traits.h>
26 
27 
28 #include <cstdio>
29 #include <vector>
30 
31 DEAL_II_NAMESPACE_OPEN
32 
33 
34 #ifdef DEAL_II_WITH_PETSC
35 namespace PETScWrappers
36 {
37  namespace MPI
38  {
39  class BlockVector;
40  }
41 }
42 #endif
43 
44 #ifdef DEAL_II_WITH_TRILINOS
45 namespace TrilinosWrappers
46 {
47  namespace MPI
48  {
49  class BlockVector;
50  }
51 }
52 #endif
53 
54 namespace LinearAlgebra
55 {
56  namespace distributed
57  {
58 
80  template <typename Number>
81  class BlockVector : public BlockVectorBase<Vector<Number> >,
82  public VectorSpaceVector<Number>
83  {
84  public:
89 
93  typedef typename BaseClass::BlockType BlockType;
94 
98  typedef typename BaseClass::value_type value_type;
99  typedef typename BaseClass::real_type real_type;
100  typedef typename BaseClass::pointer pointer;
101  typedef typename BaseClass::const_pointer const_pointer;
102  typedef typename BaseClass::reference reference;
103  typedef typename BaseClass::const_reference const_reference;
104  typedef typename BaseClass::size_type size_type;
105  typedef typename BaseClass::iterator iterator;
106  typedef typename BaseClass::const_iterator const_iterator;
107 
112 
123  explicit BlockVector (const size_type num_blocks = 0,
124  const size_type block_size = 0);
125 
130  BlockVector (const BlockVector<Number> &V);
131 
144  template <typename OtherNumber>
145  explicit
147 
152  BlockVector (const std::vector<size_type> &block_sizes);
153 
158  BlockVector (const std::vector<IndexSet> &local_ranges,
159  const std::vector<IndexSet> &ghost_indices,
160  const MPI_Comm communicator);
161 
165  BlockVector (const std::vector<IndexSet> &local_ranges,
166  const MPI_Comm communicator);
167 
172  virtual BlockVector &operator = (const value_type s) override;
173 
178  BlockVector &
179  operator= (const BlockVector &V);
180 
185  template <class Number2>
186  BlockVector &
188 
192  BlockVector &
193  operator= (const Vector<Number> &V);
194 
195 #ifdef DEAL_II_WITH_PETSC
196 
205 #endif
206 
207 #ifdef DEAL_II_WITH_TRILINOS
208 
217  operator = (const TrilinosWrappers::MPI::BlockVector &trilinos_vec);
218 #endif
219 
233  void reinit (const size_type num_blocks,
234  const size_type block_size = 0,
235  const bool omit_zeroing_entries = false);
236 
256  void reinit (const std::vector<size_type> &N,
257  const bool omit_zeroing_entries=false);
258 
273  template <typename Number2>
274  void reinit (const BlockVector<Number2> &V,
275  const bool omit_zeroing_entries=false);
276 
301  virtual void compress (::VectorOperation::values operation) override;
302 
311  void update_ghost_values () const;
312 
321  void zero_out_ghosts ();
322 
326  bool has_ghost_elements() const;
327 
332  template <typename OtherNumber>
333  void add (const std::vector<size_type> &indices,
334  const ::Vector<OtherNumber> &values);
335 
340  void sadd (const Number s,
341  const BlockVector<Number> &V);
342 
348  void equ (const Number a, const BlockVector<Number> &u,
349  const Number b, const BlockVector<Number> &v) DEAL_II_DEPRECATED;
350 
356  void sadd (const Number s,
357  const Number a,
358  const BlockVector<Number> &V,
359  const Number b,
360  const BlockVector<Number> &W) DEAL_II_DEPRECATED;
361 
367  virtual bool all_zero () const override;
368 
372  virtual Number mean_value () const override;
373 
378  real_type lp_norm (const real_type p) const;
379 
397  void swap (BlockVector<Number> &v);
399 
404 
409  virtual void reinit(const VectorSpaceVector<Number> &V,
410  const bool omit_zeroing_entries = false) override;
411 
415  virtual BlockVector<Number> &operator*= (const Number factor) override;
416 
420  virtual BlockVector<Number> &operator/= (const Number factor) override;
421 
425  virtual BlockVector<Number> &operator+= (const VectorSpaceVector<Number> &V) override;
426 
430  virtual BlockVector<Number> &operator-= (const VectorSpaceVector<Number> &V) override;
431 
440  virtual void import(const LinearAlgebra::ReadWriteVector<Number> &V,
441  VectorOperation::values operation,
442  std::shared_ptr<const CommunicationPatternBase> communication_pattern =
443  std::shared_ptr<const CommunicationPatternBase> ()) override;
444 
448  virtual Number operator* (const VectorSpaceVector<Number> &V) const override;
449 
453  virtual void add(const Number a) override;
454 
458  virtual void add(const Number a, const VectorSpaceVector<Number> &V) override;
459 
463  virtual void add(const Number a, const VectorSpaceVector<Number> &V,
464  const Number b, const VectorSpaceVector<Number> &W) override;
465 
470  virtual void add (const std::vector<size_type> &indices,
471  const std::vector<Number> &values);
472 
477  virtual void sadd(const Number s, const Number a,
478  const VectorSpaceVector<Number> &V) override;
479 
485  virtual void scale(const VectorSpaceVector<Number> &scaling_factors) override;
486 
490  virtual void equ(const Number a, const VectorSpaceVector<Number> &V) override;
491 
496  virtual real_type l1_norm() const override;
497 
502  virtual real_type l2_norm() const override;
503 
508  virtual real_type linfty_norm() const override;
509 
526  virtual Number add_and_dot(const Number a,
527  const VectorSpaceVector<Number> &V,
528  const VectorSpaceVector<Number> &W) override;
529 
534  virtual size_type size() const override;
535 
547  virtual ::IndexSet locally_owned_elements() const override;
548 
552  virtual void print(std::ostream &out,
553  const unsigned int precision=3,
554  const bool scientific=true,
555  const bool across=true) const override;
556 
560  virtual std::size_t memory_consumption() const override;
562 
574 
580  };
581 
584  } // end of namespace distributed
585 
586 } // end of namespace LinearAlgebra
587 
588 
597 template <typename Number>
598 inline
601 {
602  u.swap (v);
603 }
604 
605 
611 template <typename Number>
612 struct is_serial_vector< LinearAlgebra::distributed::BlockVector< Number > > : std::false_type
613 {
614 };
615 
616 
617 DEAL_II_NAMESPACE_CLOSE
618 
619 #ifdef DEAL_II_MSVC
620 #include <deal.II/lac/la_parallel_block_vector.templates.h>
621 #endif
622 
623 #endif
static::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
virtual std::size_t memory_consumption() const override
virtual BlockVector< Number > & operator-=(const VectorSpaceVector< Number > &V) override
virtual void compress(::VectorOperation::values operation) override
virtual BlockVector & operator=(const value_type s) override
virtual BlockVector< Number > & operator/=(const Number factor) override
virtual real_type l2_norm() const override
virtual Number mean_value() const override
virtual real_type linfty_norm() const override
virtual bool all_zero() const override
void reinit(const size_type num_blocks, const size_type block_size=0, const bool omit_zeroing_entries=false)
BlockVectorBase< Vector< Number > > BaseClass
static::ExceptionBase & ExcVectorTypeNotCompatible()
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
void swap(LinearAlgebra::distributed::BlockVector< Number > &u, LinearAlgebra::distributed::BlockVector< Number > &v)
#define DeclException0(Exception0)
Definition: exceptions.h:570
virtual real_type l1_norm() const override
void swap(BlockVector< Number > &v)
real_type lp_norm(const real_type p) const
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
BlockVector(const size_type num_blocks=0, const size_type block_size=0)
virtual size_type size() const override
void equ(const Number a, const BlockVector< Number > &u, const Number b, const BlockVector< Number > &v) 1
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
virtual BlockVector< Number > & operator+=(const VectorSpaceVector< Number > &V) override
virtual ::IndexSet locally_owned_elements() const override
void sadd(const Number s, const BlockVector< Number > &V)
virtual BlockVector< Number > & operator*=(const Number factor) override
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override