Reference documentation for deal.II version GIT relicensing-245-g36f19064f7 2024-03-29 07:20:02+00:00
\(\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// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2010 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
16#include <deal.II/base/mpi.h>
17
19
20#include <numeric>
21
22
24
25namespace internal
26{
27 namespace DoFHandlerImplementation
28 {
32
33
34
36 : n_global_dofs(n_global_dofs)
37 , n_locally_owned_dofs(n_global_dofs)
38 , locally_owned_dofs(complete_index_set(n_global_dofs))
39 , n_locally_owned_dofs_per_processor(1, n_global_dofs)
40 , locally_owned_dofs_per_processor(1, complete_index_set(n_global_dofs))
41 {}
42
43
44
46 const std::vector<IndexSet> &locally_owned_dofs_per_processor,
47 const unsigned int my_rank)
48 : locally_owned_dofs_per_processor(locally_owned_dofs_per_processor)
49 {
50 const unsigned int n_procs = locally_owned_dofs_per_processor.size();
51
52 // compress IndexSet representation before using it for anything else
53 for (unsigned int p = 0; p < n_procs; ++p)
55
57 for (unsigned int p = 0; p < n_procs; ++p)
62
63
65 std::accumulate(n_locally_owned_dofs_per_processor.begin(),
68 }
69
70
71
72 void
81
82
83
84 std::vector<types::global_dof_index>
86 const MPI_Comm mpi_communicator) const
87 {
88 if (n_global_dofs == 0)
89 return std::vector<types::global_dof_index>();
90 else if (n_locally_owned_dofs_per_processor.empty() == false)
91 {
93 Utilities::MPI::n_mpi_processes(mpi_communicator));
95 }
96 else
97 {
98 return Utilities::MPI::all_gather(mpi_communicator,
100 }
101 }
102
103
104
105 std::vector<IndexSet>
107 const MPI_Comm mpi_communicator) const
108 {
110 if (n_global_dofs == 0)
111 return std::vector<IndexSet>();
112 else if (locally_owned_dofs_per_processor.empty() == false)
113 {
115 Utilities::MPI::n_mpi_processes(mpi_communicator));
117 }
118 else
119 {
120 return Utilities::MPI::all_gather(mpi_communicator,
122 }
123 }
124
125
126 std::size_t
137 } // namespace DoFHandlerImplementation
138} // namespace internal
139
size_type size() const
Definition index_set.h:1765
void clear()
Definition index_set.h:1741
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define AssertDimension(dim1, dim2)
IndexSet complete_index_set(const IndexSet::size_type N)
Definition index_set.h:1193
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
Definition mpi.cc:128
std::vector< T > all_gather(const MPI_Comm comm, const T &object_to_send)
std::vector< types::global_dof_index > n_locally_owned_dofs_per_processor
std::vector< IndexSet > locally_owned_dofs_per_processor
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