Reference documentation for deal.II version 9.4.1
\(\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\}}\)
Loading...
Searching...
No Matches
number_cache.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1998 - 2022 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
26namespace internal
27{
28 namespace DoFHandlerImplementation
29 {
31 : NumberCache(0)
32 {}
33
34
35
37 : n_global_dofs(n_global_dofs)
38 , n_locally_owned_dofs(n_global_dofs)
39 , locally_owned_dofs(complete_index_set(n_global_dofs))
40 , n_locally_owned_dofs_per_processor(1, n_global_dofs)
41 , locally_owned_dofs_per_processor(1, complete_index_set(n_global_dofs))
42 {}
43
44
45
47 const std::vector<IndexSet> &locally_owned_dofs_per_processor,
48 const unsigned int my_rank)
49 : locally_owned_dofs_per_processor(locally_owned_dofs_per_processor)
50 {
51 const unsigned int n_procs = locally_owned_dofs_per_processor.size();
52
53 // compress IndexSet representation before using it for anything else
54 for (unsigned int p = 0; p < n_procs; ++p)
56
58 for (unsigned int p = 0; p < n_procs; ++p)
63
64
66 std::accumulate(n_locally_owned_dofs_per_processor.begin(),
69 }
70
71
72
73 void
75 {
76 n_global_dofs = 0;
81 }
82
83
84
85 std::vector<types::global_dof_index>
87 const MPI_Comm &mpi_communicator) const
88 {
89 if (n_global_dofs == 0)
90 return std::vector<types::global_dof_index>();
91 else if (n_locally_owned_dofs_per_processor.empty() == false)
92 {
95 Utilities::MPI::n_mpi_processes(mpi_communicator) :
96 1));
98 }
99 else
100 {
101 return Utilities::MPI::all_gather(mpi_communicator,
103 }
104 }
105
106
107
108 std::vector<IndexSet>
110 const MPI_Comm &mpi_communicator) const
111 {
113 if (n_global_dofs == 0)
114 return std::vector<IndexSet>();
115 else if (locally_owned_dofs_per_processor.empty() == false)
116 {
119 Utilities::MPI::n_mpi_processes(mpi_communicator) :
120 1));
122 }
123 else
124 {
125 return Utilities::MPI::all_gather(mpi_communicator,
127 }
128 }
129
130
131 std::size_t
133 {
141 }
142 } // namespace DoFHandlerImplementation
143} // namespace internal
144
size_type size() const
Definition: index_set.h:1636
void clear()
Definition: index_set.h:1612
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1667
IndexSet complete_index_set(const IndexSet::size_type N)
Definition: index_set.h:1014
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< T > all_gather(const MPI_Comm &comm, const T &object_to_send)
bool job_supports_mpi()
Definition: mpi.cc:1014
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:140
std::vector< types::global_dof_index > n_locally_owned_dofs_per_processor
Definition: number_cache.h:169
std::vector< IndexSet > locally_owned_dofs_per_processor
Definition: number_cache.h:180
std::vector< IndexSet > get_locally_owned_dofs_per_processor(const MPI_Comm &mpi_communicator) const
std::vector< types::global_dof_index > get_n_locally_owned_dofs_per_processor(const MPI_Comm &mpi_communicator) const
Definition: number_cache.cc:86