deal.II version GIT relicensing-6839-g338455934c 2026-10-02 12:10: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
mg_constrained_dofs.h
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#ifndef dealii_mg_constrained_dofs_h
14#define dealii_mg_constrained_dofs_h
15
16#include <deal.II/base/config.h>
17
20
22
24
25#include <set>
26#include <vector>
27
29
30// Forward declaration
31#ifndef DOXYGEN
32template <int dim, int spacedim>
34class DoFHandler;
35#endif
36
37
45{
46public:
47 using size_dof = std::vector<std::set<types::global_dof_index>>::size_type;
80 template <int dim, int spacedim>
81 void
83 const MGLevelObject<IndexSet> &level_relevant_dofs =
85 const bool initialize_periodicity_constraints = true);
86
97 template <int dim, int spacedim>
98 void
100 const DoFHandler<dim, spacedim> &dof,
101 const std::set<types::boundary_id> &boundary_ids,
102 const ComponentMask &component_mask = {});
103
110 template <int dim, int spacedim>
111 void
113 const unsigned int level,
115
130 void
131 add_user_constraints(const unsigned int level,
132 const AffineConstraints<double> &constraints_on_level);
133
148 template <int dim, int spacedim>
149 void
151 const types::boundary_id bid,
152 const unsigned int first_vector_component);
153
157 void
159
163 void
164 clear();
165
169 bool
170 is_boundary_index(const unsigned int level,
171 const types::global_dof_index index) const;
172
176 bool
177 at_refinement_edge(const unsigned int level,
178 const types::global_dof_index index) const;
179
180
187 bool
188 is_interface_matrix_entry(const unsigned int level,
190 const types::global_dof_index j) const;
191
198 const IndexSet &
199 get_boundary_indices(const unsigned int level) const;
200
201
206 const IndexSet &
207 get_refinement_edge_indices(unsigned int level) const;
208
209
213 bool
214 have_boundary_indices() const;
215
221 get_level_constraints(const unsigned int level) const;
222
231 get_user_constraint_matrix(const unsigned int level) const;
232
245 template <typename Number>
246 void
248 const unsigned int level,
249 const bool add_boundary_indices,
250 const bool add_refinement_edge_indices,
251 const bool add_level_constraints,
252 const bool add_user_constraints) const;
253
254private:
258 std::vector<IndexSet> boundary_indices;
259
264 std::vector<IndexSet> refinement_edge_indices;
265
270 std::vector<AffineConstraints<double>> level_constraints;
271
275 std::vector<AffineConstraints<double>> user_constraints;
276};
277
278
279
280inline bool
282 const types::global_dof_index index) const
283{
284 if (boundary_indices.empty())
285 return false;
286
288 return boundary_indices[level].is_element(index);
289}
290
291
292
293inline bool
295 const types::global_dof_index index) const
296{
298
299 return refinement_edge_indices[level].is_element(index);
300}
301
302
303
304inline bool
306 const unsigned int level,
308 const types::global_dof_index j) const
309{
310 const IndexSet &interface_dofs_on_level =
311 this->get_refinement_edge_indices(level);
312
313 return interface_dofs_on_level.is_element(i) // at_refinement_edge(i)
314 && !interface_dofs_on_level.is_element(j) // !at_refinement_edge(j)
315 && !this->is_boundary_index(level, i) // !on_boundary(i)
316 && !this->is_boundary_index(level, j); // !on_boundary(j)
317}
318
319
320
321inline const IndexSet &
327
328
329
330inline const IndexSet &
336
337
338
339inline bool
341{
342 return boundary_indices.size() != 0;
343}
344
345
346
347inline const AffineConstraints<double> &
353
354
355
356inline const AffineConstraints<double> &
362
363
364
366
367#endif
bool is_element(const size_type index) const
Definition index_set.h:1877
std::vector< IndexSet > refinement_edge_indices
std::vector< AffineConstraints< double > > user_constraints
void make_no_normal_flux_constraints(const DoFHandler< dim, spacedim > &dof, const types::boundary_id bid, const unsigned int first_vector_component)
bool is_interface_matrix_entry(const unsigned int level, const types::global_dof_index i, const types::global_dof_index j) const
void make_zero_boundary_constraints(const DoFHandler< dim, spacedim > &dof, const std::set< types::boundary_id > &boundary_ids, const ComponentMask &component_mask={})
std::vector< IndexSet > boundary_indices
void add_boundary_indices(const DoFHandler< dim, spacedim > &dof, const unsigned int level, const IndexSet &boundary_indices)
bool at_refinement_edge(const unsigned int level, const types::global_dof_index index) const
bool is_boundary_index(const unsigned int level, const types::global_dof_index index) const
void merge_constraints(AffineConstraints< Number > &constraints, const unsigned int level, const bool add_boundary_indices, const bool add_refinement_edge_indices, const bool add_level_constraints, const bool add_user_constraints) const
std::vector< AffineConstraints< double > > level_constraints
bool have_boundary_indices() const
void add_user_constraints(const unsigned int level, const AffineConstraints< double > &constraints_on_level)
const IndexSet & get_refinement_edge_indices(unsigned int level) const
const AffineConstraints< double > & get_user_constraint_matrix(const unsigned int level) const
std::vector< std::set< types::global_dof_index > >::size_type size_dof
const AffineConstraints< double > & get_level_constraints(const unsigned int level) const
const IndexSet & get_boundary_indices(const unsigned int level) const
void initialize(const DoFHandler< dim, spacedim > &dof, const MGLevelObject< IndexSet > &level_relevant_dofs=MGLevelObject< IndexSet >(), const bool initialize_periodicity_constraints=true)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:249
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
unsigned int level
Definition grid_out.cc:4642
#define AssertIndexRange(index, range)