ExaDG
Loading...
Searching...
No Matches
dof_tools_extension.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2022 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_FLUID_STRUCTURE_INTERACTION_PRECICE_DOF_TOOLS_EXTENSION_H_
23#define INCLUDE_EXADG_FLUID_STRUCTURE_INTERACTION_PRECICE_DOF_TOOLS_EXTENSION_H_
24
25// deal.II
26#include <deal.II/dofs/dof_handler.h>
27#include <deal.II/dofs/dof_tools.h>
28
29#include <deal.II/fe/fe.h>
30#include <deal.II/fe/mapping_q_generic.h>
31
32DEAL_II_NAMESPACE_OPEN
33
34namespace DoFTools
35{
40template<int dim, int spacedim>
41void
42map_boundary_dofs_to_support_points(
43 Mapping<dim, spacedim> const & mapping,
44 DoFHandler<dim, spacedim> const & dof_handler,
45 std::map<types::global_dof_index, Point<spacedim>> & support_points,
46 ComponentMask const & in_mask,
47 types::boundary_id const boundary_id)
48{
49 FiniteElement<dim, spacedim> const & fe = dof_handler.get_fe();
50 // check whether every fe in the collection has support points
51 Assert(fe.has_support_points(), typename FiniteElement<dim>::ExcFEHasNoSupportPoints());
52
53 Quadrature<dim - 1> const quad(fe.get_unit_face_support_points());
54
55 // Take care of components
56 ComponentMask const mask =
57 (in_mask.size() == 0 ? ComponentMask(fe.n_components(), true) : in_mask);
58
59 // Now loop over all cells and enquire the support points on each
60 // of these. we use dummy quadrature formulas where the quadrature
61 // points are located at the unit support points to enquire the
62 // location of the support points in real space.
63 //
64 // The weights of the quadrature rule have been set to invalid
65 // values by the used constructor.
66 FEFaceValues<dim, spacedim> fe_values(mapping, fe, quad, update_quadrature_points);
67
68 std::vector<types::global_dof_index> local_dof_indices;
69 for(auto const & cell : dof_handler.active_cell_iterators())
70 if(cell->is_locally_owned())
71 for(auto const & face : cell->face_iterators())
72 if(face->at_boundary() == true and face->boundary_id() == boundary_id)
73 // only work on locally relevant cells
74 {
75 fe_values.reinit(cell, face);
76
77 local_dof_indices.resize(fe.dofs_per_face);
78 face->get_dof_indices(local_dof_indices);
79
80 std::vector<Point<spacedim>> const & points = fe_values.get_quadrature_points();
81
82 for(unsigned int i = 0; i < fe.n_dofs_per_face(); ++i)
83 {
84 unsigned int const dof_comp = fe.face_system_to_component_index(i).first;
85
86 // insert the values into the map if it is a valid component
87 if(mask[dof_comp])
88 support_points[local_dof_indices[i]] = points[i];
89 }
90 }
91}
92} // namespace DoFTools
93
94DEAL_II_NAMESPACE_CLOSE
95
96#endif