Reference documentation for deal.II version Git abc1da1e07 2020-07-06 12:09:19 -0400
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
number_cache.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2020 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 #include <deal.II/base/mpi.h>
18 
20 
21 #include <numeric>
22 
23 
25 
26 namespace internal
27 {
28  namespace DoFHandlerImplementation
29  {
31  : n_global_dofs(0)
32  , n_locally_owned_dofs(0)
33  {}
34 
35 
36 
38  : n_global_dofs(n_global_dofs)
39  , n_locally_owned_dofs(n_global_dofs)
40  , locally_owned_dofs(complete_index_set(n_global_dofs))
41  , n_locally_owned_dofs_per_processor(1, n_global_dofs)
43  {}
44 
45 
46 
48  const std::vector<IndexSet> &locally_owned_dofs_per_processor,
49  const unsigned int my_rank)
50  : locally_owned_dofs_per_processor(locally_owned_dofs_per_processor)
51  {
52  const unsigned int n_procs = locally_owned_dofs_per_processor.size();
53 
54  // compress IndexSet representation before using it for anything else
55  for (unsigned int p = 0; p < n_procs; ++p)
56  locally_owned_dofs_per_processor[p].compress();
57 
58  n_locally_owned_dofs_per_processor.resize(n_procs);
59  for (unsigned int p = 0; p < n_procs; ++p)
61  locally_owned_dofs_per_processor[p].n_elements();
63  locally_owned_dofs = locally_owned_dofs_per_processor[my_rank];
64 
65 
67  std::accumulate(n_locally_owned_dofs_per_processor.begin(),
70  }
71 
72 
73 
74  void
76  {
77  n_global_dofs = 0;
82  }
83 
84 
85 
86  std::vector<types::global_dof_index>
88  const MPI_Comm mpi_communicator) const
89  {
90  if (n_global_dofs == 0)
91  return std::vector<types::global_dof_index>();
92  else if (n_locally_owned_dofs_per_processor.empty() == false)
93  {
96  Utilities::MPI::n_mpi_processes(mpi_communicator) :
97  1));
99  }
100  else
101  {
102  return Utilities::MPI::all_gather(mpi_communicator,
104  }
105  }
106 
107 
108 
109  std::vector<IndexSet>
111  const MPI_Comm mpi_communicator) const
112  {
114  if (n_global_dofs == 0)
115  return std::vector<IndexSet>();
116  else if (locally_owned_dofs_per_processor.empty() == false)
117  {
120  Utilities::MPI::n_mpi_processes(mpi_communicator) :
121  1));
123  }
124  else
125  {
126  return Utilities::MPI::all_gather(mpi_communicator,
128  }
129  }
130 
131 
132  std::size_t
134  {
142  }
143  } // namespace DoFHandlerImplementation
144 } // namespace internal
145 
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1560
size_type size() const
Definition: index_set.h:1632
void clear()
Definition: index_set.h:1608
std::string compress(const std::string &input)
Definition: utilities.cc:392
std::vector< types::global_dof_index > get_n_locally_owned_dofs_per_processor(const MPI_Comm mpi_communicator) const
Definition: number_cache.cc:87
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
std::vector< types::global_dof_index > n_locally_owned_dofs_per_processor
Definition: number_cache.h:169
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:117
std::vector< IndexSet > get_locally_owned_dofs_per_processor(const MPI_Comm mpi_communicator) const
IndexSet complete_index_set(const IndexSet::size_type N)
Definition: index_set.h:1011
unsigned int global_dof_index
Definition: types.h:76
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
std::vector< IndexSet > locally_owned_dofs_per_processor
Definition: number_cache.h:180
std::vector< T > all_gather(const MPI_Comm &comm, const T &object_to_send)
bool job_supports_mpi()
Definition: mpi.cc:1030
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)