Reference documentation for deal.II version 9.2.0
\(\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)
42  , locally_owned_dofs_per_processor(1, complete_index_set(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)
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();
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 
memory_consumption.h
IndexSet::size
size_type size() const
Definition: index_set.h:1635
MPI_Comm
internal::DoFHandlerImplementation::NumberCache::clear
void clear()
Definition: number_cache.cc:75
internal::DoFHandlerImplementation::NumberCache::locally_owned_dofs
IndexSet locally_owned_dofs
Definition: number_cache.h:158
mpi.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
MemoryConsumption::memory_consumption
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
Definition: memory_consumption.h:268
internal::DoFHandlerImplementation::NumberCache::n_locally_owned_dofs
types::global_dof_index n_locally_owned_dofs
Definition: number_cache.h:147
AssertDimension
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1579
IndexSet::clear
void clear()
Definition: index_set.h:1611
internal::DoFHandlerImplementation::NumberCache::n_locally_owned_dofs_per_processor
std::vector< types::global_dof_index > n_locally_owned_dofs_per_processor
Definition: number_cache.h:169
internal::DoFHandlerImplementation::NumberCache::get_n_locally_owned_dofs_per_processor
std::vector< types::global_dof_index > get_n_locally_owned_dofs_per_processor(const MPI_Comm mpi_communicator) const
Definition: number_cache.cc:87
complete_index_set
IndexSet complete_index_set(const IndexSet::size_type N)
Definition: index_set.h:1014
unsigned int
internal::DoFHandlerImplementation::NumberCache::n_global_dofs
types::global_dof_index n_global_dofs
Definition: number_cache.h:137
Utilities::MPI::n_mpi_processes
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:117
Utilities::MPI::all_gather
std::vector< T > all_gather(const MPI_Comm &comm, const T &object_to_send)
internal
Definition: aligned_vector.h:369
internal::DoFHandlerImplementation::NumberCache::get_locally_owned_dofs_per_processor
std::vector< IndexSet > get_locally_owned_dofs_per_processor(const MPI_Comm mpi_communicator) const
Definition: number_cache.cc:110
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
internal::DoFHandlerImplementation::NumberCache::locally_owned_dofs_per_processor
std::vector< IndexSet > locally_owned_dofs_per_processor
Definition: number_cache.h:180
internal::DoFHandlerImplementation::NumberCache::NumberCache
NumberCache()
Definition: number_cache.cc:30
number_cache.h
Utilities::compress
std::string compress(const std::string &input)
Definition: utilities.cc:392
Utilities::MPI::job_supports_mpi
bool job_supports_mpi()
Definition: mpi.cc:1030
internal::DoFHandlerImplementation::NumberCache::memory_consumption
std::size_t memory_consumption() const
Definition: number_cache.cc:133