deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2010 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#include <deal.II/base/config.h>
14
18#include <deal.II/base/mpi.h>
20#include <deal.II/base/types.h>
21
23
24#include <Kokkos_Macros.hpp>
25
26#include <cstddef>
27#include <numeric>
28#include <vector>
29
30
32
33namespace internal
34{
35 namespace DoFHandlerImplementation
36 {
40
41
42
44 : n_global_dofs(n_global_dofs)
45 , n_locally_owned_dofs(n_global_dofs)
46 , locally_owned_dofs(complete_index_set(n_global_dofs))
47 , n_locally_owned_dofs_per_processor(1, n_global_dofs)
48 , locally_owned_dofs_per_processor(1, complete_index_set(n_global_dofs))
49 {}
50
51
52
54 const std::vector<IndexSet> &locally_owned_dofs_per_processor,
55 const unsigned int my_rank)
56 : locally_owned_dofs_per_processor(locally_owned_dofs_per_processor)
57 {
58 const unsigned int n_procs = locally_owned_dofs_per_processor.size();
59
60 // compress IndexSet representation before using it for anything else
61 for (unsigned int p = 0; p < n_procs; ++p)
63
65 for (unsigned int p = 0; p < n_procs; ++p)
70
71
73 std::accumulate(n_locally_owned_dofs_per_processor.begin(),
76 }
77
78
79
80 void
89
90
91
92 std::vector<types::global_dof_index>
94 const MPI_Comm mpi_communicator) const
95 {
96 if (n_global_dofs == 0)
97 return std::vector<types::global_dof_index>();
98 else if (n_locally_owned_dofs_per_processor.empty() == false)
99 {
101 Utilities::MPI::n_mpi_processes(mpi_communicator));
103 }
104 else
105 {
106 return Utilities::MPI::all_gather(mpi_communicator,
108 }
109 }
110
111
112
113 std::vector<IndexSet>
115 const MPI_Comm mpi_communicator) const
116 {
118 if (n_global_dofs == 0)
119 return std::vector<IndexSet>();
120 else if (locally_owned_dofs_per_processor.empty() == false)
121 {
123 Utilities::MPI::n_mpi_processes(mpi_communicator));
125 }
126 else
127 {
128 return Utilities::MPI::all_gather(mpi_communicator,
130 }
131 }
132
133
134 std::size_t
145 } // namespace DoFHandlerImplementation
146} // namespace internal
147
size_type size() const
Definition index_set.h:1759
void clear()
Definition index_set.h:1735
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define AssertDimension(dim1, dim2)
IndexSet complete_index_set(const IndexSet::size_type N)
Definition index_set.h:1187
const unsigned int my_rank
Definition mpi.cc:917
const unsigned int n_procs
Definition mpi.cc:923
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:103
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