Reference documentation for deal.II version 8.5.1
petsc_parallel_block_vector.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2015 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 #include <deal.II/lac/petsc_parallel_block_vector.h>
17 
18 #ifdef DEAL_II_WITH_PETSC
19 
20 # include <deal.II/lac/petsc_block_vector.h>
21 
22 DEAL_II_NAMESPACE_OPEN
23 
24 namespace PETScWrappers
25 {
26  namespace MPI
27  {
29 
30  BlockVector &
32  {
33  this->block_indices = v.get_block_indices();
34 
35  if (this->components.size() != this->n_blocks())
36  this->components.resize(this->n_blocks());
37 
38  for (unsigned int i=0; i<this->n_blocks(); ++i)
39  this->block(i) = v.block(i);
40 
41  return *this;
42  }
43 
44 
45  void
46  BlockVector::reinit (const unsigned int num_blocks)
47  {
48  std::vector<size_type> block_sizes (num_blocks, 0);
49  this->block_indices.reinit (block_sizes);
50  if (this->components.size() != this->n_blocks())
51  this->components.resize(this->n_blocks());
52 
53  for (unsigned int i=0; i<this->n_blocks(); ++i)
54  components[i].reinit (MPI_COMM_SELF, 0, 0);
55 
56  collect_sizes();
57  }
58  }
59 
60 }
61 
62 DEAL_II_NAMESPACE_CLOSE
63 
64 #endif // DEAL_II_WITH_PETSC
void reinit(const unsigned int n_blocks, const MPI_Comm &communicator, const size_type block_size, const size_type local_size, const bool omit_zeroing_entries=false)
unsigned int global_dof_index
Definition: types.h:88
const BlockIndices & get_block_indices() const
void reinit(const unsigned int n_blocks, const size_type n_elements_per_block)
std::vector< Vector > components
unsigned int n_blocks() const
BlockVector & operator=(const value_type s)
BlockType & block(const unsigned int i)