ExaDG
Loading...
Searching...
No Matches
constraints.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_OPERATORS_CONSTRAINTS_H_
23#define INCLUDE_EXADG_OPERATORS_CONSTRAINTS_H_
24
25// deal.II
26#include <deal.II/dofs/dof_tools.h>
27
28// ExaDG
29#include <exadg/grid/grid_utilities.h>
30
31namespace ExaDG
32{
37template<int dim, typename Number>
38void
39add_hanging_node_and_periodicity_constraints(dealii::AffineConstraints<Number> & affine_constraints,
40 Grid<dim> const & grid,
41 dealii::DoFHandler<dim> const & dof_handler)
42{
43 dealii::IndexSet locally_relevant_dofs;
44 dealii::DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
45 affine_constraints.reinit(locally_relevant_dofs);
46
47 // hanging nodes (needs to be done before imposing periodicity constraints
48 if(grid.triangulation->has_hanging_nodes())
49 {
50 dealii::DoFTools::make_hanging_node_constraints(dof_handler, affine_constraints);
51 }
52
53 // constraints from periodic boundary conditions
54 if(not(grid.periodic_face_pairs.empty()))
55 {
56 auto periodic_faces_dof =
57 GridUtilities::transform_periodic_face_pairs_to_dof_cell_iterator(grid.periodic_face_pairs,
58 dof_handler);
59
60 dealii::DoFTools::make_periodicity_constraints<dim, dim, Number>(periodic_faces_dof,
61 affine_constraints);
62 }
63}
64
69template<typename Key, typename Data>
70inline void
71fill_keys_of_map_into_set(std::set<Key> & set, std::map<Key, Data> const & map)
72{
73 for(auto iter : map)
74 {
75 set.insert(iter.first);
76 }
77}
78
83inline void
85 std::map<dealii::types::boundary_id, dealii::ComponentMask> & map_bid_to_mask,
86 std::set<dealii::types::boundary_id> const & set_boundary_ids)
87{
88 for(auto const & it : set_boundary_ids)
89 {
90 // use default mask if no maks has been defined
91 if(map_bid_to_mask.find(it) == map_bid_to_mask.end())
92 map_bid_to_mask.insert({it, dealii::ComponentMask()});
93 }
94}
95
102template<int dim, typename Number>
103void
105 dealii::AffineConstraints<Number> & affine_constraints,
106 dealii::DoFHandler<dim> const & dof_handler,
107 std::map<dealii::types::boundary_id, dealii::ComponentMask> const &
108 map_boundary_id_to_component_mask)
109{
110 for(auto const & it : map_boundary_id_to_component_mask)
111 {
112 dealii::DoFTools::make_zero_boundary_constraints(dof_handler,
113 it.first,
114 affine_constraints,
115 it.second);
116 }
117}
118
119} // namespace ExaDG
120
121#endif /* INCLUDE_EXADG_OPERATORS_CONSTRAINTS_H_ */
Definition grid.h:40
PeriodicFacePairs periodic_face_pairs
Definition grid.h:54
std::shared_ptr< dealii::Triangulation< dim > > triangulation
Definition grid.h:49
Definition driver.cpp:33
void add_hanging_node_and_periodicity_constraints(dealii::AffineConstraints< Number > &affine_constraints, Grid< dim > const &grid, dealii::DoFHandler< dim > const &dof_handler)
Definition constraints.h:39
void add_homogeneous_dirichlet_constraints(dealii::AffineConstraints< Number > &affine_constraints, dealii::DoFHandler< dim > const &dof_handler, std::map< dealii::types::boundary_id, dealii::ComponentMask > const &map_boundary_id_to_component_mask)
Definition constraints.h:104
void fill_map_bid_to_mask_with_default_mask(std::map< dealii::types::boundary_id, dealii::ComponentMask > &map_bid_to_mask, std::set< dealii::types::boundary_id > const &set_boundary_ids)
Definition constraints.h:84
void fill_keys_of_map_into_set(std::set< Key > &set, std::map< Key, Data > const &map)
Definition constraints.h:71